├── CleanSpec.mk ├── android ├── Android.mk ├── NOTICE ├── OldPhoneNumberUtils.cpp ├── PhoneNumberUtils.cpp ├── PhoneNumberUtils.h ├── PhoneNumberUtilsTest.cpp ├── sqlite3_android.cpp └── sqlite3_android.h └── dist ├── Android.mk ├── Android.patch ├── MODULE_LICENSE_PUBLIC_DOMAIN ├── NOTICE ├── README-Android ├── orig ├── shell.c ├── sqlite3.c ├── sqlite3.h └── sqlite3ext.h ├── shell.c ├── sqlite3.c ├── sqlite3.h ├── sqlite3ext.h └── version /CleanSpec.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2007 The Android Open Source Project 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # 15 | 16 | # If you don't need to do a full clean build but would like to touch 17 | # a file or delete some intermediate files, add a clean step to the end 18 | # of the list. These steps will only be run once, if they haven't been 19 | # run before. 20 | # 21 | # E.g.: 22 | # $(call add-clean-step, touch -c external/sqlite/sqlite3.h) 23 | # $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libz_intermediates) 24 | # 25 | # Always use "touch -c" and "rm -f" or "rm -rf" to gracefully deal with 26 | # files that are missing or have been moved. 27 | # 28 | # Use $(PRODUCT_OUT) to get to the "out/target/product/blah/" directory. 29 | # Use $(OUT_DIR) to refer to the "out" directory. 30 | # 31 | # If you need to re-do something that's already mentioned, just copy 32 | # the command and add it to the bottom of the list. E.g., if a change 33 | # that you made last week required touching a file and a change you 34 | # made today requires touching the same file, just copy the old 35 | # touch step and add it to the end of the list. 36 | # 37 | # ************************************************ 38 | # NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST 39 | # ************************************************ 40 | 41 | # For example: 42 | #$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/AndroidTests_intermediates) 43 | #$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/core_intermediates) 44 | #$(call add-clean-step, find $(OUT_DIR) -type f -name "IGTalkSession*" -print0 | xargs -0 rm -f) 45 | #$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/*) 46 | 47 | # ************************************************ 48 | # NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST 49 | # ************************************************ 50 | 51 | $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libsqlite_intermediates) 52 | $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libsqlite3_android_intermediates/import_includes) 53 | $(call add-clean-step, rm -rf $(HOST_OUT)/obj/STATIC_LIBRARIES/libsqlite3_android_intermediates/import_includes) 54 | $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libsqlite_intermediates) 55 | -------------------------------------------------------------------------------- /android/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH:= $(call my-dir) 2 | 3 | libsqlite3_android_local_src_files := \ 4 | PhoneNumberUtils.cpp \ 5 | OldPhoneNumberUtils.cpp \ 6 | sqlite3_android.cpp 7 | 8 | libsqlite3_android_c_includes := \ 9 | external/sqlite/dist \ 10 | external/icu/icu4c/source/i18n \ 11 | external/icu/icu4c/source/common 12 | 13 | include $(CLEAR_VARS) 14 | LOCAL_SRC_FILES:= $(libsqlite3_android_local_src_files) 15 | LOCAL_C_INCLUDES := $(libsqlite3_android_c_includes) 16 | LOCAL_STATIC_LIBRARIES := liblog 17 | LOCAL_MODULE:= libsqlite3_android 18 | include $(BUILD_STATIC_LIBRARY) 19 | 20 | include $(CLEAR_VARS) 21 | LOCAL_SRC_FILES:= $(libsqlite3_android_local_src_files) 22 | LOCAL_C_INCLUDES := $(libsqlite3_android_c_includes) 23 | LOCAL_STATIC_LIBRARIES := liblog 24 | LOCAL_MODULE:= libsqlite3_android 25 | include $(BUILD_HOST_STATIC_LIBRARY) 26 | 27 | # Test for PhoneNumberUtils 28 | # 29 | # You can also test this in Unix, like this: 30 | # > g++ -Wall external/sqlite/android/PhoneNumberUtils.cpp \ 31 | # external/sqlite/android/PhoneNumberUtilsTest.cpp 32 | # > ./a.out 33 | # 34 | # Note: This "test" is not recognized as a formal test. This is just for enabling developers 35 | # to easily check what they modified works well or not. 36 | # The formal test for phone_number_compare() is in DataBaseGeneralTest.java 37 | # (as of 2009-08-02), in which phone_number_compare() is tested via sqlite's custom 38 | # function "PHONE_NUMBER_COMPARE". 39 | # Please add tests if you modify the implementation of PhoneNumberUtils.cpp and add 40 | # test cases in PhoneNumberUtilsTest.cpp. 41 | include $(CLEAR_VARS) 42 | 43 | LOCAL_MODULE:= libsqlite3_phone_number_utils_test 44 | 45 | LOCAL_CFLAGS += -Wall -Werror 46 | 47 | LOCAL_SRC_FILES := \ 48 | PhoneNumberUtils.cpp \ 49 | PhoneNumberUtilsTest.cpp 50 | 51 | LOCAL_MODULE_TAGS := optional 52 | 53 | include $(BUILD_EXECUTABLE) 54 | -------------------------------------------------------------------------------- /android/NOTICE: -------------------------------------------------------------------------------- 1 | 2 | Copyright (c) 2005-2008, The Android Open Source Project 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | 13 | 14 | Apache License 15 | Version 2.0, January 2004 16 | http://www.apache.org/licenses/ 17 | 18 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 19 | 20 | 1. Definitions. 21 | 22 | "License" shall mean the terms and conditions for use, reproduction, 23 | and distribution as defined by Sections 1 through 9 of this document. 24 | 25 | "Licensor" shall mean the copyright owner or entity authorized by 26 | the copyright owner that is granting the License. 27 | 28 | "Legal Entity" shall mean the union of the acting entity and all 29 | other entities that control, are controlled by, or are under common 30 | control with that entity. For the purposes of this definition, 31 | "control" means (i) the power, direct or indirect, to cause the 32 | direction or management of such entity, whether by contract or 33 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 34 | outstanding shares, or (iii) beneficial ownership of such entity. 35 | 36 | "You" (or "Your") shall mean an individual or Legal Entity 37 | exercising permissions granted by this License. 38 | 39 | "Source" form shall mean the preferred form for making modifications, 40 | including but not limited to software source code, documentation 41 | source, and configuration files. 42 | 43 | "Object" form shall mean any form resulting from mechanical 44 | transformation or translation of a Source form, including but 45 | not limited to compiled object code, generated documentation, 46 | and conversions to other media types. 47 | 48 | "Work" shall mean the work of authorship, whether in Source or 49 | Object form, made available under the License, as indicated by a 50 | copyright notice that is included in or attached to the work 51 | (an example is provided in the Appendix below). 52 | 53 | "Derivative Works" shall mean any work, whether in Source or Object 54 | form, that is based on (or derived from) the Work and for which the 55 | editorial revisions, annotations, elaborations, or other modifications 56 | represent, as a whole, an original work of authorship. For the purposes 57 | of this License, Derivative Works shall not include works that remain 58 | separable from, or merely link (or bind by name) to the interfaces of, 59 | the Work and Derivative Works thereof. 60 | 61 | "Contribution" shall mean any work of authorship, including 62 | the original version of the Work and any modifications or additions 63 | to that Work or Derivative Works thereof, that is intentionally 64 | submitted to Licensor for inclusion in the Work by the copyright owner 65 | or by an individual or Legal Entity authorized to submit on behalf of 66 | the copyright owner. For the purposes of this definition, "submitted" 67 | means any form of electronic, verbal, or written communication sent 68 | to the Licensor or its representatives, including but not limited to 69 | communication on electronic mailing lists, source code control systems, 70 | and issue tracking systems that are managed by, or on behalf of, the 71 | Licensor for the purpose of discussing and improving the Work, but 72 | excluding communication that is conspicuously marked or otherwise 73 | designated in writing by the copyright owner as "Not a Contribution." 74 | 75 | "Contributor" shall mean Licensor and any individual or Legal Entity 76 | on behalf of whom a Contribution has been received by Licensor and 77 | subsequently incorporated within the Work. 78 | 79 | 2. Grant of Copyright License. Subject to the terms and conditions of 80 | this License, each Contributor hereby grants to You a perpetual, 81 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 82 | copyright license to reproduce, prepare Derivative Works of, 83 | publicly display, publicly perform, sublicense, and distribute the 84 | Work and such Derivative Works in Source or Object form. 85 | 86 | 3. Grant of Patent License. Subject to the terms and conditions of 87 | this License, each Contributor hereby grants to You a perpetual, 88 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 89 | (except as stated in this section) patent license to make, have made, 90 | use, offer to sell, sell, import, and otherwise transfer the Work, 91 | where such license applies only to those patent claims licensable 92 | by such Contributor that are necessarily infringed by their 93 | Contribution(s) alone or by combination of their Contribution(s) 94 | with the Work to which such Contribution(s) was submitted. If You 95 | institute patent litigation against any entity (including a 96 | cross-claim or counterclaim in a lawsuit) alleging that the Work 97 | or a Contribution incorporated within the Work constitutes direct 98 | or contributory patent infringement, then any patent licenses 99 | granted to You under this License for that Work shall terminate 100 | as of the date such litigation is filed. 101 | 102 | 4. Redistribution. You may reproduce and distribute copies of the 103 | Work or Derivative Works thereof in any medium, with or without 104 | modifications, and in Source or Object form, provided that You 105 | meet the following conditions: 106 | 107 | (a) You must give any other recipients of the Work or 108 | Derivative Works a copy of this License; and 109 | 110 | (b) You must cause any modified files to carry prominent notices 111 | stating that You changed the files; and 112 | 113 | (c) You must retain, in the Source form of any Derivative Works 114 | that You distribute, all copyright, patent, trademark, and 115 | attribution notices from the Source form of the Work, 116 | excluding those notices that do not pertain to any part of 117 | the Derivative Works; and 118 | 119 | (d) If the Work includes a "NOTICE" text file as part of its 120 | distribution, then any Derivative Works that You distribute must 121 | include a readable copy of the attribution notices contained 122 | within such NOTICE file, excluding those notices that do not 123 | pertain to any part of the Derivative Works, in at least one 124 | of the following places: within a NOTICE text file distributed 125 | as part of the Derivative Works; within the Source form or 126 | documentation, if provided along with the Derivative Works; or, 127 | within a display generated by the Derivative Works, if and 128 | wherever such third-party notices normally appear. The contents 129 | of the NOTICE file are for informational purposes only and 130 | do not modify the License. You may add Your own attribution 131 | notices within Derivative Works that You distribute, alongside 132 | or as an addendum to the NOTICE text from the Work, provided 133 | that such additional attribution notices cannot be construed 134 | as modifying the License. 135 | 136 | You may add Your own copyright statement to Your modifications and 137 | may provide additional or different license terms and conditions 138 | for use, reproduction, or distribution of Your modifications, or 139 | for any such Derivative Works as a whole, provided Your use, 140 | reproduction, and distribution of the Work otherwise complies with 141 | the conditions stated in this License. 142 | 143 | 5. Submission of Contributions. Unless You explicitly state otherwise, 144 | any Contribution intentionally submitted for inclusion in the Work 145 | by You to the Licensor shall be under the terms and conditions of 146 | this License, without any additional terms or conditions. 147 | Notwithstanding the above, nothing herein shall supersede or modify 148 | the terms of any separate license agreement you may have executed 149 | with Licensor regarding such Contributions. 150 | 151 | 6. Trademarks. This License does not grant permission to use the trade 152 | names, trademarks, service marks, or product names of the Licensor, 153 | except as required for reasonable and customary use in describing the 154 | origin of the Work and reproducing the content of the NOTICE file. 155 | 156 | 7. Disclaimer of Warranty. Unless required by applicable law or 157 | agreed to in writing, Licensor provides the Work (and each 158 | Contributor provides its Contributions) on an "AS IS" BASIS, 159 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 160 | implied, including, without limitation, any warranties or conditions 161 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 162 | PARTICULAR PURPOSE. You are solely responsible for determining the 163 | appropriateness of using or redistributing the Work and assume any 164 | risks associated with Your exercise of permissions under this License. 165 | 166 | 8. Limitation of Liability. In no event and under no legal theory, 167 | whether in tort (including negligence), contract, or otherwise, 168 | unless required by applicable law (such as deliberate and grossly 169 | negligent acts) or agreed to in writing, shall any Contributor be 170 | liable to You for damages, including any direct, indirect, special, 171 | incidental, or consequential damages of any character arising as a 172 | result of this License or out of the use or inability to use the 173 | Work (including but not limited to damages for loss of goodwill, 174 | work stoppage, computer failure or malfunction, or any and all 175 | other commercial damages or losses), even if such Contributor 176 | has been advised of the possibility of such damages. 177 | 178 | 9. Accepting Warranty or Additional Liability. While redistributing 179 | the Work or Derivative Works thereof, You may choose to offer, 180 | and charge a fee for, acceptance of support, warranty, indemnity, 181 | or other liability obligations and/or rights consistent with this 182 | License. However, in accepting such obligations, You may act only 183 | on Your own behalf and on Your sole responsibility, not on behalf 184 | of any other Contributor, and only if You agree to indemnify, 185 | defend, and hold each Contributor harmless for any liability 186 | incurred by, or claims asserted against, such Contributor by reason 187 | of your accepting any such warranty or additional liability. 188 | 189 | END OF TERMS AND CONDITIONS 190 | 191 | -------------------------------------------------------------------------------- /android/OldPhoneNumberUtils.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2006, The Android Open Source Project 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | // Old implementation for phone_number_compare(), which has used in cupcake, but once replaced with 19 | // the new, more strict version, and reverted again. 20 | 21 | #include 22 | 23 | namespace android { 24 | 25 | static int MIN_MATCH = 7; 26 | 27 | /** True if c is ISO-LATIN characters 0-9 */ 28 | static bool isISODigit (char c) 29 | { 30 | return c >= '0' && c <= '9'; 31 | } 32 | 33 | /** True if c is ISO-LATIN characters 0-9, *, # , + */ 34 | static bool isNonSeparator(char c) 35 | { 36 | return (c >= '0' && c <= '9') || c == '*' || c == '#' || c == '+'; 37 | } 38 | 39 | /** 40 | * Phone numbers are stored in "lookup" form in the database 41 | * as reversed strings to allow for caller ID lookup 42 | * 43 | * This method takes a phone number and makes a valid SQL "LIKE" 44 | * string that will match the lookup form 45 | * 46 | */ 47 | /** all of a up to len must be an international prefix or 48 | * separators/non-dialing digits 49 | */ 50 | static bool matchIntlPrefix(const char* a, int len) 51 | { 52 | /* '([^0-9*#+]\+[^0-9*#+] | [^0-9*#+]0(0|11)[^0-9*#+] )$' */ 53 | /* 0 1 2 3 45 */ 54 | 55 | int state = 0; 56 | for (int i = 0 ; i < len ; i++) { 57 | char c = a[i]; 58 | 59 | switch (state) { 60 | case 0: 61 | if (c == '+') state = 1; 62 | else if (c == '0') state = 2; 63 | else if (isNonSeparator(c)) return false; 64 | break; 65 | 66 | case 2: 67 | if (c == '0') state = 3; 68 | else if (c == '1') state = 4; 69 | else if (isNonSeparator(c)) return false; 70 | break; 71 | 72 | case 4: 73 | if (c == '1') state = 5; 74 | else if (isNonSeparator(c)) return false; 75 | break; 76 | 77 | default: 78 | if (isNonSeparator(c)) return false; 79 | break; 80 | 81 | } 82 | } 83 | 84 | return state == 1 || state == 3 || state == 5; 85 | } 86 | 87 | /** all of 'a' up to len must match non-US trunk prefix ('0') */ 88 | static bool matchTrunkPrefix(const char* a, int len) 89 | { 90 | bool found; 91 | 92 | found = false; 93 | 94 | for (int i = 0 ; i < len ; i++) { 95 | char c = a[i]; 96 | 97 | if (c == '0' && !found) { 98 | found = true; 99 | } else if (isNonSeparator(c)) { 100 | return false; 101 | } 102 | } 103 | 104 | return found; 105 | } 106 | 107 | /** all of 'a' up to len must be a (+|00|011)country code) 108 | * We're fast and loose with the country code. Any \d{1,3} matches */ 109 | static bool matchIntlPrefixAndCC(const char* a, int len) 110 | { 111 | /* [^0-9*#+]*(\+|0(0|11)\d\d?\d? [^0-9*#+] $ */ 112 | /* 0 1 2 3 45 6 7 8 */ 113 | 114 | int state = 0; 115 | for (int i = 0 ; i < len ; i++ ) { 116 | char c = a[i]; 117 | 118 | switch (state) { 119 | case 0: 120 | if (c == '+') state = 1; 121 | else if (c == '0') state = 2; 122 | else if (isNonSeparator(c)) return false; 123 | break; 124 | 125 | case 2: 126 | if (c == '0') state = 3; 127 | else if (c == '1') state = 4; 128 | else if (isNonSeparator(c)) return false; 129 | break; 130 | 131 | case 4: 132 | if (c == '1') state = 5; 133 | else if (isNonSeparator(c)) return false; 134 | break; 135 | 136 | case 1: 137 | case 3: 138 | case 5: 139 | if (isISODigit(c)) state = 6; 140 | else if (isNonSeparator(c)) return false; 141 | break; 142 | 143 | case 6: 144 | case 7: 145 | if (isISODigit(c)) state++; 146 | else if (isNonSeparator(c)) return false; 147 | break; 148 | 149 | default: 150 | if (isNonSeparator(c)) return false; 151 | } 152 | } 153 | 154 | return state == 6 || state == 7 || state == 8; 155 | } 156 | 157 | /** or -1 if both are negative */ 158 | static int minPositive(int a, int b) 159 | { 160 | if (a >= 0 && b >= 0) { 161 | return (a < b) ? a : b; 162 | } else if (a >= 0) { /* && b < 0 */ 163 | return a; 164 | } else if (b >= 0) { /* && a < 0 */ 165 | return b; 166 | } else { /* a < 0 && b < 0 */ 167 | return -1; 168 | } 169 | } 170 | 171 | /** 172 | * Return the offset into a of the first appearance of b, or -1 if there 173 | * is no such character in a. 174 | */ 175 | static int indexOf(const char *a, char b) { 176 | const char *ix = strchr(a, b); 177 | 178 | if (ix == NULL) 179 | return -1; 180 | else 181 | return ix - a; 182 | } 183 | 184 | /** 185 | * Compare phone numbers a and b, return true if they're identical 186 | * enough for caller ID purposes. 187 | * 188 | * - Compares from right to left 189 | * - requires MIN_MATCH (7) characters to match 190 | * - handles common trunk prefixes and international prefixes 191 | * (basically, everything except the Russian trunk prefix) 192 | * 193 | * Tolerates nulls 194 | */ 195 | bool phone_number_compare_loose(const char* a, const char* b) 196 | { 197 | int ia, ib; 198 | int matched; 199 | int numSeparatorCharsInA = 0; 200 | int numSeparatorCharsInB = 0; 201 | 202 | if (a == NULL || b == NULL) { 203 | return false; 204 | } 205 | 206 | ia = strlen(a); 207 | ib = strlen(b); 208 | if (ia == 0 || ib == 0) { 209 | return false; 210 | } 211 | 212 | // Compare from right to left 213 | ia--; 214 | ib--; 215 | 216 | matched = 0; 217 | 218 | while (ia >= 0 && ib >=0) { 219 | char ca, cb; 220 | bool skipCmp = false; 221 | 222 | ca = a[ia]; 223 | 224 | if (!isNonSeparator(ca)) { 225 | ia--; 226 | skipCmp = true; 227 | numSeparatorCharsInA++; 228 | } 229 | 230 | cb = b[ib]; 231 | 232 | if (!isNonSeparator(cb)) { 233 | ib--; 234 | skipCmp = true; 235 | numSeparatorCharsInB++; 236 | } 237 | 238 | if (!skipCmp) { 239 | if (cb != ca) { 240 | break; 241 | } 242 | ia--; ib--; matched++; 243 | } 244 | } 245 | 246 | if (matched < MIN_MATCH) { 247 | const int effectiveALen = strlen(a) - numSeparatorCharsInA; 248 | const int effectiveBLen = strlen(b) - numSeparatorCharsInB; 249 | 250 | // if the number of dialable chars in a and b match, but the matched chars < MIN_MATCH, 251 | // treat them as equal (i.e. 404-04 and 40404) 252 | if (effectiveALen == effectiveBLen && effectiveALen == matched) { 253 | return true; 254 | } 255 | 256 | return false; 257 | } 258 | 259 | // At least one string has matched completely; 260 | if (matched >= MIN_MATCH && (ia < 0 || ib < 0)) { 261 | return true; 262 | } 263 | 264 | /* 265 | * Now, what remains must be one of the following for a 266 | * match: 267 | * 268 | * - a '+' on one and a '00' or a '011' on the other 269 | * - a '0' on one and a (+,00) on the other 270 | * (for this, a '0' and a '00' prefix would have succeeded above) 271 | */ 272 | 273 | if (matchIntlPrefix(a, ia + 1) && matchIntlPrefix(b, ib +1)) { 274 | return true; 275 | } 276 | 277 | if (matchTrunkPrefix(a, ia + 1) && matchIntlPrefixAndCC(b, ib +1)) { 278 | return true; 279 | } 280 | 281 | if (matchTrunkPrefix(b, ib + 1) && matchIntlPrefixAndCC(a, ia +1)) { 282 | return true; 283 | } 284 | 285 | /* 286 | * Last resort: if the number of unmatched characters on both sides is less than or equal 287 | * to the length of the longest country code and only one number starts with a + accept 288 | * the match. This is because some countries like France and Russia have an extra prefix 289 | * digit that is used when dialing locally in country that does not show up when you dial 290 | * the number using the country code. In France this prefix digit is used to determine 291 | * which land line carrier to route the call over. 292 | */ 293 | bool aPlusFirst = (*a == '+'); 294 | bool bPlusFirst = (*b == '+'); 295 | if (ia < 4 && ib < 4 && (aPlusFirst || bPlusFirst) && !(aPlusFirst && bPlusFirst)) { 296 | return true; 297 | } 298 | 299 | return false; 300 | } 301 | 302 | } // namespace android 303 | -------------------------------------------------------------------------------- /android/PhoneNumberUtils.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2009, The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | #include 19 | 20 | namespace android { 21 | 22 | /* Generated by the following Python script. Values of country calling codes 23 | are from http://en.wikipedia.org/wiki/List_of_country_calling_codes 24 | 25 | #!/usr/bin/python 26 | import sys 27 | ccc_set_2digits = set([0, 1, 7, 28 | 20, 27, 28, 30, 31, 32, 33, 34, 36, 39, 40, 43, 44, 45, 29 | 46, 47, 48, 49, 51, 52, 53, 54, 55, 56, 57, 58, 60, 61, 30 | 62, 63, 64, 65, 66, 81, 82, 83, 84, 86, 89, 90, 91, 92, 31 | 93, 94, 95, 98]) 32 | 33 | ONE_LINE_NUM = 10 34 | 35 | for i in xrange(100): 36 | if i % ONE_LINE_NUM == 0: 37 | sys.stdout.write(' ') 38 | if i in ccc_set_2digits: 39 | included = 'true' 40 | else: 41 | included = 'false' 42 | sys.stdout.write(included + ',') 43 | if ((i + 1) % ONE_LINE_NUM) == 0: 44 | sys.stdout.write('\n') 45 | else: 46 | sys.stdout.write(' ') 47 | */ 48 | static bool two_length_country_code_map[100] = { 49 | true, true, false, false, false, false, false, true, false, false, 50 | false, false, false, false, false, false, false, false, false, false, 51 | true, false, false, false, false, false, false, true, true, false, 52 | true, true, true, true, true, false, true, false, false, true, 53 | true, false, false, true, true, true, true, true, true, true, 54 | false, true, true, true, true, true, true, true, true, false, 55 | true, true, true, true, true, true, true, false, false, false, 56 | false, false, false, false, false, false, false, false, false, false, 57 | false, true, true, true, true, false, true, false, false, true, 58 | true, true, true, true, true, true, false, false, true, false, 59 | }; 60 | 61 | #define ARRAY_SIZE(a) (sizeof(a)/sizeof((a)[0])) 62 | 63 | /** 64 | * Returns true if "ccc_candidate" expresses (part of ) some country calling 65 | * code. 66 | * Returns false otherwise. 67 | */ 68 | static bool isCountryCallingCode(int ccc_candidate) { 69 | return ccc_candidate > 0 && 70 | ccc_candidate < (int)ARRAY_SIZE(two_length_country_code_map) && 71 | two_length_country_code_map[ccc_candidate]; 72 | } 73 | 74 | /** 75 | * Returns interger corresponding to the input if input "ch" is 76 | * ISO-LATIN characters 0-9. 77 | * Returns -1 otherwise 78 | */ 79 | static int tryGetISODigit (char ch) 80 | { 81 | if ('0' <= ch && ch <= '9') { 82 | return ch - '0'; 83 | } else { 84 | return -1; 85 | } 86 | } 87 | 88 | /** 89 | * True if ch is ISO-LATIN characters 0-9, *, # , + 90 | * Note this method current does not account for the WILD char 'N' 91 | */ 92 | static bool isDialable(char ch) 93 | { 94 | return ('0' <= ch && ch <= '9') || ch == '*' || ch == '#' || ch == '+'; 95 | } 96 | 97 | /** Returns true if ch is not dialable or alpha char */ 98 | static bool isSeparator(char ch) 99 | { 100 | return !isDialable(ch) && (isalpha(ch) == 0); 101 | } 102 | 103 | /** 104 | * Try to store the pointer to "new_ptr" which does not have trunk prefix. 105 | * 106 | * Currently this function simply ignore the first digit assuming it is 107 | * trunk prefix. Actually trunk prefix is different in each country. 108 | * 109 | * e.g. 110 | * "+79161234567" equals "89161234567" (Russian trunk digit is 8) 111 | * "+33123456789" equals "0123456789" (French trunk digit is 0) 112 | * 113 | */ 114 | static bool tryGetTrunkPrefixOmittedStr(const char *str, size_t len, 115 | const char **new_ptr, size_t *new_len) 116 | { 117 | for (size_t i = 0 ; i < len ; i++) { 118 | char ch = str[i]; 119 | if (tryGetISODigit(ch) >= 0) { 120 | if (new_ptr != NULL) { 121 | *new_ptr = str + i + 1; 122 | } 123 | if (new_len != NULL) { 124 | *new_len = len - (i + 1); 125 | } 126 | return true; 127 | } else if (isDialable(ch)) { 128 | return false; 129 | } 130 | } 131 | 132 | return false; 133 | } 134 | 135 | /* 136 | * Note that this function does not strictly care the country calling code with 137 | * 3 length (like Morocco: +212), assuming it is enough to use the first two 138 | * digit to compare two phone numbers. 139 | */ 140 | static int tryGetCountryCallingCode(const char *str, size_t len, 141 | const char **new_ptr, size_t *new_len, 142 | bool accept_thailand_case) 143 | { 144 | // Rough regexp: 145 | // ^[^0-9*#+]*((\+|0(0|11)\d\d?|166) [^0-9*#+] $ 146 | // 0 1 2 3 45 6 7 89 147 | // 148 | // In all the states, this function ignores separator characters. 149 | // "166" is the special case for the call from Thailand to the US. Ugu! 150 | 151 | int state = 0; 152 | int ccc = 0; 153 | for (size_t i = 0 ; i < len ; i++ ) { 154 | char ch = str[i]; 155 | switch (state) { 156 | case 0: 157 | if (ch == '+') state = 1; 158 | else if (ch == '0') state = 2; 159 | else if (ch == '1') { 160 | if (accept_thailand_case) { 161 | state = 8; 162 | } else { 163 | return -1; 164 | } 165 | } else if (isDialable(ch)) return -1; 166 | break; 167 | 168 | case 2: 169 | if (ch == '0') state = 3; 170 | else if (ch == '1') state = 4; 171 | else if (isDialable(ch)) return -1; 172 | break; 173 | 174 | case 4: 175 | if (ch == '1') state = 5; 176 | else if (isDialable(ch)) return -1; 177 | break; 178 | 179 | case 1: 180 | case 3: 181 | case 5: 182 | case 6: 183 | case 7: 184 | { 185 | int ret = tryGetISODigit(ch); 186 | if (ret > 0) { 187 | ccc = ccc * 10 + ret; 188 | if (ccc >= 100 || isCountryCallingCode(ccc)) { 189 | if (new_ptr != NULL) { 190 | *new_ptr = str + i + 1; 191 | } 192 | if (new_len != NULL) { 193 | *new_len = len - (i + 1); 194 | } 195 | return ccc; 196 | } 197 | if (state == 1 || state == 3 || state == 5) { 198 | state = 6; 199 | } else { 200 | state++; 201 | } 202 | } else if (isDialable(ch)) { 203 | return -1; 204 | } 205 | } 206 | break; 207 | case 8: 208 | if (ch == '6') state = 9; 209 | else if (isDialable(ch)) return -1; 210 | break; 211 | case 9: 212 | if (ch == '6') { 213 | if (new_ptr != NULL) { 214 | *new_ptr = str + i + 1; 215 | } 216 | if (new_len != NULL) { 217 | *new_len = len - (i + 1); 218 | } 219 | return 66; 220 | } else { 221 | return -1; 222 | } 223 | break; 224 | default: 225 | return -1; 226 | } 227 | } 228 | 229 | return -1; 230 | } 231 | 232 | /** 233 | * Return true if the prefix of "ch" is "ignorable". Here, "ignorable" means 234 | * that "ch" has only one digit and separater characters. The one digit is 235 | * assumed to be trunk prefix. 236 | */ 237 | static bool checkPrefixIsIgnorable(const char* ch, int i) { 238 | bool trunk_prefix_was_read = false; 239 | while (i >= 0) { 240 | if (tryGetISODigit(ch[i]) >= 0) { 241 | if (trunk_prefix_was_read) { 242 | // More than one digit appeared, meaning that "a" and "b" 243 | // is different. 244 | return false; 245 | } else { 246 | // Ignore just one digit, assuming it is trunk prefix. 247 | trunk_prefix_was_read = true; 248 | } 249 | } else if (isDialable(ch[i])) { 250 | // Trunk prefix is a digit, not "*", "#"... 251 | return false; 252 | } 253 | i--; 254 | } 255 | 256 | return true; 257 | } 258 | 259 | /** 260 | * Compare phone numbers a and b, return true if they're identical 261 | * enough for caller ID purposes. 262 | * 263 | * Assume NULL as 0-length string. 264 | * 265 | * Detailed information: 266 | * Currently (as of 2009-06-12), we cannot depend on the locale given from the 267 | * OS. For example, current Android does not accept "en_JP", meaning 268 | * "the display language is English but the phone should be in Japan", but 269 | * en_US, es_US, etc. So we cannot identify which digit is valid trunk prefix 270 | * in the country where the phone is used. More specifically, "880-1234-1234" 271 | * is not valid phone number in Japan since the trunk prefix in Japan is not 8 272 | * but 0 (correct number should be "080-1234-1234"), while Russian trunk prefix 273 | * is 8. Also, we cannot know whether the country where users live has trunk 274 | * prefix itself. So, we cannot determine whether "+81-80-1234-1234" is NOT 275 | * same as "880-1234-1234" (while "+81-80-1234-1234" is same as "080-1234-1234" 276 | * and we can determine "880-1234-1234" is different from "080-1234-1234"). 277 | * 278 | * In the future, we should handle trunk prefix more correctly, but as of now, 279 | * we just ignore it... 280 | */ 281 | static bool phone_number_compare_inter(const char* const org_a, const char* const org_b, 282 | bool accept_thailand_case) 283 | { 284 | const char* a = org_a; 285 | const char* b = org_b; 286 | size_t len_a = 0; 287 | size_t len_b = 0; 288 | if (a == NULL) { 289 | a = ""; 290 | } else { 291 | len_a = strlen(a); 292 | } 293 | if (b == NULL) { 294 | b = ""; 295 | } else { 296 | len_b = strlen(b); 297 | } 298 | 299 | const char* tmp_a = NULL; 300 | const char* tmp_b = NULL; 301 | size_t tmp_len_a = len_a; 302 | size_t tmp_len_b = len_b; 303 | 304 | int ccc_a = tryGetCountryCallingCode(a, len_a, &tmp_a, &tmp_len_a, accept_thailand_case); 305 | int ccc_b = tryGetCountryCallingCode(b, len_b, &tmp_b, &tmp_len_b, accept_thailand_case); 306 | bool both_have_ccc = false; 307 | bool ok_to_ignore_prefix = true; 308 | bool trunk_prefix_is_omitted_a = false; 309 | bool trunk_prefix_is_omitted_b = false; 310 | if (ccc_a >= 0 && ccc_b >= 0) { 311 | if (ccc_a != ccc_b) { 312 | // Different Country Calling Code. Must be different phone number. 313 | return false; 314 | } 315 | // When both have ccc, do not ignore trunk prefix. Without this, 316 | // "+81123123" becomes same as "+810123123" (+81 == Japan) 317 | ok_to_ignore_prefix = false; 318 | both_have_ccc = true; 319 | } else if (ccc_a < 0 && ccc_b < 0) { 320 | // When both do not have ccc, do not ignore trunk prefix. Without this, 321 | // "123123" becomes same as "0123123" 322 | ok_to_ignore_prefix = false; 323 | } else { 324 | if (ccc_a < 0) { 325 | tryGetTrunkPrefixOmittedStr(a, len_a, &tmp_a, &tmp_len_a); 326 | trunk_prefix_is_omitted_a = true; 327 | } 328 | if (ccc_b < 0) { 329 | tryGetTrunkPrefixOmittedStr(b, len_b, &tmp_b, &tmp_len_b); 330 | trunk_prefix_is_omitted_b = true; 331 | } 332 | } 333 | 334 | if (tmp_a != NULL) { 335 | a = tmp_a; 336 | len_a = tmp_len_a; 337 | } 338 | if (tmp_b != NULL) { 339 | b = tmp_b; 340 | len_b = tmp_len_b; 341 | } 342 | 343 | int i_a = len_a - 1; 344 | int i_b = len_b - 1; 345 | while (i_a >= 0 && i_b >= 0) { 346 | bool skip_compare = false; 347 | char ch_a = a[i_a]; 348 | char ch_b = b[i_b]; 349 | if (isSeparator(ch_a)) { 350 | i_a--; 351 | skip_compare = true; 352 | } 353 | if (isSeparator(ch_b)) { 354 | i_b--; 355 | skip_compare = true; 356 | } 357 | 358 | if (!skip_compare) { 359 | if (ch_a != ch_b) { 360 | return false; 361 | } 362 | i_a--; 363 | i_b--; 364 | } 365 | } 366 | 367 | if (ok_to_ignore_prefix) { 368 | if ((trunk_prefix_is_omitted_a && i_a >= 0) || 369 | !checkPrefixIsIgnorable(a, i_a)) { 370 | if (accept_thailand_case) { 371 | // Maybe the code handling the special case for Thailand makes the 372 | // result garbled, so disable the code and try again. 373 | // e.g. "16610001234" must equal to "6610001234", but with 374 | // Thailand-case handling code, they become equal to each other. 375 | // 376 | // Note: we select simplicity rather than adding some complicated 377 | // logic here for performance(like "checking whether remaining 378 | // numbers are just 66 or not"), assuming inputs are small 379 | // enough. 380 | return phone_number_compare_inter(org_a, org_b, false); 381 | } else { 382 | return false; 383 | } 384 | } 385 | if ((trunk_prefix_is_omitted_b && i_b >= 0) || 386 | !checkPrefixIsIgnorable(b, i_b)) { 387 | if (accept_thailand_case) { 388 | return phone_number_compare_inter(org_a, org_b, false); 389 | } else { 390 | return false; 391 | } 392 | } 393 | } else { 394 | // In the US, 1-650-555-1234 must be equal to 650-555-1234, 395 | // while 090-1234-1234 must not be equalt to 90-1234-1234 in Japan. 396 | // This request exists just in US (with 1 trunk (NDD) prefix). 397 | // In addition, "011 11 7005554141" must not equal to "+17005554141", 398 | // while "011 1 7005554141" must equal to "+17005554141" 399 | // 400 | // In this comparison, we ignore the prefix '1' just once, when 401 | // - at least either does not have CCC, or 402 | // - the remaining non-separator number is 1 403 | bool may_be_namp = !both_have_ccc; 404 | while (i_a >= 0) { 405 | const char ch_a = a[i_a]; 406 | if (isDialable(ch_a)) { 407 | if (may_be_namp && tryGetISODigit(ch_a) == 1) { 408 | may_be_namp = false; 409 | } else { 410 | return false; 411 | } 412 | } 413 | i_a--; 414 | } 415 | while (i_b >= 0) { 416 | const char ch_b = b[i_b]; 417 | if (isDialable(ch_b)) { 418 | if (may_be_namp && tryGetISODigit(ch_b) == 1) { 419 | may_be_namp = false; 420 | } else { 421 | return false; 422 | } 423 | } 424 | i_b--; 425 | } 426 | } 427 | 428 | return true; 429 | } 430 | 431 | bool phone_number_compare_strict(const char* a, const char* b) 432 | { 433 | return phone_number_compare_inter(a, b, true); 434 | } 435 | 436 | /** 437 | * Imitates the Java method PhoneNumberUtils.getStrippedReversed. 438 | * Used for API compatibility with Android 1.6 and earlier. 439 | */ 440 | bool phone_number_stripped_reversed_inter(const char* in, char* out, const int len, int *outlen) { 441 | int in_len = strlen(in); 442 | int out_len = 0; 443 | bool have_seen_plus = false; 444 | for (int i = in_len; --i >= 0;) { 445 | char c = in[i]; 446 | if ((c >= '0' && c <= '9') || c == '*' || c == '#' || c == 'N') { 447 | if (out_len < len) { 448 | out[out_len++] = c; 449 | } 450 | } else { 451 | switch (c) { 452 | case '+': 453 | if (!have_seen_plus) { 454 | if (out_len < len) { 455 | out[out_len++] = c; 456 | } 457 | have_seen_plus = true; 458 | } 459 | break; 460 | case ',': 461 | case ';': 462 | out_len = 0; 463 | break; 464 | } 465 | } 466 | } 467 | 468 | *outlen = out_len; 469 | return true; 470 | } 471 | 472 | } // namespace android 473 | -------------------------------------------------------------------------------- /android/PhoneNumberUtils.h: -------------------------------------------------------------------------------- 1 | /* //device/libs/android_runtime/PhoneNumberUtils.h 2 | ** 3 | ** Copyright 2006, The Android Open Source Project 4 | ** 5 | ** Licensed under the Apache License, Version 2.0 (the "License"); 6 | ** you may not use this file except in compliance with the License. 7 | ** You may obtain a copy of the License at 8 | ** 9 | ** http://www.apache.org/licenses/LICENSE-2.0 10 | ** 11 | ** Unless required by applicable law or agreed to in writing, software 12 | ** distributed under the License is distributed on an "AS IS" BASIS, 13 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | ** See the License for the specific language governing permissions and 15 | ** limitations under the License. 16 | */ 17 | 18 | #ifndef _ANDROID_PHONE_NUMBER_UTILS_H 19 | #define _ANDROID_PHONE_NUMBER_UTILS_H 20 | 21 | namespace android { 22 | 23 | bool phone_number_compare_loose(const char* a, const char* b); 24 | bool phone_number_compare_strict(const char* a, const char* b); 25 | bool phone_number_stripped_reversed_inter(const char* in, char* out, const int len, int *outlen); 26 | 27 | } // namespace android 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /android/PhoneNumberUtilsTest.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | /* 17 | * Note that similar (or almost same) tests exist in Java side (See 18 | * DatabaseGeneralTest.java in AndroidTests). The differences are: 19 | * - this test is quite easy to do (You can do it in your Unix PC) 20 | * - this test is not automatically executed by build servers 21 | * 22 | * You should also execute the test before submitting this. 23 | */ 24 | 25 | #include "PhoneNumberUtils.h" 26 | 27 | #include 28 | #include 29 | 30 | using namespace android; 31 | 32 | #define PHONE_NUMBER_BUFFER_SIZE 6 33 | 34 | #define EXPECT(function, input1, input2, expected, total, error) \ 35 | ({ \ 36 | const char *i1_cache = input1; \ 37 | const char *i2_cache = input2; \ 38 | (total)++; \ 39 | if ((expected) != (function)((i1_cache), (i2_cache))) { \ 40 | if (expected) { \ 41 | printf("%s != %s while we expect %s == %s\n", \ 42 | (i1_cache), (i2_cache), (i1_cache), (i2_cache)); \ 43 | } else { \ 44 | printf("%s == %s while we expect %s != %s\n", \ 45 | (i1_cache), (i2_cache), (i1_cache), (i2_cache)); \ 46 | } \ 47 | (error)++; \ 48 | } \ 49 | }) 50 | 51 | #define EXPECT_EQ(input1, input2) \ 52 | EXPECT(phone_number_compare_strict, (input1), (input2), true, \ 53 | (total), (error)) 54 | 55 | 56 | #define EXPECT_NE(input1, input2) \ 57 | EXPECT(phone_number_compare_strict, (input1), (input2), false, \ 58 | (total), (error)) 59 | 60 | #define ASSERT_STRIPPED_REVERSE(input, expected) \ 61 | ({ \ 62 | char out[PHONE_NUMBER_BUFFER_SIZE]; \ 63 | int outlen; \ 64 | (total)++; \ 65 | phone_number_stripped_reversed_inter((input), \ 66 | out, \ 67 | PHONE_NUMBER_BUFFER_SIZE, \ 68 | &outlen); \ 69 | out[outlen] = 0; \ 70 | if (strcmp((expected), (out)) != 0) { \ 71 | printf("Expected: %s actual: %s\n", (expected), (out)); \ 72 | (error)++; \ 73 | } \ 74 | }) 75 | 76 | int main() { 77 | int total = 0; 78 | int error = 0; 79 | 80 | EXPECT_EQ(NULL, NULL); 81 | EXPECT_EQ("", NULL); 82 | EXPECT_EQ(NULL, ""); 83 | EXPECT_EQ("", ""); 84 | 85 | EXPECT_EQ("999", "999"); 86 | EXPECT_EQ("119", "119"); 87 | 88 | EXPECT_NE("123456789", "923456789"); 89 | EXPECT_NE("123456789", "123456781"); 90 | EXPECT_NE("123456789", "1234567890"); 91 | EXPECT_NE("123456789", "0123456789"); 92 | 93 | // Google, Inc. 94 | EXPECT_EQ("650-253-0000", "6502530000"); 95 | EXPECT_EQ("650-253-0000", "650 253 0000"); 96 | EXPECT_EQ("650 253 0000", "6502530000"); 97 | 98 | // trunk (NDD) prefix must be properly handled in US 99 | EXPECT_EQ("650-253-0000", "1-650-253-0000"); 100 | EXPECT_EQ("650-253-0000", " 1-650-253-0000"); 101 | EXPECT_NE("650-253-0000", "11-650-253-0000"); 102 | EXPECT_NE("650-253-0000", "0-650-253-0000"); 103 | EXPECT_NE("555-4141", "+1-700-555-4141"); 104 | 105 | EXPECT_EQ("+1 650-253-0000", "6502530000"); 106 | EXPECT_EQ("001 650-253-0000", "6502530000"); 107 | EXPECT_EQ("0111 650-253-0000", "6502530000"); 108 | 109 | // Country code is different. 110 | EXPECT_NE("+19012345678", "+819012345678"); 111 | 112 | // Russian trunk digit 113 | EXPECT_EQ("+79161234567", "89161234567"); 114 | 115 | // French trunk digit 116 | EXPECT_EQ("+33123456789", "0123456789"); 117 | 118 | // Trunk digit for city codes in the Netherlands 119 | EXPECT_EQ("+31771234567", "0771234567"); 120 | 121 | // Japanese dial 122 | EXPECT_EQ("090-1234-5678", "+819012345678"); 123 | EXPECT_EQ("090(1234)5678", "+819012345678"); 124 | EXPECT_EQ("090-1234-5678", "+81-90-1234-5678"); 125 | 126 | // Trunk prefix must not be ignored in Japan 127 | EXPECT_NE("090-1234-5678", "90-1234-5678"); 128 | 129 | EXPECT_NE("090-1234-5678", "080-1234-5678"); 130 | EXPECT_NE("090-1234-5678", "190-1234-5678"); 131 | EXPECT_NE("090-1234-5678", "890-1234-5678"); 132 | EXPECT_NE("+81-90-1234-5678", "+81-090-1234-5678"); 133 | 134 | EXPECT_EQ("+593(800)123-1234", "8001231234"); 135 | 136 | // Two continuous 0 at the beginieng of the phone string should not be 137 | // treated as trunk prefix. 138 | EXPECT_NE("008001231234", "8001231234"); 139 | 140 | // Test broken caller ID seen on call from Thailand to the US 141 | EXPECT_EQ("+66811234567", "166811234567"); 142 | 143 | // Confirm that the bug found before does not re-appear. 144 | EXPECT_NE("080-1234-5678", "+819012345678"); 145 | EXPECT_EQ("650-000-3456", "16500003456"); 146 | EXPECT_EQ("011 1 7005554141", "+17005554141"); 147 | EXPECT_NE("011 11 7005554141", "+17005554141"); 148 | EXPECT_NE("+44 207 792 3490", "00 207 792 3490"); 149 | // This is not related to Thailand case. NAMP "1" + region code "661". 150 | EXPECT_EQ("16610001234", "6610001234"); 151 | 152 | // We also need to compare two alpha addresses to make sure two different strings 153 | // aren't treated as the same addresses. This is relevant to SMS as SMS sender may 154 | // contain all alpha chars. 155 | EXPECT_NE("abcd", "bcde"); 156 | 157 | // in the U.S. people often use alpha in the phone number to easily remember it 158 | // (e.g. 800-flowers would be dialed as 800-356-9377). Since we accept this form of 159 | // phone number in Contacts and others, we should make sure the comparison method 160 | // handle them. 161 | EXPECT_EQ("1-800-flowers", "800-flowers"); 162 | 163 | // TODO: we currently do not support this comparison. It maybe nice to support this 164 | // TODO: in the future. 165 | // EXPECT_EQ("1-800-flowers", "1-800-356-9377") 166 | 167 | EXPECT_NE("1-800-flowers", "1-800-abcdefg"); 168 | 169 | // Currently we cannot get this test through (Japanese trunk prefix is 0, 170 | // but there is no sensible way to know it now (as of 2009-6-12)... 171 | // EXPECT_NE("290-1234-5678", "+819012345678"); 172 | 173 | ASSERT_STRIPPED_REVERSE("", ""); 174 | ASSERT_STRIPPED_REVERSE("123", "321"); 175 | ASSERT_STRIPPED_REVERSE("123*N#", "#N*321"); 176 | 177 | // Buffer overflow 178 | ASSERT_STRIPPED_REVERSE("1234567890", "098765"); 179 | 180 | // Only one plus is copied 181 | ASSERT_STRIPPED_REVERSE("1+2+", "+21"); 182 | 183 | // Pause/wait in the phone number 184 | ASSERT_STRIPPED_REVERSE("12;34", "21"); 185 | 186 | // Ignoring non-dialable 187 | ASSERT_STRIPPED_REVERSE("1A2 3?4", "4321"); 188 | 189 | printf("total: %d, error: %d\n\n", total, error); 190 | if (error == 0) { 191 | printf("Success!\n"); 192 | } else { 193 | printf("Failure... :(\n"); 194 | } 195 | } 196 | -------------------------------------------------------------------------------- /android/sqlite3_android.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #define LOG_TAG "sqlite3_android" 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #include "sqlite3_android.h" 31 | #include "PhoneNumberUtils.h" 32 | 33 | #define ENABLE_ANDROID_LOG 0 34 | #define SMALL_BUFFER_SIZE 10 35 | #define PHONE_NUMBER_BUFFER_SIZE 40 36 | 37 | static int collate16(void *p, int n1, const void *v1, int n2, const void *v2) 38 | { 39 | UCollator *coll = (UCollator *) p; 40 | UCollationResult result = ucol_strcoll(coll, (const UChar *) v1, n1, 41 | (const UChar *) v2, n2); 42 | 43 | if (result == UCOL_LESS) { 44 | return -1; 45 | } else if (result == UCOL_GREATER) { 46 | return 1; 47 | } else { 48 | return 0; 49 | } 50 | } 51 | 52 | static int collate8(void *p, int n1, const void *v1, int n2, const void *v2) 53 | { 54 | UCollator *coll = (UCollator *) p; 55 | UCharIterator i1, i2; 56 | UErrorCode status = U_ZERO_ERROR; 57 | 58 | uiter_setUTF8(&i1, (const char *) v1, n1); 59 | uiter_setUTF8(&i2, (const char *) v2, n2); 60 | 61 | UCollationResult result = ucol_strcollIter(coll, &i1, &i2, &status); 62 | 63 | if (U_FAILURE(status)) { 64 | // ALOGE("Collation iterator error: %d\n", status); 65 | } 66 | 67 | if (result == UCOL_LESS) { 68 | return -1; 69 | } else if (result == UCOL_GREATER) { 70 | return 1; 71 | } else { 72 | return 0; 73 | } 74 | } 75 | 76 | static void phone_numbers_equal(sqlite3_context * context, int argc, sqlite3_value ** argv) 77 | { 78 | if (argc != 2 && argc != 3) { 79 | sqlite3_result_int(context, 0); 80 | return; 81 | } 82 | 83 | char const * num1 = (char const *)sqlite3_value_text(argv[0]); 84 | char const * num2 = (char const *)sqlite3_value_text(argv[1]); 85 | 86 | bool use_strict = false; 87 | if (argc == 3) { 88 | use_strict = (sqlite3_value_int(argv[2]) != 0); 89 | } 90 | 91 | if (num1 == NULL || num2 == NULL) { 92 | sqlite3_result_null(context); 93 | return; 94 | } 95 | 96 | bool equal = 97 | (use_strict ? 98 | android::phone_number_compare_strict(num1, num2) : 99 | android::phone_number_compare_loose(num1, num2)); 100 | 101 | if (equal) { 102 | sqlite3_result_int(context, 1); 103 | } else { 104 | sqlite3_result_int(context, 0); 105 | } 106 | } 107 | 108 | static void phone_number_stripped_reversed(sqlite3_context * context, int argc, 109 | sqlite3_value ** argv) 110 | { 111 | if (argc != 1) { 112 | sqlite3_result_int(context, 0); 113 | return; 114 | } 115 | 116 | char const * number = (char const *)sqlite3_value_text(argv[0]); 117 | if (number == NULL) { 118 | sqlite3_result_null(context); 119 | return; 120 | } 121 | 122 | char out[PHONE_NUMBER_BUFFER_SIZE]; 123 | int outlen = 0; 124 | android::phone_number_stripped_reversed_inter(number, out, PHONE_NUMBER_BUFFER_SIZE, &outlen); 125 | sqlite3_result_text(context, (const char*)out, outlen, SQLITE_TRANSIENT); 126 | } 127 | 128 | 129 | #if ENABLE_ANDROID_LOG 130 | static void android_log(sqlite3_context * context, int argc, sqlite3_value ** argv) 131 | { 132 | char const * tag = "sqlite_trigger"; 133 | char const * msg = ""; 134 | int msgIndex = 0; 135 | 136 | switch (argc) { 137 | case 2: 138 | tag = (char const *)sqlite3_value_text(argv[0]); 139 | if (tag == NULL) { 140 | tag = "sqlite_trigger"; 141 | } 142 | msgIndex = 1; 143 | case 1: 144 | msg = (char const *)sqlite3_value_text(argv[msgIndex]); 145 | if (msg == NULL) { 146 | msg = ""; 147 | } 148 | ALOG(LOG_INFO, tag, "%s", msg); 149 | sqlite3_result_int(context, 1); 150 | return; 151 | 152 | default: 153 | sqlite3_result_int(context, 0); 154 | return; 155 | } 156 | } 157 | #endif 158 | 159 | static void delete_file(sqlite3_context * context, int argc, sqlite3_value ** argv) 160 | { 161 | if (argc != 1) { 162 | sqlite3_result_int(context, 0); 163 | return; 164 | } 165 | 166 | char const * path = (char const *)sqlite3_value_text(argv[0]); 167 | // Don't allow ".." in paths 168 | if (path == NULL || strstr(path, "/../") != NULL) { 169 | sqlite3_result_null(context); 170 | return; 171 | } 172 | 173 | // We only allow deleting files in the EXTERNAL_STORAGE path, or one of the 174 | // SECONDARY_STORAGE paths 175 | bool good_path = false; 176 | char const * external_storage = getenv("EXTERNAL_STORAGE"); 177 | if (external_storage && strncmp(external_storage, path, strlen(external_storage)) == 0) { 178 | good_path = true; 179 | } else { 180 | // check SECONDARY_STORAGE, which should be a colon separated list of paths 181 | char const * secondary_paths = getenv("SECONDARY_STORAGE"); 182 | while (secondary_paths && secondary_paths[0]) { 183 | const char* colon = strchr(secondary_paths, ':'); 184 | int length = (colon ? colon - secondary_paths : strlen(secondary_paths)); 185 | if (strncmp(secondary_paths, path, length) == 0) { 186 | good_path = true; 187 | } 188 | secondary_paths += length; 189 | while (*secondary_paths == ':') secondary_paths++; 190 | } 191 | } 192 | 193 | if (!good_path) { 194 | sqlite3_result_null(context); 195 | return; 196 | } 197 | 198 | int err = unlink(path); 199 | if (err != -1) { 200 | // No error occured, return true 201 | sqlite3_result_int(context, 1); 202 | } else { 203 | // An error occured, return false 204 | sqlite3_result_int(context, 0); 205 | } 206 | } 207 | 208 | static void tokenize_auxdata_delete(void * data) 209 | { 210 | sqlite3_stmt * statement = (sqlite3_stmt *)data; 211 | sqlite3_finalize(statement); 212 | } 213 | 214 | static void base16Encode(char* dest, const char* src, uint32_t size) 215 | { 216 | static const char * BASE16_TABLE = "0123456789abcdef"; 217 | for (uint32_t i = 0; i < size; i++) { 218 | char ch = *src++; 219 | *dest++ = BASE16_TABLE[ (ch & 0xf0) >> 4 ]; 220 | *dest++ = BASE16_TABLE[ (ch & 0x0f) ]; 221 | } 222 | } 223 | 224 | struct SqliteUserData { 225 | sqlite3 * handle; 226 | UCollator* collator; 227 | }; 228 | 229 | /** 230 | * This function is invoked as: 231 | * 232 | * _TOKENIZE('', , , , 233 | * , ) 234 | * 235 | * If is omitted, it is treated as 0. 236 | * If is omitted, it is treated as NULL. 237 | * 238 | * It will split on each instance of and insert each token 239 | * into . The following columns in are used: 240 | * token TEXT, source INTEGER, token_index INTEGER, tag (any type) 241 | * The token_index column is not required if is 0. 242 | * The tag column is not required if is NULL. 243 | * 244 | * One row is inserted for each token in . 245 | * In each inserted row, 'source' is . 246 | * In the first inserted row, 'token' is the hex collation key of 247 | * the entire string, and 'token_index' is 0. 248 | * In each row I (where 1 <= I < N, and N is the number of tokens in ) 249 | * 'token' will be set to the hex collation key of the I:th token (0-based). 250 | * If != 0, 'token_index' is set to I. 251 | * If is not NULL, 'tag' is set to . 252 | * 253 | * In other words, there will be one row for the entire string, 254 | * and one row for each token except the first one. 255 | * 256 | * The function returns the number of tokens generated. 257 | */ 258 | static void tokenize(sqlite3_context * context, int argc, sqlite3_value ** argv) 259 | { 260 | //ALOGD("enter tokenize"); 261 | int err; 262 | int useTokenIndex = 0; 263 | int useDataTag = 0; 264 | 265 | if (!(argc >= 4 || argc <= 6)) { 266 | ALOGE("Tokenize requires 4 to 6 arguments"); 267 | sqlite3_result_null(context); 268 | return; 269 | } 270 | 271 | if (argc > 4) { 272 | useTokenIndex = sqlite3_value_int(argv[4]); 273 | } 274 | 275 | if (argc > 5) { 276 | useDataTag = (sqlite3_value_type(argv[5]) != SQLITE_NULL); 277 | } 278 | 279 | sqlite3 * handle = sqlite3_context_db_handle(context); 280 | UCollator* collator = (UCollator*)sqlite3_user_data(context); 281 | char const * tokenTable = (char const *)sqlite3_value_text(argv[0]); 282 | if (tokenTable == NULL) { 283 | ALOGE("tokenTable null"); 284 | sqlite3_result_null(context); 285 | return; 286 | } 287 | 288 | // Get or create the prepared statement for the insertions 289 | sqlite3_stmt * statement = (sqlite3_stmt *)sqlite3_get_auxdata(context, 0); 290 | if (!statement) { 291 | char const * tokenIndexCol = useTokenIndex ? ", token_index" : ""; 292 | char const * tokenIndexParam = useTokenIndex ? ", ?" : ""; 293 | char const * dataTagCol = useDataTag ? ", tag" : ""; 294 | char const * dataTagParam = useDataTag ? ", ?" : ""; 295 | char * sql = sqlite3_mprintf("INSERT INTO %s (token, source%s%s) VALUES (?, ?%s%s);", 296 | tokenTable, tokenIndexCol, dataTagCol, tokenIndexParam, dataTagParam); 297 | err = sqlite3_prepare_v2(handle, sql, -1, &statement, NULL); 298 | sqlite3_free(sql); 299 | if (err) { 300 | ALOGE("prepare failed"); 301 | sqlite3_result_null(context); 302 | return; 303 | } 304 | // This binds the statement to the table it was compiled against, which is argv[0]. 305 | // If this function is ever called with a different table the finalizer will be called 306 | // and sqlite3_get_auxdata() will return null above, forcing a recompile for the new table. 307 | sqlite3_set_auxdata(context, 0, statement, tokenize_auxdata_delete); 308 | } else { 309 | // Reset the cached statement so that binding the row ID will work properly 310 | sqlite3_reset(statement); 311 | } 312 | 313 | // Bind the row ID of the source row 314 | int64_t rowID = sqlite3_value_int64(argv[1]); 315 | err = sqlite3_bind_int64(statement, 2, rowID); 316 | if (err != SQLITE_OK) { 317 | ALOGE("bind failed"); 318 | sqlite3_result_null(context); 319 | return; 320 | } 321 | 322 | // Bind to the tag column 323 | if (useDataTag) { 324 | int dataTagParamIndex = useTokenIndex ? 4 : 3; 325 | err = sqlite3_bind_value(statement, dataTagParamIndex, argv[5]); 326 | if (err != SQLITE_OK) { 327 | ALOGE("bind failed"); 328 | sqlite3_result_null(context); 329 | return; 330 | } 331 | } 332 | 333 | // Get the raw bytes for the string to tokenize 334 | // the string will be modified by following code 335 | // however, sqlite did not reuse the string, so it is safe to not dup it 336 | UChar * origData = (UChar *)sqlite3_value_text16(argv[2]); 337 | if (origData == NULL) { 338 | sqlite3_result_null(context); 339 | return; 340 | } 341 | 342 | // Get the raw bytes for the delimiter 343 | const UChar * delim = (const UChar *)sqlite3_value_text16(argv[3]); 344 | if (delim == NULL) { 345 | ALOGE("can't get delimiter"); 346 | sqlite3_result_null(context); 347 | return; 348 | } 349 | 350 | UChar * token = NULL; 351 | UChar *state; 352 | int numTokens = 0; 353 | 354 | do { 355 | if (numTokens == 0) { 356 | token = origData; 357 | } 358 | 359 | // Reset the program so we can use it to perform the insert 360 | sqlite3_reset(statement); 361 | UErrorCode status = U_ZERO_ERROR; 362 | char keybuf[1024]; 363 | uint32_t result = ucol_getSortKey(collator, token, -1, (uint8_t*)keybuf, sizeof(keybuf)-1); 364 | if (result > sizeof(keybuf)) { 365 | // TODO allocate memory for this super big string 366 | ALOGE("ucol_getSortKey needs bigger buffer %d", result); 367 | break; 368 | } 369 | uint32_t keysize = result-1; 370 | uint32_t base16Size = keysize*2; 371 | char *base16buf = (char*)malloc(base16Size); 372 | base16Encode(base16buf, keybuf, keysize); 373 | err = sqlite3_bind_text(statement, 1, base16buf, base16Size, SQLITE_STATIC); 374 | 375 | if (err != SQLITE_OK) { 376 | ALOGE(" sqlite3_bind_text16 error %d", err); 377 | free(base16buf); 378 | break; 379 | } 380 | 381 | if (useTokenIndex) { 382 | err = sqlite3_bind_int(statement, 3, numTokens); 383 | if (err != SQLITE_OK) { 384 | ALOGE(" sqlite3_bind_int error %d", err); 385 | free(base16buf); 386 | break; 387 | } 388 | } 389 | 390 | err = sqlite3_step(statement); 391 | free(base16buf); 392 | 393 | if (err != SQLITE_DONE) { 394 | ALOGE(" sqlite3_step error %d", err); 395 | break; 396 | } 397 | numTokens++; 398 | if (numTokens == 1) { 399 | // first call 400 | u_strtok_r(origData, delim, &state); 401 | } 402 | } while ((token = u_strtok_r(NULL, delim, &state)) != NULL); 403 | sqlite3_result_int(context, numTokens); 404 | } 405 | 406 | static void localized_collator_dtor(UCollator* collator) 407 | { 408 | ucol_close(collator); 409 | } 410 | 411 | #define LOCALIZED_COLLATOR_NAME "LOCALIZED" 412 | 413 | // This collator may be removed in the near future, so you MUST not use now. 414 | #define PHONEBOOK_COLLATOR_NAME "PHONEBOOK" 415 | 416 | extern "C" int register_localized_collators(sqlite3* handle, const char* systemLocale, int utf16Storage) 417 | { 418 | int err; 419 | UErrorCode status = U_ZERO_ERROR; 420 | void* icudata; 421 | 422 | UCollator* collator = ucol_open(systemLocale, &status); 423 | if (U_FAILURE(status)) { 424 | return -1; 425 | } 426 | 427 | ucol_setAttribute(collator, UCOL_STRENGTH, UCOL_PRIMARY, &status); 428 | if (U_FAILURE(status)) { 429 | return -1; 430 | } 431 | 432 | status = U_ZERO_ERROR; 433 | char buf[1024]; 434 | ucol_getShortDefinitionString(collator, NULL, buf, 1024, &status); 435 | 436 | if (utf16Storage) { 437 | err = sqlite3_create_collation_v2(handle, LOCALIZED_COLLATOR_NAME, SQLITE_UTF16, collator, 438 | collate16, (void(*)(void*))localized_collator_dtor); 439 | } else { 440 | err = sqlite3_create_collation_v2(handle, LOCALIZED_COLLATOR_NAME, SQLITE_UTF8, collator, 441 | collate8, (void(*)(void*))localized_collator_dtor); 442 | } 443 | 444 | if (err != SQLITE_OK) { 445 | return err; 446 | } 447 | 448 | // Register the _TOKENIZE function 449 | err = sqlite3_create_function(handle, "_TOKENIZE", 4, SQLITE_UTF16, collator, tokenize, NULL, NULL); 450 | if (err != SQLITE_OK) { 451 | return err; 452 | } 453 | err = sqlite3_create_function(handle, "_TOKENIZE", 5, SQLITE_UTF16, collator, tokenize, NULL, NULL); 454 | if (err != SQLITE_OK) { 455 | return err; 456 | } 457 | err = sqlite3_create_function(handle, "_TOKENIZE", 6, SQLITE_UTF16, collator, tokenize, NULL, NULL); 458 | if (err != SQLITE_OK) { 459 | return err; 460 | } 461 | 462 | 463 | //// PHONEBOOK_COLLATOR 464 | status = U_ZERO_ERROR; 465 | collator = ucol_open(systemLocale, &status); 466 | if (U_FAILURE(status)) { 467 | return -1; 468 | } 469 | 470 | status = U_ZERO_ERROR; 471 | ucol_setAttribute(collator, UCOL_STRENGTH, UCOL_PRIMARY, &status); 472 | if (U_FAILURE(status)) { 473 | return -1; 474 | } 475 | 476 | status = U_ZERO_ERROR; 477 | // ucol_getShortDefinitionString(collator, NULL, buf, 1024, &status); 478 | if (utf16Storage) { 479 | err = sqlite3_create_collation_v2(handle, PHONEBOOK_COLLATOR_NAME, SQLITE_UTF16, collator, 480 | collate16, (void(*)(void*))localized_collator_dtor); 481 | } else { 482 | err = sqlite3_create_collation_v2(handle, PHONEBOOK_COLLATOR_NAME, SQLITE_UTF8, collator, 483 | collate8, (void(*)(void*))localized_collator_dtor); 484 | } 485 | 486 | if (err != SQLITE_OK) { 487 | return err; 488 | } 489 | //// PHONEBOOK_COLLATOR 490 | 491 | return SQLITE_OK; 492 | } 493 | 494 | 495 | extern "C" int register_android_functions(sqlite3 * handle, int utf16Storage) 496 | { 497 | int err; 498 | UErrorCode status = U_ZERO_ERROR; 499 | 500 | UCollator * collator = ucol_open(NULL, &status); 501 | if (U_FAILURE(status)) { 502 | return -1; 503 | } 504 | 505 | if (utf16Storage) { 506 | // Note that text should be stored as UTF-16 507 | err = sqlite3_exec(handle, "PRAGMA encoding = 'UTF-16'", 0, 0, 0); 508 | if (err != SQLITE_OK) { 509 | return err; 510 | } 511 | 512 | // Register the UNICODE collation 513 | err = sqlite3_create_collation_v2(handle, "UNICODE", SQLITE_UTF16, collator, collate16, 514 | (void(*)(void*))localized_collator_dtor); 515 | } else { 516 | err = sqlite3_create_collation_v2(handle, "UNICODE", SQLITE_UTF8, collator, collate8, 517 | (void(*)(void*))localized_collator_dtor); 518 | } 519 | 520 | if (err != SQLITE_OK) { 521 | return err; 522 | } 523 | 524 | // Register the PHONE_NUM_EQUALS function 525 | err = sqlite3_create_function( 526 | handle, "PHONE_NUMBERS_EQUAL", 2, 527 | SQLITE_UTF8, NULL, phone_numbers_equal, NULL, NULL); 528 | if (err != SQLITE_OK) { 529 | return err; 530 | } 531 | 532 | // Register the PHONE_NUM_EQUALS function with an additional argument "use_strict" 533 | err = sqlite3_create_function( 534 | handle, "PHONE_NUMBERS_EQUAL", 3, 535 | SQLITE_UTF8, NULL, phone_numbers_equal, NULL, NULL); 536 | if (err != SQLITE_OK) { 537 | return err; 538 | } 539 | 540 | // Register the _DELETE_FILE function 541 | err = sqlite3_create_function(handle, "_DELETE_FILE", 1, SQLITE_UTF8, NULL, delete_file, NULL, NULL); 542 | if (err != SQLITE_OK) { 543 | return err; 544 | } 545 | 546 | #if ENABLE_ANDROID_LOG 547 | // Register the _LOG function 548 | err = sqlite3_create_function(handle, "_LOG", 1, SQLITE_UTF8, NULL, android_log, NULL, NULL); 549 | if (err != SQLITE_OK) { 550 | return err; 551 | } 552 | #endif 553 | 554 | // Register the _PHONE_NUMBER_STRIPPED_REVERSED function, which imitates 555 | // PhoneNumberUtils.getStrippedReversed. This function is not public API, 556 | // it is only used for compatibility with Android 1.6 and earlier. 557 | err = sqlite3_create_function(handle, 558 | "_PHONE_NUMBER_STRIPPED_REVERSED", 559 | 1, SQLITE_UTF8, NULL, 560 | phone_number_stripped_reversed, 561 | NULL, NULL); 562 | if (err != SQLITE_OK) { 563 | return err; 564 | } 565 | 566 | return SQLITE_OK; 567 | } 568 | -------------------------------------------------------------------------------- /android/sqlite3_android.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef SQLITE3_ANDROID_H 18 | #define SQLITE3_ANDROID_H 19 | 20 | #include 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | int register_android_functions(sqlite3 * handle, int uit16Storage); 27 | 28 | int register_localized_collators(sqlite3* handle, const char* systemLocale, int utf16Storage); 29 | 30 | #ifdef __cplusplus 31 | } // extern "C" 32 | #endif 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /dist/Android.mk: -------------------------------------------------------------------------------- 1 | ## 2 | ## 3 | ## Build the library 4 | ## 5 | ## 6 | 7 | LOCAL_PATH:= $(call my-dir) 8 | 9 | # NOTE the following flags, 10 | # SQLITE_TEMP_STORE=3 causes all TEMP files to go into RAM. and thats the behavior we want 11 | # SQLITE_ENABLE_FTS3 enables usage of FTS3 - NOT FTS1 or 2. 12 | # SQLITE_DEFAULT_AUTOVACUUM=1 causes the databases to be subject to auto-vacuum 13 | common_sqlite_flags := \ 14 | -DNDEBUG=1 \ 15 | -DHAVE_USLEEP=1 \ 16 | -DSQLITE_HAVE_ISNAN \ 17 | -DSQLITE_DEFAULT_JOURNAL_SIZE_LIMIT=1048576 \ 18 | -DSQLITE_THREADSAFE=2 \ 19 | -DSQLITE_TEMP_STORE=3 \ 20 | -DSQLITE_POWERSAFE_OVERWRITE=1 \ 21 | -DSQLITE_DEFAULT_FILE_FORMAT=4 \ 22 | -DSQLITE_DEFAULT_AUTOVACUUM=1 \ 23 | -DSQLITE_ENABLE_MEMORY_MANAGEMENT=1 \ 24 | -DSQLITE_ENABLE_FTS3 \ 25 | -DSQLITE_ENABLE_FTS3_BACKWARDS \ 26 | -DSQLITE_ENABLE_FTS4 \ 27 | -DSQLITE_OMIT_BUILTIN_TEST \ 28 | -DSQLITE_OMIT_COMPILEOPTION_DIAGS \ 29 | -DSQLITE_OMIT_LOAD_EXTENSION \ 30 | -DSQLITE_DEFAULT_FILE_PERMISSIONS=0600 31 | 32 | device_sqlite_flags := $(common_sqlite_flags) \ 33 | -DSQLITE_ENABLE_ICU \ 34 | -DUSE_PREAD64 \ 35 | -Dfdatasync=fdatasync \ 36 | -DHAVE_MALLOC_USABLE_SIZE 37 | 38 | host_sqlite_flags := $(common_sqlite_flags) 39 | 40 | common_src_files := sqlite3.c 41 | 42 | # the device library 43 | include $(CLEAR_VARS) 44 | 45 | LOCAL_SRC_FILES := $(common_src_files) 46 | 47 | LOCAL_CFLAGS += $(device_sqlite_flags) 48 | 49 | LOCAL_SHARED_LIBRARIES := libdl 50 | 51 | LOCAL_MODULE:= libsqlite 52 | 53 | LOCAL_C_INCLUDES += \ 54 | $(call include-path-for, system-core)/cutils \ 55 | external/icu/icu4c/source/i18n \ 56 | external/icu/icu4c/source/common 57 | 58 | LOCAL_SHARED_LIBRARIES += liblog \ 59 | libicuuc \ 60 | libicui18n \ 61 | libutils \ 62 | liblog 63 | 64 | # include android specific methods 65 | LOCAL_WHOLE_STATIC_LIBRARIES := libsqlite3_android 66 | 67 | include $(BUILD_SHARED_LIBRARY) 68 | 69 | 70 | include $(CLEAR_VARS) 71 | LOCAL_SRC_FILES := $(common_src_files) 72 | LOCAL_LDLIBS += -lpthread -ldl 73 | LOCAL_CFLAGS += $(host_sqlite_flags) 74 | LOCAL_MODULE:= libsqlite 75 | LOCAL_SHARED_LIBRARIES += libicuuc-host libicui18n-host 76 | LOCAL_STATIC_LIBRARIES := liblog libutils libcutils 77 | 78 | # include android specific methods 79 | LOCAL_WHOLE_STATIC_LIBRARIES := libsqlite3_android 80 | include $(BUILD_HOST_SHARED_LIBRARY) 81 | 82 | ## 83 | ## 84 | ## Build the device command line tool sqlite3 85 | ## 86 | ## 87 | ifneq ($(SDK_ONLY),true) # SDK doesn't need device version of sqlite3 88 | 89 | include $(CLEAR_VARS) 90 | 91 | LOCAL_SRC_FILES := shell.c 92 | 93 | LOCAL_C_INCLUDES := \ 94 | $(LOCAL_PATH)/../android \ 95 | $(call include-path-for, system-core)/cutils \ 96 | external/icu4c/i18n \ 97 | external/icu4c/common 98 | 99 | LOCAL_SHARED_LIBRARIES := libsqlite \ 100 | libicuuc \ 101 | libicui18n \ 102 | libutils 103 | 104 | LOCAL_CFLAGS += $(device_sqlite_flags) 105 | 106 | LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES) 107 | 108 | LOCAL_MODULE_TAGS := debug 109 | 110 | LOCAL_MODULE := sqlite3 111 | 112 | include $(BUILD_EXECUTABLE) 113 | 114 | endif # !SDK_ONLY 115 | 116 | 117 | ## 118 | ## 119 | ## Build the host command line tool sqlite3 120 | ## 121 | ## 122 | 123 | include $(CLEAR_VARS) 124 | 125 | LOCAL_SRC_FILES := $(common_src_files) shell.c 126 | 127 | LOCAL_CFLAGS += $(host_sqlite_flags) \ 128 | -DNO_ANDROID_FUNCS=1 129 | 130 | # sqlite3MemsysAlarm uses LOG() 131 | LOCAL_STATIC_LIBRARIES += liblog 132 | 133 | ifeq ($(strip $(USE_MINGW)),) 134 | LOCAL_LDLIBS += -lpthread 135 | ifneq ($(HOST_OS),freebsd) 136 | LOCAL_LDLIBS += -ldl 137 | endif 138 | endif 139 | 140 | LOCAL_MODULE := sqlite3 141 | 142 | include $(BUILD_HOST_EXECUTABLE) 143 | -------------------------------------------------------------------------------- /dist/Android.patch: -------------------------------------------------------------------------------- 1 | diff -r -u -d orig/shell.c ./shell.c 2 | --- orig/shell.c 2014-08-20 16:26:07.117256041 -0700 3 | +++ ./shell.c 2014-08-20 16:45:00.468546769 -0700 4 | @@ -35,6 +35,11 @@ 5 | #include "sqlite3.h" 6 | #include 7 | #include 8 | +// Begin Android Add 9 | +#ifndef NO_ANDROID_FUNCS 10 | +#include 11 | +#endif 12 | +// End Android Add 13 | 14 | #if !defined(_WIN32) && !defined(WIN32) 15 | # include 16 | @@ -1737,6 +1742,21 @@ 17 | readfileFunc, 0, 0); 18 | sqlite3_create_function(db, "writefile", 2, SQLITE_UTF8, 0, 19 | writefileFunc, 0, 0); 20 | + 21 | + // Begin Android Add 22 | + #ifndef NO_ANDROID_FUNCS 23 | + int err = register_localized_collators(db, "en_US", 0); 24 | + if (err != SQLITE_OK) { 25 | + fprintf(stderr, "register_localized_collators() failed\n"); 26 | + exit(1); 27 | + } 28 | + err = register_android_functions(db, 0); 29 | + if (err != SQLITE_OK) { 30 | + fprintf(stderr, "register_android_functions() failed\n"); 31 | + exit(1); 32 | + } 33 | + #endif 34 | + // End Android Add 35 | } 36 | } 37 | 38 | diff -r -u -d orig/sqlite3.c ./sqlite3.c 39 | --- orig/sqlite3.c 2014-08-20 16:26:07.145255923 -0700 40 | +++ ./sqlite3.c 2014-08-20 16:26:36.205134826 -0700 41 | @@ -24109,6 +24109,13 @@ 42 | */ 43 | #if SQLITE_OS_UNIX /* This file is used on unix only */ 44 | 45 | +/* Use posix_fallocate() if it is available 46 | +*/ 47 | +#if !defined(HAVE_POSIX_FALLOCATE) \ 48 | + && (_XOPEN_SOURCE >= 600 || _POSIX_C_SOURCE >= 200112L) 49 | +# define HAVE_POSIX_FALLOCATE 1 50 | +#endif 51 | + 52 | /* 53 | ** There are various methods for file locking used for concurrency 54 | ** control: 55 | @@ -24660,7 +24667,12 @@ 56 | #else 57 | { "pread64", (sqlite3_syscall_ptr)0, 0 }, 58 | #endif 59 | +#ifdef ANDROID 60 | +// Bionic defines pread64 using off64_t rather than off_t. 61 | +#define osPread64 ((ssize_t(*)(int,void*,size_t,off64_t))aSyscall[10].pCurrent) 62 | +#else 63 | #define osPread64 ((ssize_t(*)(int,void*,size_t,off_t))aSyscall[10].pCurrent) 64 | +#endif 65 | 66 | { "write", (sqlite3_syscall_ptr)write, 0 }, 67 | #define osWrite ((ssize_t(*)(int,const void*,size_t))aSyscall[11].pCurrent) 68 | @@ -24678,8 +24690,14 @@ 69 | #else 70 | { "pwrite64", (sqlite3_syscall_ptr)0, 0 }, 71 | #endif 72 | +#ifdef ANDROID 73 | +// Bionic defines pwrite64 using off64_t rather than off_t. 74 | +#define osPwrite64 ((ssize_t(*)(int,const void*,size_t,off64_t))\ 75 | + aSyscall[13].pCurrent) 76 | +#else 77 | #define osPwrite64 ((ssize_t(*)(int,const void*,size_t,off_t))\ 78 | aSyscall[13].pCurrent) 79 | +#endif 80 | 81 | { "fchmod", (sqlite3_syscall_ptr)fchmod, 0 }, 82 | #define osFchmod ((int(*)(int,mode_t))aSyscall[14].pCurrent) 83 | @@ -27909,7 +27927,7 @@ 84 | SimulateIOError( rc=1 ); 85 | if( rc!=0 ){ 86 | ((unixFile*)id)->lastErrno = errno; 87 | - return SQLITE_IOERR_FSTAT; 88 | + return unixLogError(SQLITE_IOERR_FSTAT, "fstat", ((unixFile*)id)->zPath); 89 | } 90 | *pSize = buf.st_size; 91 | 92 | @@ -27944,7 +27962,9 @@ 93 | i64 nSize; /* Required file size */ 94 | struct stat buf; /* Used to hold return values of fstat() */ 95 | 96 | - if( osFstat(pFile->h, &buf) ) return SQLITE_IOERR_FSTAT; 97 | + if( osFstat(pFile->h, &buf) ) { 98 | + return unixLogError(SQLITE_IOERR_FSTAT, "fstat", pFile->zPath); 99 | + } 100 | 101 | nSize = ((nByte+pFile->szChunk-1) / pFile->szChunk) * pFile->szChunk; 102 | if( nSize>(i64)buf.st_size ){ 103 | @@ -28510,7 +28530,7 @@ 104 | ** with the same permissions. 105 | */ 106 | if( osFstat(pDbFd->h, &sStat) && pInode->bProcessLock==0 ){ 107 | - rc = SQLITE_IOERR_FSTAT; 108 | + rc = unixLogError(SQLITE_IOERR_FSTAT, "fstat", pDbFd->zPath); 109 | goto shm_open_err; 110 | } 111 | 112 | @@ -29848,7 +29868,7 @@ 113 | *pUid = sStat.st_uid; 114 | *pGid = sStat.st_gid; 115 | }else{ 116 | - rc = SQLITE_IOERR_FSTAT; 117 | + rc = unixLogError(SQLITE_IOERR_FSTAT, "stat", zDb); 118 | } 119 | }else if( flags & SQLITE_OPEN_DELETEONCLOSE ){ 120 | *pMode = 0600; 121 | @@ -100867,7 +100887,7 @@ 122 | } 123 | if( pDb->pSchema->file_format>SQLITE_MAX_FILE_FORMAT ){ 124 | sqlite3SetString(pzErrMsg, db, "unsupported file format"); 125 | - rc = SQLITE_ERROR; 126 | + rc = SQLITE_CORRUPT_BKPT; // Android Change from "rc = SQLITE_ERROR;" 127 | goto initone_error_out; 128 | } 129 | 130 | @@ -124770,9 +124790,9 @@ 131 | #endif 132 | 133 | #ifdef SQLITE_ENABLE_FTS3 134 | - if( !db->mallocFailed && rc==SQLITE_OK ){ 135 | - rc = sqlite3Fts3Init(db); 136 | - } 137 | + if( !db->mallocFailed && rc==SQLITE_OK ){ 138 | + rc = sqlite3Fts3Init(db); 139 | + } 140 | #endif 141 | 142 | #ifdef SQLITE_ENABLE_ICU 143 | @@ -130660,16 +130680,28 @@ 144 | ** module with sqlite. 145 | */ 146 | if( SQLITE_OK==rc 147 | +#ifndef ANDROID /* fts3_tokenizer disabled for security reasons */ 148 | && SQLITE_OK==(rc = sqlite3Fts3InitHashTable(db, pHash, "fts3_tokenizer")) 149 | +#endif 150 | && SQLITE_OK==(rc = sqlite3_overload_function(db, "snippet", -1)) 151 | && SQLITE_OK==(rc = sqlite3_overload_function(db, "offsets", 1)) 152 | && SQLITE_OK==(rc = sqlite3_overload_function(db, "matchinfo", 1)) 153 | && SQLITE_OK==(rc = sqlite3_overload_function(db, "matchinfo", 2)) 154 | && SQLITE_OK==(rc = sqlite3_overload_function(db, "optimize", 1)) 155 | ){ 156 | +#ifdef SQLITE_ENABLE_FTS3_BACKWARDS 157 | + rc = sqlite3_create_module_v2( 158 | + db, "fts1", &fts3Module, (void *)pHash, 0 159 | + ); 160 | + if(rc) return rc; 161 | + rc = sqlite3_create_module_v2( 162 | + db, "fts2", &fts3Module, (void *)pHash, 0 163 | + ); 164 | + if(rc) return rc; 165 | +#endif 166 | rc = sqlite3_create_module_v2( 167 | db, "fts3", &fts3Module, (void *)pHash, hashDestroy 168 | - ); 169 | + ); 170 | if( rc==SQLITE_OK ){ 171 | rc = sqlite3_create_module_v2( 172 | db, "fts4", &fts3Module, (void *)pHash, 0 173 | -------------------------------------------------------------------------------- /dist/MODULE_LICENSE_PUBLIC_DOMAIN: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_external_sqlite/3f8fe414895cd42b17964d3044c2ecb1d5f2dae2/dist/MODULE_LICENSE_PUBLIC_DOMAIN -------------------------------------------------------------------------------- /dist/NOTICE: -------------------------------------------------------------------------------- 1 | 2001 September 15 2 | 3 | The author disclaims copyright to this source code. In place of 4 | a legal notice, here is a blessing: 5 | 6 | May you do good and not evil. 7 | May you find forgiveness for yourself and forgive others. 8 | May you share freely, never taking more than you give. 9 | 10 | -------------------------------------------------------------------------------- /dist/README-Android: -------------------------------------------------------------------------------- 1 | SQLite on Android 2 | 3 | The Android port of SQLite contains a few customizations. 4 | They are immortalized in Android.patch to ease future upgraded. 5 | 6 | This file can be regenerated using: 7 | 8 | diff -r -u -d orig . | grep -v "Only in" > Android.patch 9 | -------------------------------------------------------------------------------- /dist/orig/sqlite3ext.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** 2006 June 7 3 | ** 4 | ** The author disclaims copyright to this source code. In place of 5 | ** a legal notice, here is a blessing: 6 | ** 7 | ** May you do good and not evil. 8 | ** May you find forgiveness for yourself and forgive others. 9 | ** May you share freely, never taking more than you give. 10 | ** 11 | ************************************************************************* 12 | ** This header file defines the SQLite interface for use by 13 | ** shared libraries that want to be imported as extensions into 14 | ** an SQLite instance. Shared libraries that intend to be loaded 15 | ** as extensions by SQLite should #include this file instead of 16 | ** sqlite3.h. 17 | */ 18 | #ifndef _SQLITE3EXT_H_ 19 | #define _SQLITE3EXT_H_ 20 | #include "sqlite3.h" 21 | 22 | typedef struct sqlite3_api_routines sqlite3_api_routines; 23 | 24 | /* 25 | ** The following structure holds pointers to all of the SQLite API 26 | ** routines. 27 | ** 28 | ** WARNING: In order to maintain backwards compatibility, add new 29 | ** interfaces to the end of this structure only. If you insert new 30 | ** interfaces in the middle of this structure, then older different 31 | ** versions of SQLite will not be able to load each others' shared 32 | ** libraries! 33 | */ 34 | struct sqlite3_api_routines { 35 | void * (*aggregate_context)(sqlite3_context*,int nBytes); 36 | int (*aggregate_count)(sqlite3_context*); 37 | int (*bind_blob)(sqlite3_stmt*,int,const void*,int n,void(*)(void*)); 38 | int (*bind_double)(sqlite3_stmt*,int,double); 39 | int (*bind_int)(sqlite3_stmt*,int,int); 40 | int (*bind_int64)(sqlite3_stmt*,int,sqlite_int64); 41 | int (*bind_null)(sqlite3_stmt*,int); 42 | int (*bind_parameter_count)(sqlite3_stmt*); 43 | int (*bind_parameter_index)(sqlite3_stmt*,const char*zName); 44 | const char * (*bind_parameter_name)(sqlite3_stmt*,int); 45 | int (*bind_text)(sqlite3_stmt*,int,const char*,int n,void(*)(void*)); 46 | int (*bind_text16)(sqlite3_stmt*,int,const void*,int,void(*)(void*)); 47 | int (*bind_value)(sqlite3_stmt*,int,const sqlite3_value*); 48 | int (*busy_handler)(sqlite3*,int(*)(void*,int),void*); 49 | int (*busy_timeout)(sqlite3*,int ms); 50 | int (*changes)(sqlite3*); 51 | int (*close)(sqlite3*); 52 | int (*collation_needed)(sqlite3*,void*,void(*)(void*,sqlite3*, 53 | int eTextRep,const char*)); 54 | int (*collation_needed16)(sqlite3*,void*,void(*)(void*,sqlite3*, 55 | int eTextRep,const void*)); 56 | const void * (*column_blob)(sqlite3_stmt*,int iCol); 57 | int (*column_bytes)(sqlite3_stmt*,int iCol); 58 | int (*column_bytes16)(sqlite3_stmt*,int iCol); 59 | int (*column_count)(sqlite3_stmt*pStmt); 60 | const char * (*column_database_name)(sqlite3_stmt*,int); 61 | const void * (*column_database_name16)(sqlite3_stmt*,int); 62 | const char * (*column_decltype)(sqlite3_stmt*,int i); 63 | const void * (*column_decltype16)(sqlite3_stmt*,int); 64 | double (*column_double)(sqlite3_stmt*,int iCol); 65 | int (*column_int)(sqlite3_stmt*,int iCol); 66 | sqlite_int64 (*column_int64)(sqlite3_stmt*,int iCol); 67 | const char * (*column_name)(sqlite3_stmt*,int); 68 | const void * (*column_name16)(sqlite3_stmt*,int); 69 | const char * (*column_origin_name)(sqlite3_stmt*,int); 70 | const void * (*column_origin_name16)(sqlite3_stmt*,int); 71 | const char * (*column_table_name)(sqlite3_stmt*,int); 72 | const void * (*column_table_name16)(sqlite3_stmt*,int); 73 | const unsigned char * (*column_text)(sqlite3_stmt*,int iCol); 74 | const void * (*column_text16)(sqlite3_stmt*,int iCol); 75 | int (*column_type)(sqlite3_stmt*,int iCol); 76 | sqlite3_value* (*column_value)(sqlite3_stmt*,int iCol); 77 | void * (*commit_hook)(sqlite3*,int(*)(void*),void*); 78 | int (*complete)(const char*sql); 79 | int (*complete16)(const void*sql); 80 | int (*create_collation)(sqlite3*,const char*,int,void*, 81 | int(*)(void*,int,const void*,int,const void*)); 82 | int (*create_collation16)(sqlite3*,const void*,int,void*, 83 | int(*)(void*,int,const void*,int,const void*)); 84 | int (*create_function)(sqlite3*,const char*,int,int,void*, 85 | void (*xFunc)(sqlite3_context*,int,sqlite3_value**), 86 | void (*xStep)(sqlite3_context*,int,sqlite3_value**), 87 | void (*xFinal)(sqlite3_context*)); 88 | int (*create_function16)(sqlite3*,const void*,int,int,void*, 89 | void (*xFunc)(sqlite3_context*,int,sqlite3_value**), 90 | void (*xStep)(sqlite3_context*,int,sqlite3_value**), 91 | void (*xFinal)(sqlite3_context*)); 92 | int (*create_module)(sqlite3*,const char*,const sqlite3_module*,void*); 93 | int (*data_count)(sqlite3_stmt*pStmt); 94 | sqlite3 * (*db_handle)(sqlite3_stmt*); 95 | int (*declare_vtab)(sqlite3*,const char*); 96 | int (*enable_shared_cache)(int); 97 | int (*errcode)(sqlite3*db); 98 | const char * (*errmsg)(sqlite3*); 99 | const void * (*errmsg16)(sqlite3*); 100 | int (*exec)(sqlite3*,const char*,sqlite3_callback,void*,char**); 101 | int (*expired)(sqlite3_stmt*); 102 | int (*finalize)(sqlite3_stmt*pStmt); 103 | void (*free)(void*); 104 | void (*free_table)(char**result); 105 | int (*get_autocommit)(sqlite3*); 106 | void * (*get_auxdata)(sqlite3_context*,int); 107 | int (*get_table)(sqlite3*,const char*,char***,int*,int*,char**); 108 | int (*global_recover)(void); 109 | void (*interruptx)(sqlite3*); 110 | sqlite_int64 (*last_insert_rowid)(sqlite3*); 111 | const char * (*libversion)(void); 112 | int (*libversion_number)(void); 113 | void *(*malloc)(int); 114 | char * (*mprintf)(const char*,...); 115 | int (*open)(const char*,sqlite3**); 116 | int (*open16)(const void*,sqlite3**); 117 | int (*prepare)(sqlite3*,const char*,int,sqlite3_stmt**,const char**); 118 | int (*prepare16)(sqlite3*,const void*,int,sqlite3_stmt**,const void**); 119 | void * (*profile)(sqlite3*,void(*)(void*,const char*,sqlite_uint64),void*); 120 | void (*progress_handler)(sqlite3*,int,int(*)(void*),void*); 121 | void *(*realloc)(void*,int); 122 | int (*reset)(sqlite3_stmt*pStmt); 123 | void (*result_blob)(sqlite3_context*,const void*,int,void(*)(void*)); 124 | void (*result_double)(sqlite3_context*,double); 125 | void (*result_error)(sqlite3_context*,const char*,int); 126 | void (*result_error16)(sqlite3_context*,const void*,int); 127 | void (*result_int)(sqlite3_context*,int); 128 | void (*result_int64)(sqlite3_context*,sqlite_int64); 129 | void (*result_null)(sqlite3_context*); 130 | void (*result_text)(sqlite3_context*,const char*,int,void(*)(void*)); 131 | void (*result_text16)(sqlite3_context*,const void*,int,void(*)(void*)); 132 | void (*result_text16be)(sqlite3_context*,const void*,int,void(*)(void*)); 133 | void (*result_text16le)(sqlite3_context*,const void*,int,void(*)(void*)); 134 | void (*result_value)(sqlite3_context*,sqlite3_value*); 135 | void * (*rollback_hook)(sqlite3*,void(*)(void*),void*); 136 | int (*set_authorizer)(sqlite3*,int(*)(void*,int,const char*,const char*, 137 | const char*,const char*),void*); 138 | void (*set_auxdata)(sqlite3_context*,int,void*,void (*)(void*)); 139 | char * (*snprintf)(int,char*,const char*,...); 140 | int (*step)(sqlite3_stmt*); 141 | int (*table_column_metadata)(sqlite3*,const char*,const char*,const char*, 142 | char const**,char const**,int*,int*,int*); 143 | void (*thread_cleanup)(void); 144 | int (*total_changes)(sqlite3*); 145 | void * (*trace)(sqlite3*,void(*xTrace)(void*,const char*),void*); 146 | int (*transfer_bindings)(sqlite3_stmt*,sqlite3_stmt*); 147 | void * (*update_hook)(sqlite3*,void(*)(void*,int ,char const*,char const*, 148 | sqlite_int64),void*); 149 | void * (*user_data)(sqlite3_context*); 150 | const void * (*value_blob)(sqlite3_value*); 151 | int (*value_bytes)(sqlite3_value*); 152 | int (*value_bytes16)(sqlite3_value*); 153 | double (*value_double)(sqlite3_value*); 154 | int (*value_int)(sqlite3_value*); 155 | sqlite_int64 (*value_int64)(sqlite3_value*); 156 | int (*value_numeric_type)(sqlite3_value*); 157 | const unsigned char * (*value_text)(sqlite3_value*); 158 | const void * (*value_text16)(sqlite3_value*); 159 | const void * (*value_text16be)(sqlite3_value*); 160 | const void * (*value_text16le)(sqlite3_value*); 161 | int (*value_type)(sqlite3_value*); 162 | char *(*vmprintf)(const char*,va_list); 163 | /* Added ??? */ 164 | int (*overload_function)(sqlite3*, const char *zFuncName, int nArg); 165 | /* Added by 3.3.13 */ 166 | int (*prepare_v2)(sqlite3*,const char*,int,sqlite3_stmt**,const char**); 167 | int (*prepare16_v2)(sqlite3*,const void*,int,sqlite3_stmt**,const void**); 168 | int (*clear_bindings)(sqlite3_stmt*); 169 | /* Added by 3.4.1 */ 170 | int (*create_module_v2)(sqlite3*,const char*,const sqlite3_module*,void*, 171 | void (*xDestroy)(void *)); 172 | /* Added by 3.5.0 */ 173 | int (*bind_zeroblob)(sqlite3_stmt*,int,int); 174 | int (*blob_bytes)(sqlite3_blob*); 175 | int (*blob_close)(sqlite3_blob*); 176 | int (*blob_open)(sqlite3*,const char*,const char*,const char*,sqlite3_int64, 177 | int,sqlite3_blob**); 178 | int (*blob_read)(sqlite3_blob*,void*,int,int); 179 | int (*blob_write)(sqlite3_blob*,const void*,int,int); 180 | int (*create_collation_v2)(sqlite3*,const char*,int,void*, 181 | int(*)(void*,int,const void*,int,const void*), 182 | void(*)(void*)); 183 | int (*file_control)(sqlite3*,const char*,int,void*); 184 | sqlite3_int64 (*memory_highwater)(int); 185 | sqlite3_int64 (*memory_used)(void); 186 | sqlite3_mutex *(*mutex_alloc)(int); 187 | void (*mutex_enter)(sqlite3_mutex*); 188 | void (*mutex_free)(sqlite3_mutex*); 189 | void (*mutex_leave)(sqlite3_mutex*); 190 | int (*mutex_try)(sqlite3_mutex*); 191 | int (*open_v2)(const char*,sqlite3**,int,const char*); 192 | int (*release_memory)(int); 193 | void (*result_error_nomem)(sqlite3_context*); 194 | void (*result_error_toobig)(sqlite3_context*); 195 | int (*sleep)(int); 196 | void (*soft_heap_limit)(int); 197 | sqlite3_vfs *(*vfs_find)(const char*); 198 | int (*vfs_register)(sqlite3_vfs*,int); 199 | int (*vfs_unregister)(sqlite3_vfs*); 200 | int (*xthreadsafe)(void); 201 | void (*result_zeroblob)(sqlite3_context*,int); 202 | void (*result_error_code)(sqlite3_context*,int); 203 | int (*test_control)(int, ...); 204 | void (*randomness)(int,void*); 205 | sqlite3 *(*context_db_handle)(sqlite3_context*); 206 | int (*extended_result_codes)(sqlite3*,int); 207 | int (*limit)(sqlite3*,int,int); 208 | sqlite3_stmt *(*next_stmt)(sqlite3*,sqlite3_stmt*); 209 | const char *(*sql)(sqlite3_stmt*); 210 | int (*status)(int,int*,int*,int); 211 | int (*backup_finish)(sqlite3_backup*); 212 | sqlite3_backup *(*backup_init)(sqlite3*,const char*,sqlite3*,const char*); 213 | int (*backup_pagecount)(sqlite3_backup*); 214 | int (*backup_remaining)(sqlite3_backup*); 215 | int (*backup_step)(sqlite3_backup*,int); 216 | const char *(*compileoption_get)(int); 217 | int (*compileoption_used)(const char*); 218 | int (*create_function_v2)(sqlite3*,const char*,int,int,void*, 219 | void (*xFunc)(sqlite3_context*,int,sqlite3_value**), 220 | void (*xStep)(sqlite3_context*,int,sqlite3_value**), 221 | void (*xFinal)(sqlite3_context*), 222 | void(*xDestroy)(void*)); 223 | int (*db_config)(sqlite3*,int,...); 224 | sqlite3_mutex *(*db_mutex)(sqlite3*); 225 | int (*db_status)(sqlite3*,int,int*,int*,int); 226 | int (*extended_errcode)(sqlite3*); 227 | void (*log)(int,const char*,...); 228 | sqlite3_int64 (*soft_heap_limit64)(sqlite3_int64); 229 | const char *(*sourceid)(void); 230 | int (*stmt_status)(sqlite3_stmt*,int,int); 231 | int (*strnicmp)(const char*,const char*,int); 232 | int (*unlock_notify)(sqlite3*,void(*)(void**,int),void*); 233 | int (*wal_autocheckpoint)(sqlite3*,int); 234 | int (*wal_checkpoint)(sqlite3*,const char*); 235 | void *(*wal_hook)(sqlite3*,int(*)(void*,sqlite3*,const char*,int),void*); 236 | int (*blob_reopen)(sqlite3_blob*,sqlite3_int64); 237 | int (*vtab_config)(sqlite3*,int op,...); 238 | int (*vtab_on_conflict)(sqlite3*); 239 | /* Version 3.7.16 and later */ 240 | int (*close_v2)(sqlite3*); 241 | const char *(*db_filename)(sqlite3*,const char*); 242 | int (*db_readonly)(sqlite3*,const char*); 243 | int (*db_release_memory)(sqlite3*); 244 | const char *(*errstr)(int); 245 | int (*stmt_busy)(sqlite3_stmt*); 246 | int (*stmt_readonly)(sqlite3_stmt*); 247 | int (*stricmp)(const char*,const char*); 248 | int (*uri_boolean)(const char*,const char*,int); 249 | sqlite3_int64 (*uri_int64)(const char*,const char*,sqlite3_int64); 250 | const char *(*uri_parameter)(const char*,const char*); 251 | char *(*vsnprintf)(int,char*,const char*,va_list); 252 | int (*wal_checkpoint_v2)(sqlite3*,const char*,int,int*,int*); 253 | }; 254 | 255 | /* 256 | ** The following macros redefine the API routines so that they are 257 | ** redirected throught the global sqlite3_api structure. 258 | ** 259 | ** This header file is also used by the loadext.c source file 260 | ** (part of the main SQLite library - not an extension) so that 261 | ** it can get access to the sqlite3_api_routines structure 262 | ** definition. But the main library does not want to redefine 263 | ** the API. So the redefinition macros are only valid if the 264 | ** SQLITE_CORE macros is undefined. 265 | */ 266 | #ifndef SQLITE_CORE 267 | #define sqlite3_aggregate_context sqlite3_api->aggregate_context 268 | #ifndef SQLITE_OMIT_DEPRECATED 269 | #define sqlite3_aggregate_count sqlite3_api->aggregate_count 270 | #endif 271 | #define sqlite3_bind_blob sqlite3_api->bind_blob 272 | #define sqlite3_bind_double sqlite3_api->bind_double 273 | #define sqlite3_bind_int sqlite3_api->bind_int 274 | #define sqlite3_bind_int64 sqlite3_api->bind_int64 275 | #define sqlite3_bind_null sqlite3_api->bind_null 276 | #define sqlite3_bind_parameter_count sqlite3_api->bind_parameter_count 277 | #define sqlite3_bind_parameter_index sqlite3_api->bind_parameter_index 278 | #define sqlite3_bind_parameter_name sqlite3_api->bind_parameter_name 279 | #define sqlite3_bind_text sqlite3_api->bind_text 280 | #define sqlite3_bind_text16 sqlite3_api->bind_text16 281 | #define sqlite3_bind_value sqlite3_api->bind_value 282 | #define sqlite3_busy_handler sqlite3_api->busy_handler 283 | #define sqlite3_busy_timeout sqlite3_api->busy_timeout 284 | #define sqlite3_changes sqlite3_api->changes 285 | #define sqlite3_close sqlite3_api->close 286 | #define sqlite3_collation_needed sqlite3_api->collation_needed 287 | #define sqlite3_collation_needed16 sqlite3_api->collation_needed16 288 | #define sqlite3_column_blob sqlite3_api->column_blob 289 | #define sqlite3_column_bytes sqlite3_api->column_bytes 290 | #define sqlite3_column_bytes16 sqlite3_api->column_bytes16 291 | #define sqlite3_column_count sqlite3_api->column_count 292 | #define sqlite3_column_database_name sqlite3_api->column_database_name 293 | #define sqlite3_column_database_name16 sqlite3_api->column_database_name16 294 | #define sqlite3_column_decltype sqlite3_api->column_decltype 295 | #define sqlite3_column_decltype16 sqlite3_api->column_decltype16 296 | #define sqlite3_column_double sqlite3_api->column_double 297 | #define sqlite3_column_int sqlite3_api->column_int 298 | #define sqlite3_column_int64 sqlite3_api->column_int64 299 | #define sqlite3_column_name sqlite3_api->column_name 300 | #define sqlite3_column_name16 sqlite3_api->column_name16 301 | #define sqlite3_column_origin_name sqlite3_api->column_origin_name 302 | #define sqlite3_column_origin_name16 sqlite3_api->column_origin_name16 303 | #define sqlite3_column_table_name sqlite3_api->column_table_name 304 | #define sqlite3_column_table_name16 sqlite3_api->column_table_name16 305 | #define sqlite3_column_text sqlite3_api->column_text 306 | #define sqlite3_column_text16 sqlite3_api->column_text16 307 | #define sqlite3_column_type sqlite3_api->column_type 308 | #define sqlite3_column_value sqlite3_api->column_value 309 | #define sqlite3_commit_hook sqlite3_api->commit_hook 310 | #define sqlite3_complete sqlite3_api->complete 311 | #define sqlite3_complete16 sqlite3_api->complete16 312 | #define sqlite3_create_collation sqlite3_api->create_collation 313 | #define sqlite3_create_collation16 sqlite3_api->create_collation16 314 | #define sqlite3_create_function sqlite3_api->create_function 315 | #define sqlite3_create_function16 sqlite3_api->create_function16 316 | #define sqlite3_create_module sqlite3_api->create_module 317 | #define sqlite3_create_module_v2 sqlite3_api->create_module_v2 318 | #define sqlite3_data_count sqlite3_api->data_count 319 | #define sqlite3_db_handle sqlite3_api->db_handle 320 | #define sqlite3_declare_vtab sqlite3_api->declare_vtab 321 | #define sqlite3_enable_shared_cache sqlite3_api->enable_shared_cache 322 | #define sqlite3_errcode sqlite3_api->errcode 323 | #define sqlite3_errmsg sqlite3_api->errmsg 324 | #define sqlite3_errmsg16 sqlite3_api->errmsg16 325 | #define sqlite3_exec sqlite3_api->exec 326 | #ifndef SQLITE_OMIT_DEPRECATED 327 | #define sqlite3_expired sqlite3_api->expired 328 | #endif 329 | #define sqlite3_finalize sqlite3_api->finalize 330 | #define sqlite3_free sqlite3_api->free 331 | #define sqlite3_free_table sqlite3_api->free_table 332 | #define sqlite3_get_autocommit sqlite3_api->get_autocommit 333 | #define sqlite3_get_auxdata sqlite3_api->get_auxdata 334 | #define sqlite3_get_table sqlite3_api->get_table 335 | #ifndef SQLITE_OMIT_DEPRECATED 336 | #define sqlite3_global_recover sqlite3_api->global_recover 337 | #endif 338 | #define sqlite3_interrupt sqlite3_api->interruptx 339 | #define sqlite3_last_insert_rowid sqlite3_api->last_insert_rowid 340 | #define sqlite3_libversion sqlite3_api->libversion 341 | #define sqlite3_libversion_number sqlite3_api->libversion_number 342 | #define sqlite3_malloc sqlite3_api->malloc 343 | #define sqlite3_mprintf sqlite3_api->mprintf 344 | #define sqlite3_open sqlite3_api->open 345 | #define sqlite3_open16 sqlite3_api->open16 346 | #define sqlite3_prepare sqlite3_api->prepare 347 | #define sqlite3_prepare16 sqlite3_api->prepare16 348 | #define sqlite3_prepare_v2 sqlite3_api->prepare_v2 349 | #define sqlite3_prepare16_v2 sqlite3_api->prepare16_v2 350 | #define sqlite3_profile sqlite3_api->profile 351 | #define sqlite3_progress_handler sqlite3_api->progress_handler 352 | #define sqlite3_realloc sqlite3_api->realloc 353 | #define sqlite3_reset sqlite3_api->reset 354 | #define sqlite3_result_blob sqlite3_api->result_blob 355 | #define sqlite3_result_double sqlite3_api->result_double 356 | #define sqlite3_result_error sqlite3_api->result_error 357 | #define sqlite3_result_error16 sqlite3_api->result_error16 358 | #define sqlite3_result_int sqlite3_api->result_int 359 | #define sqlite3_result_int64 sqlite3_api->result_int64 360 | #define sqlite3_result_null sqlite3_api->result_null 361 | #define sqlite3_result_text sqlite3_api->result_text 362 | #define sqlite3_result_text16 sqlite3_api->result_text16 363 | #define sqlite3_result_text16be sqlite3_api->result_text16be 364 | #define sqlite3_result_text16le sqlite3_api->result_text16le 365 | #define sqlite3_result_value sqlite3_api->result_value 366 | #define sqlite3_rollback_hook sqlite3_api->rollback_hook 367 | #define sqlite3_set_authorizer sqlite3_api->set_authorizer 368 | #define sqlite3_set_auxdata sqlite3_api->set_auxdata 369 | #define sqlite3_snprintf sqlite3_api->snprintf 370 | #define sqlite3_step sqlite3_api->step 371 | #define sqlite3_table_column_metadata sqlite3_api->table_column_metadata 372 | #define sqlite3_thread_cleanup sqlite3_api->thread_cleanup 373 | #define sqlite3_total_changes sqlite3_api->total_changes 374 | #define sqlite3_trace sqlite3_api->trace 375 | #ifndef SQLITE_OMIT_DEPRECATED 376 | #define sqlite3_transfer_bindings sqlite3_api->transfer_bindings 377 | #endif 378 | #define sqlite3_update_hook sqlite3_api->update_hook 379 | #define sqlite3_user_data sqlite3_api->user_data 380 | #define sqlite3_value_blob sqlite3_api->value_blob 381 | #define sqlite3_value_bytes sqlite3_api->value_bytes 382 | #define sqlite3_value_bytes16 sqlite3_api->value_bytes16 383 | #define sqlite3_value_double sqlite3_api->value_double 384 | #define sqlite3_value_int sqlite3_api->value_int 385 | #define sqlite3_value_int64 sqlite3_api->value_int64 386 | #define sqlite3_value_numeric_type sqlite3_api->value_numeric_type 387 | #define sqlite3_value_text sqlite3_api->value_text 388 | #define sqlite3_value_text16 sqlite3_api->value_text16 389 | #define sqlite3_value_text16be sqlite3_api->value_text16be 390 | #define sqlite3_value_text16le sqlite3_api->value_text16le 391 | #define sqlite3_value_type sqlite3_api->value_type 392 | #define sqlite3_vmprintf sqlite3_api->vmprintf 393 | #define sqlite3_overload_function sqlite3_api->overload_function 394 | #define sqlite3_prepare_v2 sqlite3_api->prepare_v2 395 | #define sqlite3_prepare16_v2 sqlite3_api->prepare16_v2 396 | #define sqlite3_clear_bindings sqlite3_api->clear_bindings 397 | #define sqlite3_bind_zeroblob sqlite3_api->bind_zeroblob 398 | #define sqlite3_blob_bytes sqlite3_api->blob_bytes 399 | #define sqlite3_blob_close sqlite3_api->blob_close 400 | #define sqlite3_blob_open sqlite3_api->blob_open 401 | #define sqlite3_blob_read sqlite3_api->blob_read 402 | #define sqlite3_blob_write sqlite3_api->blob_write 403 | #define sqlite3_create_collation_v2 sqlite3_api->create_collation_v2 404 | #define sqlite3_file_control sqlite3_api->file_control 405 | #define sqlite3_memory_highwater sqlite3_api->memory_highwater 406 | #define sqlite3_memory_used sqlite3_api->memory_used 407 | #define sqlite3_mutex_alloc sqlite3_api->mutex_alloc 408 | #define sqlite3_mutex_enter sqlite3_api->mutex_enter 409 | #define sqlite3_mutex_free sqlite3_api->mutex_free 410 | #define sqlite3_mutex_leave sqlite3_api->mutex_leave 411 | #define sqlite3_mutex_try sqlite3_api->mutex_try 412 | #define sqlite3_open_v2 sqlite3_api->open_v2 413 | #define sqlite3_release_memory sqlite3_api->release_memory 414 | #define sqlite3_result_error_nomem sqlite3_api->result_error_nomem 415 | #define sqlite3_result_error_toobig sqlite3_api->result_error_toobig 416 | #define sqlite3_sleep sqlite3_api->sleep 417 | #define sqlite3_soft_heap_limit sqlite3_api->soft_heap_limit 418 | #define sqlite3_vfs_find sqlite3_api->vfs_find 419 | #define sqlite3_vfs_register sqlite3_api->vfs_register 420 | #define sqlite3_vfs_unregister sqlite3_api->vfs_unregister 421 | #define sqlite3_threadsafe sqlite3_api->xthreadsafe 422 | #define sqlite3_result_zeroblob sqlite3_api->result_zeroblob 423 | #define sqlite3_result_error_code sqlite3_api->result_error_code 424 | #define sqlite3_test_control sqlite3_api->test_control 425 | #define sqlite3_randomness sqlite3_api->randomness 426 | #define sqlite3_context_db_handle sqlite3_api->context_db_handle 427 | #define sqlite3_extended_result_codes sqlite3_api->extended_result_codes 428 | #define sqlite3_limit sqlite3_api->limit 429 | #define sqlite3_next_stmt sqlite3_api->next_stmt 430 | #define sqlite3_sql sqlite3_api->sql 431 | #define sqlite3_status sqlite3_api->status 432 | #define sqlite3_backup_finish sqlite3_api->backup_finish 433 | #define sqlite3_backup_init sqlite3_api->backup_init 434 | #define sqlite3_backup_pagecount sqlite3_api->backup_pagecount 435 | #define sqlite3_backup_remaining sqlite3_api->backup_remaining 436 | #define sqlite3_backup_step sqlite3_api->backup_step 437 | #define sqlite3_compileoption_get sqlite3_api->compileoption_get 438 | #define sqlite3_compileoption_used sqlite3_api->compileoption_used 439 | #define sqlite3_create_function_v2 sqlite3_api->create_function_v2 440 | #define sqlite3_db_config sqlite3_api->db_config 441 | #define sqlite3_db_mutex sqlite3_api->db_mutex 442 | #define sqlite3_db_status sqlite3_api->db_status 443 | #define sqlite3_extended_errcode sqlite3_api->extended_errcode 444 | #define sqlite3_log sqlite3_api->log 445 | #define sqlite3_soft_heap_limit64 sqlite3_api->soft_heap_limit64 446 | #define sqlite3_sourceid sqlite3_api->sourceid 447 | #define sqlite3_stmt_status sqlite3_api->stmt_status 448 | #define sqlite3_strnicmp sqlite3_api->strnicmp 449 | #define sqlite3_unlock_notify sqlite3_api->unlock_notify 450 | #define sqlite3_wal_autocheckpoint sqlite3_api->wal_autocheckpoint 451 | #define sqlite3_wal_checkpoint sqlite3_api->wal_checkpoint 452 | #define sqlite3_wal_hook sqlite3_api->wal_hook 453 | #define sqlite3_blob_reopen sqlite3_api->blob_reopen 454 | #define sqlite3_vtab_config sqlite3_api->vtab_config 455 | #define sqlite3_vtab_on_conflict sqlite3_api->vtab_on_conflict 456 | /* Version 3.7.16 and later */ 457 | #define sqlite3_close_v2 sqlite3_api->close_v2 458 | #define sqlite3_db_filename sqlite3_api->db_filename 459 | #define sqlite3_db_readonly sqlite3_api->db_readonly 460 | #define sqlite3_db_release_memory sqlite3_api->db_release_memory 461 | #define sqlite3_errstr sqlite3_api->errstr 462 | #define sqlite3_stmt_busy sqlite3_api->stmt_busy 463 | #define sqlite3_stmt_readonly sqlite3_api->stmt_readonly 464 | #define sqlite3_stricmp sqlite3_api->stricmp 465 | #define sqlite3_uri_boolean sqlite3_api->uri_boolean 466 | #define sqlite3_uri_int64 sqlite3_api->uri_int64 467 | #define sqlite3_uri_parameter sqlite3_api->uri_parameter 468 | #define sqlite3_uri_vsnprintf sqlite3_api->vsnprintf 469 | #define sqlite3_wal_checkpoint_v2 sqlite3_api->wal_checkpoint_v2 470 | #endif /* SQLITE_CORE */ 471 | 472 | #ifndef SQLITE_CORE 473 | /* This case when the file really is being compiled as a loadable 474 | ** extension */ 475 | # define SQLITE_EXTENSION_INIT1 const sqlite3_api_routines *sqlite3_api=0; 476 | # define SQLITE_EXTENSION_INIT2(v) sqlite3_api=v; 477 | # define SQLITE_EXTENSION_INIT3 \ 478 | extern const sqlite3_api_routines *sqlite3_api; 479 | #else 480 | /* This case when the file is being statically linked into the 481 | ** application */ 482 | # define SQLITE_EXTENSION_INIT1 /*no-op*/ 483 | # define SQLITE_EXTENSION_INIT2(v) (void)v; /* unused parameter */ 484 | # define SQLITE_EXTENSION_INIT3 /*no-op*/ 485 | #endif 486 | 487 | #endif /* _SQLITE3EXT_H_ */ 488 | -------------------------------------------------------------------------------- /dist/sqlite3ext.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** 2006 June 7 3 | ** 4 | ** The author disclaims copyright to this source code. In place of 5 | ** a legal notice, here is a blessing: 6 | ** 7 | ** May you do good and not evil. 8 | ** May you find forgiveness for yourself and forgive others. 9 | ** May you share freely, never taking more than you give. 10 | ** 11 | ************************************************************************* 12 | ** This header file defines the SQLite interface for use by 13 | ** shared libraries that want to be imported as extensions into 14 | ** an SQLite instance. Shared libraries that intend to be loaded 15 | ** as extensions by SQLite should #include this file instead of 16 | ** sqlite3.h. 17 | */ 18 | #ifndef _SQLITE3EXT_H_ 19 | #define _SQLITE3EXT_H_ 20 | #include "sqlite3.h" 21 | 22 | typedef struct sqlite3_api_routines sqlite3_api_routines; 23 | 24 | /* 25 | ** The following structure holds pointers to all of the SQLite API 26 | ** routines. 27 | ** 28 | ** WARNING: In order to maintain backwards compatibility, add new 29 | ** interfaces to the end of this structure only. If you insert new 30 | ** interfaces in the middle of this structure, then older different 31 | ** versions of SQLite will not be able to load each others' shared 32 | ** libraries! 33 | */ 34 | struct sqlite3_api_routines { 35 | void * (*aggregate_context)(sqlite3_context*,int nBytes); 36 | int (*aggregate_count)(sqlite3_context*); 37 | int (*bind_blob)(sqlite3_stmt*,int,const void*,int n,void(*)(void*)); 38 | int (*bind_double)(sqlite3_stmt*,int,double); 39 | int (*bind_int)(sqlite3_stmt*,int,int); 40 | int (*bind_int64)(sqlite3_stmt*,int,sqlite_int64); 41 | int (*bind_null)(sqlite3_stmt*,int); 42 | int (*bind_parameter_count)(sqlite3_stmt*); 43 | int (*bind_parameter_index)(sqlite3_stmt*,const char*zName); 44 | const char * (*bind_parameter_name)(sqlite3_stmt*,int); 45 | int (*bind_text)(sqlite3_stmt*,int,const char*,int n,void(*)(void*)); 46 | int (*bind_text16)(sqlite3_stmt*,int,const void*,int,void(*)(void*)); 47 | int (*bind_value)(sqlite3_stmt*,int,const sqlite3_value*); 48 | int (*busy_handler)(sqlite3*,int(*)(void*,int),void*); 49 | int (*busy_timeout)(sqlite3*,int ms); 50 | int (*changes)(sqlite3*); 51 | int (*close)(sqlite3*); 52 | int (*collation_needed)(sqlite3*,void*,void(*)(void*,sqlite3*, 53 | int eTextRep,const char*)); 54 | int (*collation_needed16)(sqlite3*,void*,void(*)(void*,sqlite3*, 55 | int eTextRep,const void*)); 56 | const void * (*column_blob)(sqlite3_stmt*,int iCol); 57 | int (*column_bytes)(sqlite3_stmt*,int iCol); 58 | int (*column_bytes16)(sqlite3_stmt*,int iCol); 59 | int (*column_count)(sqlite3_stmt*pStmt); 60 | const char * (*column_database_name)(sqlite3_stmt*,int); 61 | const void * (*column_database_name16)(sqlite3_stmt*,int); 62 | const char * (*column_decltype)(sqlite3_stmt*,int i); 63 | const void * (*column_decltype16)(sqlite3_stmt*,int); 64 | double (*column_double)(sqlite3_stmt*,int iCol); 65 | int (*column_int)(sqlite3_stmt*,int iCol); 66 | sqlite_int64 (*column_int64)(sqlite3_stmt*,int iCol); 67 | const char * (*column_name)(sqlite3_stmt*,int); 68 | const void * (*column_name16)(sqlite3_stmt*,int); 69 | const char * (*column_origin_name)(sqlite3_stmt*,int); 70 | const void * (*column_origin_name16)(sqlite3_stmt*,int); 71 | const char * (*column_table_name)(sqlite3_stmt*,int); 72 | const void * (*column_table_name16)(sqlite3_stmt*,int); 73 | const unsigned char * (*column_text)(sqlite3_stmt*,int iCol); 74 | const void * (*column_text16)(sqlite3_stmt*,int iCol); 75 | int (*column_type)(sqlite3_stmt*,int iCol); 76 | sqlite3_value* (*column_value)(sqlite3_stmt*,int iCol); 77 | void * (*commit_hook)(sqlite3*,int(*)(void*),void*); 78 | int (*complete)(const char*sql); 79 | int (*complete16)(const void*sql); 80 | int (*create_collation)(sqlite3*,const char*,int,void*, 81 | int(*)(void*,int,const void*,int,const void*)); 82 | int (*create_collation16)(sqlite3*,const void*,int,void*, 83 | int(*)(void*,int,const void*,int,const void*)); 84 | int (*create_function)(sqlite3*,const char*,int,int,void*, 85 | void (*xFunc)(sqlite3_context*,int,sqlite3_value**), 86 | void (*xStep)(sqlite3_context*,int,sqlite3_value**), 87 | void (*xFinal)(sqlite3_context*)); 88 | int (*create_function16)(sqlite3*,const void*,int,int,void*, 89 | void (*xFunc)(sqlite3_context*,int,sqlite3_value**), 90 | void (*xStep)(sqlite3_context*,int,sqlite3_value**), 91 | void (*xFinal)(sqlite3_context*)); 92 | int (*create_module)(sqlite3*,const char*,const sqlite3_module*,void*); 93 | int (*data_count)(sqlite3_stmt*pStmt); 94 | sqlite3 * (*db_handle)(sqlite3_stmt*); 95 | int (*declare_vtab)(sqlite3*,const char*); 96 | int (*enable_shared_cache)(int); 97 | int (*errcode)(sqlite3*db); 98 | const char * (*errmsg)(sqlite3*); 99 | const void * (*errmsg16)(sqlite3*); 100 | int (*exec)(sqlite3*,const char*,sqlite3_callback,void*,char**); 101 | int (*expired)(sqlite3_stmt*); 102 | int (*finalize)(sqlite3_stmt*pStmt); 103 | void (*free)(void*); 104 | void (*free_table)(char**result); 105 | int (*get_autocommit)(sqlite3*); 106 | void * (*get_auxdata)(sqlite3_context*,int); 107 | int (*get_table)(sqlite3*,const char*,char***,int*,int*,char**); 108 | int (*global_recover)(void); 109 | void (*interruptx)(sqlite3*); 110 | sqlite_int64 (*last_insert_rowid)(sqlite3*); 111 | const char * (*libversion)(void); 112 | int (*libversion_number)(void); 113 | void *(*malloc)(int); 114 | char * (*mprintf)(const char*,...); 115 | int (*open)(const char*,sqlite3**); 116 | int (*open16)(const void*,sqlite3**); 117 | int (*prepare)(sqlite3*,const char*,int,sqlite3_stmt**,const char**); 118 | int (*prepare16)(sqlite3*,const void*,int,sqlite3_stmt**,const void**); 119 | void * (*profile)(sqlite3*,void(*)(void*,const char*,sqlite_uint64),void*); 120 | void (*progress_handler)(sqlite3*,int,int(*)(void*),void*); 121 | void *(*realloc)(void*,int); 122 | int (*reset)(sqlite3_stmt*pStmt); 123 | void (*result_blob)(sqlite3_context*,const void*,int,void(*)(void*)); 124 | void (*result_double)(sqlite3_context*,double); 125 | void (*result_error)(sqlite3_context*,const char*,int); 126 | void (*result_error16)(sqlite3_context*,const void*,int); 127 | void (*result_int)(sqlite3_context*,int); 128 | void (*result_int64)(sqlite3_context*,sqlite_int64); 129 | void (*result_null)(sqlite3_context*); 130 | void (*result_text)(sqlite3_context*,const char*,int,void(*)(void*)); 131 | void (*result_text16)(sqlite3_context*,const void*,int,void(*)(void*)); 132 | void (*result_text16be)(sqlite3_context*,const void*,int,void(*)(void*)); 133 | void (*result_text16le)(sqlite3_context*,const void*,int,void(*)(void*)); 134 | void (*result_value)(sqlite3_context*,sqlite3_value*); 135 | void * (*rollback_hook)(sqlite3*,void(*)(void*),void*); 136 | int (*set_authorizer)(sqlite3*,int(*)(void*,int,const char*,const char*, 137 | const char*,const char*),void*); 138 | void (*set_auxdata)(sqlite3_context*,int,void*,void (*)(void*)); 139 | char * (*snprintf)(int,char*,const char*,...); 140 | int (*step)(sqlite3_stmt*); 141 | int (*table_column_metadata)(sqlite3*,const char*,const char*,const char*, 142 | char const**,char const**,int*,int*,int*); 143 | void (*thread_cleanup)(void); 144 | int (*total_changes)(sqlite3*); 145 | void * (*trace)(sqlite3*,void(*xTrace)(void*,const char*),void*); 146 | int (*transfer_bindings)(sqlite3_stmt*,sqlite3_stmt*); 147 | void * (*update_hook)(sqlite3*,void(*)(void*,int ,char const*,char const*, 148 | sqlite_int64),void*); 149 | void * (*user_data)(sqlite3_context*); 150 | const void * (*value_blob)(sqlite3_value*); 151 | int (*value_bytes)(sqlite3_value*); 152 | int (*value_bytes16)(sqlite3_value*); 153 | double (*value_double)(sqlite3_value*); 154 | int (*value_int)(sqlite3_value*); 155 | sqlite_int64 (*value_int64)(sqlite3_value*); 156 | int (*value_numeric_type)(sqlite3_value*); 157 | const unsigned char * (*value_text)(sqlite3_value*); 158 | const void * (*value_text16)(sqlite3_value*); 159 | const void * (*value_text16be)(sqlite3_value*); 160 | const void * (*value_text16le)(sqlite3_value*); 161 | int (*value_type)(sqlite3_value*); 162 | char *(*vmprintf)(const char*,va_list); 163 | /* Added ??? */ 164 | int (*overload_function)(sqlite3*, const char *zFuncName, int nArg); 165 | /* Added by 3.3.13 */ 166 | int (*prepare_v2)(sqlite3*,const char*,int,sqlite3_stmt**,const char**); 167 | int (*prepare16_v2)(sqlite3*,const void*,int,sqlite3_stmt**,const void**); 168 | int (*clear_bindings)(sqlite3_stmt*); 169 | /* Added by 3.4.1 */ 170 | int (*create_module_v2)(sqlite3*,const char*,const sqlite3_module*,void*, 171 | void (*xDestroy)(void *)); 172 | /* Added by 3.5.0 */ 173 | int (*bind_zeroblob)(sqlite3_stmt*,int,int); 174 | int (*blob_bytes)(sqlite3_blob*); 175 | int (*blob_close)(sqlite3_blob*); 176 | int (*blob_open)(sqlite3*,const char*,const char*,const char*,sqlite3_int64, 177 | int,sqlite3_blob**); 178 | int (*blob_read)(sqlite3_blob*,void*,int,int); 179 | int (*blob_write)(sqlite3_blob*,const void*,int,int); 180 | int (*create_collation_v2)(sqlite3*,const char*,int,void*, 181 | int(*)(void*,int,const void*,int,const void*), 182 | void(*)(void*)); 183 | int (*file_control)(sqlite3*,const char*,int,void*); 184 | sqlite3_int64 (*memory_highwater)(int); 185 | sqlite3_int64 (*memory_used)(void); 186 | sqlite3_mutex *(*mutex_alloc)(int); 187 | void (*mutex_enter)(sqlite3_mutex*); 188 | void (*mutex_free)(sqlite3_mutex*); 189 | void (*mutex_leave)(sqlite3_mutex*); 190 | int (*mutex_try)(sqlite3_mutex*); 191 | int (*open_v2)(const char*,sqlite3**,int,const char*); 192 | int (*release_memory)(int); 193 | void (*result_error_nomem)(sqlite3_context*); 194 | void (*result_error_toobig)(sqlite3_context*); 195 | int (*sleep)(int); 196 | void (*soft_heap_limit)(int); 197 | sqlite3_vfs *(*vfs_find)(const char*); 198 | int (*vfs_register)(sqlite3_vfs*,int); 199 | int (*vfs_unregister)(sqlite3_vfs*); 200 | int (*xthreadsafe)(void); 201 | void (*result_zeroblob)(sqlite3_context*,int); 202 | void (*result_error_code)(sqlite3_context*,int); 203 | int (*test_control)(int, ...); 204 | void (*randomness)(int,void*); 205 | sqlite3 *(*context_db_handle)(sqlite3_context*); 206 | int (*extended_result_codes)(sqlite3*,int); 207 | int (*limit)(sqlite3*,int,int); 208 | sqlite3_stmt *(*next_stmt)(sqlite3*,sqlite3_stmt*); 209 | const char *(*sql)(sqlite3_stmt*); 210 | int (*status)(int,int*,int*,int); 211 | int (*backup_finish)(sqlite3_backup*); 212 | sqlite3_backup *(*backup_init)(sqlite3*,const char*,sqlite3*,const char*); 213 | int (*backup_pagecount)(sqlite3_backup*); 214 | int (*backup_remaining)(sqlite3_backup*); 215 | int (*backup_step)(sqlite3_backup*,int); 216 | const char *(*compileoption_get)(int); 217 | int (*compileoption_used)(const char*); 218 | int (*create_function_v2)(sqlite3*,const char*,int,int,void*, 219 | void (*xFunc)(sqlite3_context*,int,sqlite3_value**), 220 | void (*xStep)(sqlite3_context*,int,sqlite3_value**), 221 | void (*xFinal)(sqlite3_context*), 222 | void(*xDestroy)(void*)); 223 | int (*db_config)(sqlite3*,int,...); 224 | sqlite3_mutex *(*db_mutex)(sqlite3*); 225 | int (*db_status)(sqlite3*,int,int*,int*,int); 226 | int (*extended_errcode)(sqlite3*); 227 | void (*log)(int,const char*,...); 228 | sqlite3_int64 (*soft_heap_limit64)(sqlite3_int64); 229 | const char *(*sourceid)(void); 230 | int (*stmt_status)(sqlite3_stmt*,int,int); 231 | int (*strnicmp)(const char*,const char*,int); 232 | int (*unlock_notify)(sqlite3*,void(*)(void**,int),void*); 233 | int (*wal_autocheckpoint)(sqlite3*,int); 234 | int (*wal_checkpoint)(sqlite3*,const char*); 235 | void *(*wal_hook)(sqlite3*,int(*)(void*,sqlite3*,const char*,int),void*); 236 | int (*blob_reopen)(sqlite3_blob*,sqlite3_int64); 237 | int (*vtab_config)(sqlite3*,int op,...); 238 | int (*vtab_on_conflict)(sqlite3*); 239 | /* Version 3.7.16 and later */ 240 | int (*close_v2)(sqlite3*); 241 | const char *(*db_filename)(sqlite3*,const char*); 242 | int (*db_readonly)(sqlite3*,const char*); 243 | int (*db_release_memory)(sqlite3*); 244 | const char *(*errstr)(int); 245 | int (*stmt_busy)(sqlite3_stmt*); 246 | int (*stmt_readonly)(sqlite3_stmt*); 247 | int (*stricmp)(const char*,const char*); 248 | int (*uri_boolean)(const char*,const char*,int); 249 | sqlite3_int64 (*uri_int64)(const char*,const char*,sqlite3_int64); 250 | const char *(*uri_parameter)(const char*,const char*); 251 | char *(*vsnprintf)(int,char*,const char*,va_list); 252 | int (*wal_checkpoint_v2)(sqlite3*,const char*,int,int*,int*); 253 | }; 254 | 255 | /* 256 | ** The following macros redefine the API routines so that they are 257 | ** redirected throught the global sqlite3_api structure. 258 | ** 259 | ** This header file is also used by the loadext.c source file 260 | ** (part of the main SQLite library - not an extension) so that 261 | ** it can get access to the sqlite3_api_routines structure 262 | ** definition. But the main library does not want to redefine 263 | ** the API. So the redefinition macros are only valid if the 264 | ** SQLITE_CORE macros is undefined. 265 | */ 266 | #ifndef SQLITE_CORE 267 | #define sqlite3_aggregate_context sqlite3_api->aggregate_context 268 | #ifndef SQLITE_OMIT_DEPRECATED 269 | #define sqlite3_aggregate_count sqlite3_api->aggregate_count 270 | #endif 271 | #define sqlite3_bind_blob sqlite3_api->bind_blob 272 | #define sqlite3_bind_double sqlite3_api->bind_double 273 | #define sqlite3_bind_int sqlite3_api->bind_int 274 | #define sqlite3_bind_int64 sqlite3_api->bind_int64 275 | #define sqlite3_bind_null sqlite3_api->bind_null 276 | #define sqlite3_bind_parameter_count sqlite3_api->bind_parameter_count 277 | #define sqlite3_bind_parameter_index sqlite3_api->bind_parameter_index 278 | #define sqlite3_bind_parameter_name sqlite3_api->bind_parameter_name 279 | #define sqlite3_bind_text sqlite3_api->bind_text 280 | #define sqlite3_bind_text16 sqlite3_api->bind_text16 281 | #define sqlite3_bind_value sqlite3_api->bind_value 282 | #define sqlite3_busy_handler sqlite3_api->busy_handler 283 | #define sqlite3_busy_timeout sqlite3_api->busy_timeout 284 | #define sqlite3_changes sqlite3_api->changes 285 | #define sqlite3_close sqlite3_api->close 286 | #define sqlite3_collation_needed sqlite3_api->collation_needed 287 | #define sqlite3_collation_needed16 sqlite3_api->collation_needed16 288 | #define sqlite3_column_blob sqlite3_api->column_blob 289 | #define sqlite3_column_bytes sqlite3_api->column_bytes 290 | #define sqlite3_column_bytes16 sqlite3_api->column_bytes16 291 | #define sqlite3_column_count sqlite3_api->column_count 292 | #define sqlite3_column_database_name sqlite3_api->column_database_name 293 | #define sqlite3_column_database_name16 sqlite3_api->column_database_name16 294 | #define sqlite3_column_decltype sqlite3_api->column_decltype 295 | #define sqlite3_column_decltype16 sqlite3_api->column_decltype16 296 | #define sqlite3_column_double sqlite3_api->column_double 297 | #define sqlite3_column_int sqlite3_api->column_int 298 | #define sqlite3_column_int64 sqlite3_api->column_int64 299 | #define sqlite3_column_name sqlite3_api->column_name 300 | #define sqlite3_column_name16 sqlite3_api->column_name16 301 | #define sqlite3_column_origin_name sqlite3_api->column_origin_name 302 | #define sqlite3_column_origin_name16 sqlite3_api->column_origin_name16 303 | #define sqlite3_column_table_name sqlite3_api->column_table_name 304 | #define sqlite3_column_table_name16 sqlite3_api->column_table_name16 305 | #define sqlite3_column_text sqlite3_api->column_text 306 | #define sqlite3_column_text16 sqlite3_api->column_text16 307 | #define sqlite3_column_type sqlite3_api->column_type 308 | #define sqlite3_column_value sqlite3_api->column_value 309 | #define sqlite3_commit_hook sqlite3_api->commit_hook 310 | #define sqlite3_complete sqlite3_api->complete 311 | #define sqlite3_complete16 sqlite3_api->complete16 312 | #define sqlite3_create_collation sqlite3_api->create_collation 313 | #define sqlite3_create_collation16 sqlite3_api->create_collation16 314 | #define sqlite3_create_function sqlite3_api->create_function 315 | #define sqlite3_create_function16 sqlite3_api->create_function16 316 | #define sqlite3_create_module sqlite3_api->create_module 317 | #define sqlite3_create_module_v2 sqlite3_api->create_module_v2 318 | #define sqlite3_data_count sqlite3_api->data_count 319 | #define sqlite3_db_handle sqlite3_api->db_handle 320 | #define sqlite3_declare_vtab sqlite3_api->declare_vtab 321 | #define sqlite3_enable_shared_cache sqlite3_api->enable_shared_cache 322 | #define sqlite3_errcode sqlite3_api->errcode 323 | #define sqlite3_errmsg sqlite3_api->errmsg 324 | #define sqlite3_errmsg16 sqlite3_api->errmsg16 325 | #define sqlite3_exec sqlite3_api->exec 326 | #ifndef SQLITE_OMIT_DEPRECATED 327 | #define sqlite3_expired sqlite3_api->expired 328 | #endif 329 | #define sqlite3_finalize sqlite3_api->finalize 330 | #define sqlite3_free sqlite3_api->free 331 | #define sqlite3_free_table sqlite3_api->free_table 332 | #define sqlite3_get_autocommit sqlite3_api->get_autocommit 333 | #define sqlite3_get_auxdata sqlite3_api->get_auxdata 334 | #define sqlite3_get_table sqlite3_api->get_table 335 | #ifndef SQLITE_OMIT_DEPRECATED 336 | #define sqlite3_global_recover sqlite3_api->global_recover 337 | #endif 338 | #define sqlite3_interrupt sqlite3_api->interruptx 339 | #define sqlite3_last_insert_rowid sqlite3_api->last_insert_rowid 340 | #define sqlite3_libversion sqlite3_api->libversion 341 | #define sqlite3_libversion_number sqlite3_api->libversion_number 342 | #define sqlite3_malloc sqlite3_api->malloc 343 | #define sqlite3_mprintf sqlite3_api->mprintf 344 | #define sqlite3_open sqlite3_api->open 345 | #define sqlite3_open16 sqlite3_api->open16 346 | #define sqlite3_prepare sqlite3_api->prepare 347 | #define sqlite3_prepare16 sqlite3_api->prepare16 348 | #define sqlite3_prepare_v2 sqlite3_api->prepare_v2 349 | #define sqlite3_prepare16_v2 sqlite3_api->prepare16_v2 350 | #define sqlite3_profile sqlite3_api->profile 351 | #define sqlite3_progress_handler sqlite3_api->progress_handler 352 | #define sqlite3_realloc sqlite3_api->realloc 353 | #define sqlite3_reset sqlite3_api->reset 354 | #define sqlite3_result_blob sqlite3_api->result_blob 355 | #define sqlite3_result_double sqlite3_api->result_double 356 | #define sqlite3_result_error sqlite3_api->result_error 357 | #define sqlite3_result_error16 sqlite3_api->result_error16 358 | #define sqlite3_result_int sqlite3_api->result_int 359 | #define sqlite3_result_int64 sqlite3_api->result_int64 360 | #define sqlite3_result_null sqlite3_api->result_null 361 | #define sqlite3_result_text sqlite3_api->result_text 362 | #define sqlite3_result_text16 sqlite3_api->result_text16 363 | #define sqlite3_result_text16be sqlite3_api->result_text16be 364 | #define sqlite3_result_text16le sqlite3_api->result_text16le 365 | #define sqlite3_result_value sqlite3_api->result_value 366 | #define sqlite3_rollback_hook sqlite3_api->rollback_hook 367 | #define sqlite3_set_authorizer sqlite3_api->set_authorizer 368 | #define sqlite3_set_auxdata sqlite3_api->set_auxdata 369 | #define sqlite3_snprintf sqlite3_api->snprintf 370 | #define sqlite3_step sqlite3_api->step 371 | #define sqlite3_table_column_metadata sqlite3_api->table_column_metadata 372 | #define sqlite3_thread_cleanup sqlite3_api->thread_cleanup 373 | #define sqlite3_total_changes sqlite3_api->total_changes 374 | #define sqlite3_trace sqlite3_api->trace 375 | #ifndef SQLITE_OMIT_DEPRECATED 376 | #define sqlite3_transfer_bindings sqlite3_api->transfer_bindings 377 | #endif 378 | #define sqlite3_update_hook sqlite3_api->update_hook 379 | #define sqlite3_user_data sqlite3_api->user_data 380 | #define sqlite3_value_blob sqlite3_api->value_blob 381 | #define sqlite3_value_bytes sqlite3_api->value_bytes 382 | #define sqlite3_value_bytes16 sqlite3_api->value_bytes16 383 | #define sqlite3_value_double sqlite3_api->value_double 384 | #define sqlite3_value_int sqlite3_api->value_int 385 | #define sqlite3_value_int64 sqlite3_api->value_int64 386 | #define sqlite3_value_numeric_type sqlite3_api->value_numeric_type 387 | #define sqlite3_value_text sqlite3_api->value_text 388 | #define sqlite3_value_text16 sqlite3_api->value_text16 389 | #define sqlite3_value_text16be sqlite3_api->value_text16be 390 | #define sqlite3_value_text16le sqlite3_api->value_text16le 391 | #define sqlite3_value_type sqlite3_api->value_type 392 | #define sqlite3_vmprintf sqlite3_api->vmprintf 393 | #define sqlite3_overload_function sqlite3_api->overload_function 394 | #define sqlite3_prepare_v2 sqlite3_api->prepare_v2 395 | #define sqlite3_prepare16_v2 sqlite3_api->prepare16_v2 396 | #define sqlite3_clear_bindings sqlite3_api->clear_bindings 397 | #define sqlite3_bind_zeroblob sqlite3_api->bind_zeroblob 398 | #define sqlite3_blob_bytes sqlite3_api->blob_bytes 399 | #define sqlite3_blob_close sqlite3_api->blob_close 400 | #define sqlite3_blob_open sqlite3_api->blob_open 401 | #define sqlite3_blob_read sqlite3_api->blob_read 402 | #define sqlite3_blob_write sqlite3_api->blob_write 403 | #define sqlite3_create_collation_v2 sqlite3_api->create_collation_v2 404 | #define sqlite3_file_control sqlite3_api->file_control 405 | #define sqlite3_memory_highwater sqlite3_api->memory_highwater 406 | #define sqlite3_memory_used sqlite3_api->memory_used 407 | #define sqlite3_mutex_alloc sqlite3_api->mutex_alloc 408 | #define sqlite3_mutex_enter sqlite3_api->mutex_enter 409 | #define sqlite3_mutex_free sqlite3_api->mutex_free 410 | #define sqlite3_mutex_leave sqlite3_api->mutex_leave 411 | #define sqlite3_mutex_try sqlite3_api->mutex_try 412 | #define sqlite3_open_v2 sqlite3_api->open_v2 413 | #define sqlite3_release_memory sqlite3_api->release_memory 414 | #define sqlite3_result_error_nomem sqlite3_api->result_error_nomem 415 | #define sqlite3_result_error_toobig sqlite3_api->result_error_toobig 416 | #define sqlite3_sleep sqlite3_api->sleep 417 | #define sqlite3_soft_heap_limit sqlite3_api->soft_heap_limit 418 | #define sqlite3_vfs_find sqlite3_api->vfs_find 419 | #define sqlite3_vfs_register sqlite3_api->vfs_register 420 | #define sqlite3_vfs_unregister sqlite3_api->vfs_unregister 421 | #define sqlite3_threadsafe sqlite3_api->xthreadsafe 422 | #define sqlite3_result_zeroblob sqlite3_api->result_zeroblob 423 | #define sqlite3_result_error_code sqlite3_api->result_error_code 424 | #define sqlite3_test_control sqlite3_api->test_control 425 | #define sqlite3_randomness sqlite3_api->randomness 426 | #define sqlite3_context_db_handle sqlite3_api->context_db_handle 427 | #define sqlite3_extended_result_codes sqlite3_api->extended_result_codes 428 | #define sqlite3_limit sqlite3_api->limit 429 | #define sqlite3_next_stmt sqlite3_api->next_stmt 430 | #define sqlite3_sql sqlite3_api->sql 431 | #define sqlite3_status sqlite3_api->status 432 | #define sqlite3_backup_finish sqlite3_api->backup_finish 433 | #define sqlite3_backup_init sqlite3_api->backup_init 434 | #define sqlite3_backup_pagecount sqlite3_api->backup_pagecount 435 | #define sqlite3_backup_remaining sqlite3_api->backup_remaining 436 | #define sqlite3_backup_step sqlite3_api->backup_step 437 | #define sqlite3_compileoption_get sqlite3_api->compileoption_get 438 | #define sqlite3_compileoption_used sqlite3_api->compileoption_used 439 | #define sqlite3_create_function_v2 sqlite3_api->create_function_v2 440 | #define sqlite3_db_config sqlite3_api->db_config 441 | #define sqlite3_db_mutex sqlite3_api->db_mutex 442 | #define sqlite3_db_status sqlite3_api->db_status 443 | #define sqlite3_extended_errcode sqlite3_api->extended_errcode 444 | #define sqlite3_log sqlite3_api->log 445 | #define sqlite3_soft_heap_limit64 sqlite3_api->soft_heap_limit64 446 | #define sqlite3_sourceid sqlite3_api->sourceid 447 | #define sqlite3_stmt_status sqlite3_api->stmt_status 448 | #define sqlite3_strnicmp sqlite3_api->strnicmp 449 | #define sqlite3_unlock_notify sqlite3_api->unlock_notify 450 | #define sqlite3_wal_autocheckpoint sqlite3_api->wal_autocheckpoint 451 | #define sqlite3_wal_checkpoint sqlite3_api->wal_checkpoint 452 | #define sqlite3_wal_hook sqlite3_api->wal_hook 453 | #define sqlite3_blob_reopen sqlite3_api->blob_reopen 454 | #define sqlite3_vtab_config sqlite3_api->vtab_config 455 | #define sqlite3_vtab_on_conflict sqlite3_api->vtab_on_conflict 456 | /* Version 3.7.16 and later */ 457 | #define sqlite3_close_v2 sqlite3_api->close_v2 458 | #define sqlite3_db_filename sqlite3_api->db_filename 459 | #define sqlite3_db_readonly sqlite3_api->db_readonly 460 | #define sqlite3_db_release_memory sqlite3_api->db_release_memory 461 | #define sqlite3_errstr sqlite3_api->errstr 462 | #define sqlite3_stmt_busy sqlite3_api->stmt_busy 463 | #define sqlite3_stmt_readonly sqlite3_api->stmt_readonly 464 | #define sqlite3_stricmp sqlite3_api->stricmp 465 | #define sqlite3_uri_boolean sqlite3_api->uri_boolean 466 | #define sqlite3_uri_int64 sqlite3_api->uri_int64 467 | #define sqlite3_uri_parameter sqlite3_api->uri_parameter 468 | #define sqlite3_uri_vsnprintf sqlite3_api->vsnprintf 469 | #define sqlite3_wal_checkpoint_v2 sqlite3_api->wal_checkpoint_v2 470 | #endif /* SQLITE_CORE */ 471 | 472 | #ifndef SQLITE_CORE 473 | /* This case when the file really is being compiled as a loadable 474 | ** extension */ 475 | # define SQLITE_EXTENSION_INIT1 const sqlite3_api_routines *sqlite3_api=0; 476 | # define SQLITE_EXTENSION_INIT2(v) sqlite3_api=v; 477 | # define SQLITE_EXTENSION_INIT3 \ 478 | extern const sqlite3_api_routines *sqlite3_api; 479 | #else 480 | /* This case when the file is being statically linked into the 481 | ** application */ 482 | # define SQLITE_EXTENSION_INIT1 /*no-op*/ 483 | # define SQLITE_EXTENSION_INIT2(v) (void)v; /* unused parameter */ 484 | # define SQLITE_EXTENSION_INIT3 /*no-op*/ 485 | #endif 486 | 487 | #endif /* _SQLITE3EXT_H_ */ 488 | -------------------------------------------------------------------------------- /dist/version: -------------------------------------------------------------------------------- 1 | downloaded from http://www.sqlite.org/2014/sqlite-amalgamation-3080600.zip 2 | --------------------------------------------------------------------------------