rhodes 2.3.2 → 2.4.0.beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (623) hide show
  1. data/CHANGELOG +18 -0
  2. data/CREDITS +38 -0
  3. data/README.md +2 -2
  4. data/Rakefile +60 -2
  5. data/bin/set-rhodes-sdk.bat +1 -0
  6. data/doc/application.txt +11 -0
  7. data/doc/build.txt +156 -39
  8. data/doc/configuration.txt +1 -10
  9. data/doc/connect-to-web-services.txt +6 -6
  10. data/doc/device-caps.txt +48 -5
  11. data/doc/extensions.txt +8 -1
  12. data/doc/rhom.txt +16 -0
  13. data/doc/synchronization.txt +56 -14
  14. data/doc/ui.txt +23 -2
  15. data/installer/instant-rhodes.nsi +6 -6
  16. data/lib/extensions/barcode/ext/barcode/platform/iphone/Barcode.xcodeproj/project.pbxproj +4 -2
  17. data/lib/extensions/barcode/ext/barcode/platform/wm/Rakefile +1 -1
  18. data/lib/extensions/digest-md5/ext/Rakefile +3 -3
  19. data/lib/extensions/digest-md5/ext/build +0 -1
  20. data/lib/extensions/digest-sha1/ext/Rakefile +1 -1
  21. data/lib/extensions/digest-sha1/ext/build +0 -1
  22. data/lib/extensions/digest/ext/Rakefile +3 -3
  23. data/lib/extensions/digest/ext/build +0 -1
  24. data/lib/extensions/fcntl/ext/Rakefile +1 -1
  25. data/lib/extensions/mspec/mspec/guards/guard.rb +4 -0
  26. data/lib/extensions/mspec/mspec/helpers/environment.rb +4 -0
  27. data/lib/extensions/nfc/ext.yml +2 -0
  28. data/lib/extensions/nfc/ext/build +12 -0
  29. data/lib/extensions/nfc/ext/build.bat +8 -0
  30. data/lib/extensions/nfc/ext/nfc/platform/android/AndroidManifest.xml +25 -0
  31. data/lib/extensions/nfc/ext/nfc/platform/android/Rakefile +94 -0
  32. data/lib/extensions/nfc/ext/nfc/platform/android/ext_build.files +4 -0
  33. data/lib/extensions/nfc/ext/nfc/platform/android/jni/src/nfc.cpp +404 -0
  34. data/lib/extensions/nfc/ext/nfc/platform/android/src/com/nfc/Nfc.java +138 -0
  35. data/lib/extensions/nfc/ext/nfc/platform/android/src/com/nfc/NfcMessage.java +34 -0
  36. data/lib/extensions/nfc/ext/nfc/platform/android/src/com/nfc/NfcMessagePack.java +33 -0
  37. data/lib/extensions/nfc/ext/nfc/platform/android/src/com/nfc/NfcRecord.java +149 -0
  38. data/lib/extensions/nfc/ext/nfc/shared/ruby/nfc.i +22 -0
  39. data/lib/extensions/nfc/ext/nfc/shared/ruby/nfc_wrap.c +2034 -0
  40. data/lib/extensions/nfc/nfc.rb +120 -0
  41. data/lib/extensions/rholang/{lang_ca.rb → rholang/lang_ca.rb} +0 -0
  42. data/lib/extensions/rholang/{lang_cf.rb → rholang/lang_cf.rb} +0 -0
  43. data/lib/extensions/rholang/{lang_chef.rb → rholang/lang_chef.rb} +0 -0
  44. data/lib/extensions/rholang/{lang_cs.rb → rholang/lang_cs.rb} +0 -0
  45. data/lib/extensions/rholang/{lang_da.rb → rholang/lang_da.rb} +0 -0
  46. data/lib/extensions/rholang/{lang_de.rb → rholang/lang_de.rb} +0 -0
  47. data/lib/extensions/rholang/{lang_es.rb → rholang/lang_es.rb} +0 -0
  48. data/lib/extensions/rholang/{lang_es_ar.rb → rholang/lang_es_ar.rb} +0 -0
  49. data/lib/extensions/rholang/{lang_fi.rb → rholang/lang_fi.rb} +0 -0
  50. data/lib/extensions/rholang/{lang_fr.rb → rholang/lang_fr.rb} +0 -0
  51. data/lib/extensions/rholang/{lang_it.rb → rholang/lang_it.rb} +0 -0
  52. data/lib/extensions/rholang/{lang_ko.rb → rholang/lang_ko.rb} +0 -0
  53. data/lib/extensions/rholang/{lang_nl.rb → rholang/lang_nl.rb} +0 -0
  54. data/lib/extensions/rholang/{lang_no.rb → rholang/lang_no.rb} +0 -0
  55. data/lib/extensions/rholang/{lang_pt.rb → rholang/lang_pt.rb} +0 -0
  56. data/lib/extensions/rholang/{lang_pt_br.rb → rholang/lang_pt_br.rb} +0 -0
  57. data/lib/extensions/rholang/{lang_ru.rb → rholang/lang_ru.rb} +0 -0
  58. data/lib/extensions/rholang/{lang_se.rb → rholang/lang_se.rb} +0 -0
  59. data/lib/extensions/rholang/{lang_sr.rb → rholang/lang_sr.rb} +0 -0
  60. data/lib/extensions/rholang/{rhoerror_ru.rb → rholang/rhoerror_ru.rb} +0 -0
  61. data/lib/extensions/rholang/{rhomsg_ru.rb → rholang/rhomsg_ru.rb} +0 -0
  62. data/lib/framework/date/format.rb +2 -0
  63. data/lib/framework/dateOrig.rb +17 -8
  64. data/lib/framework/rational18.rb +532 -0
  65. data/lib/framework/res/back_btn.wp7.png +0 -0
  66. data/lib/framework/res/blue_pushpin.wp7.png +0 -0
  67. data/lib/framework/res/blue_pushpin_small.wp7.png +0 -0
  68. data/lib/framework/res/callout.wp7.png +0 -0
  69. data/lib/framework/res/callout_link.wp7.png +0 -0
  70. data/lib/framework/res/esri.wp7.png +0 -0
  71. data/lib/framework/res/forward_btn.wp7.png +0 -0
  72. data/lib/framework/res/home_btn.wp7.png +0 -0
  73. data/lib/framework/res/options_btn.wp7.png +0 -0
  74. data/lib/framework/res/refresh_btn.wp7.png +0 -0
  75. data/lib/framework/rho/render.rb +8 -1
  76. data/lib/framework/rho/rho.rb +30 -7
  77. data/lib/framework/rho/rhoapplication.rb +9 -4
  78. data/lib/framework/rho/rhofsconnector.rb +5 -1
  79. data/lib/framework/rho/rhotabbar.rb +8 -0
  80. data/lib/framework/rho/rhotoolbar.rb +1 -1
  81. data/lib/framework/rho/rhoviewhelpers.rb +18 -1
  82. data/lib/framework/rhodes.rb +1 -1
  83. data/lib/framework/rhoframework.rb +46 -1
  84. data/lib/framework/rholang/localization_simplified.rb +17 -16
  85. data/lib/framework/rhom/rhom_db_adapter.rb +2 -2
  86. data/lib/framework/rhom/rhom_object_factory.rb +115 -12
  87. data/lib/framework/rhosystem.rb +135 -0
  88. data/lib/framework/version.rb +1 -1
  89. data/lib/rhodes.rb +1 -1
  90. data/lib/test/apps/rhoconfig.txt +23 -23
  91. data/platform/android/Rhodes/AndroidManifest.full.xml +101 -0
  92. data/platform/android/Rhodes/AndroidManifest.xml +10 -15
  93. data/platform/android/Rhodes/default.properties +11 -0
  94. data/platform/android/Rhodes/gen/com/rhomobile/rhodes/R.java +59 -53
  95. data/platform/android/Rhodes/jni/include/rhodes.h +1 -0
  96. data/platform/android/Rhodes/jni/include/rhodes/jni/com_rhomobile_rhodes_RhodesApplication.h +21 -0
  97. data/platform/android/Rhodes/jni/include/rhodes/jni/com_rhomobile_rhodes_alert_PopupActivity.h +21 -0
  98. data/platform/android/Rhodes/jni/include/rhodes/jni/com_rhomobile_rhodes_file_RhoFileApi.h +10 -2
  99. data/platform/android/Rhodes/jni/src/alert.cpp +2 -1
  100. data/platform/android/Rhodes/jni/src/datetimepicker.cpp +2 -0
  101. data/platform/android/Rhodes/jni/src/fileapi.cpp +671 -84
  102. data/platform/android/Rhodes/jni/src/nativebar.cpp +18 -0
  103. data/platform/android/Rhodes/jni/src/rhodes.cpp +92 -1
  104. data/platform/android/Rhodes/res/values/styles.xml +7 -0
  105. data/platform/android/Rhodes/src/com/rhomobile/rhodes/BaseActivity.java +35 -2
  106. data/platform/android/Rhodes/src/com/rhomobile/rhodes/Capabilities.java +12 -13
  107. data/platform/android/Rhodes/src/com/rhomobile/rhodes/LocalFileProvider.java +130 -0
  108. data/platform/android/Rhodes/src/com/rhomobile/rhodes/NativeBar.java +6 -0
  109. data/platform/android/Rhodes/src/com/rhomobile/rhodes/PushReceiver.java +5 -1
  110. data/platform/android/Rhodes/src/com/rhomobile/rhodes/PushService.java +6 -2
  111. data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhoMenu.java +7 -36
  112. data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesActivity.java +43 -20
  113. data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesApplication.java +2 -0
  114. data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesService.java +63 -28
  115. data/platform/android/Rhodes/src/com/rhomobile/rhodes/Utils.java +2 -2
  116. data/platform/android/Rhodes/src/com/rhomobile/rhodes/WebView.java +6 -2
  117. data/platform/android/Rhodes/src/com/rhomobile/rhodes/alert/Alert.java +19 -282
  118. data/platform/android/Rhodes/src/com/rhomobile/rhodes/alert/PopupActivity.java +354 -0
  119. data/platform/android/Rhodes/src/com/rhomobile/rhodes/datetime/DateTimePickerScreen.java +4 -0
  120. data/platform/android/Rhodes/src/com/rhomobile/rhodes/event/EventStore.java +1 -2
  121. data/platform/android/Rhodes/src/com/rhomobile/rhodes/file/RhoFileApi.java +71 -5
  122. data/platform/android/Rhodes/src/com/rhomobile/rhodes/geolocation/GeoLocationImpl.java +107 -37
  123. data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/SimpleMainView.java +10 -7
  124. data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/TabbedMainView.java +156 -56
  125. data/platform/android/Rhodes/src/com/rhomobile/rhodes/mapview/MapView.java +0 -1
  126. data/platform/android/Rhodes/src/com/rhomobile/rhodes/phonebook/ContactAccessorNew.java +40 -32
  127. data/platform/android/Rhodes/src/com/rhomobile/rhodes/signature/SignatureView.java +1 -0
  128. data/platform/android/Rhodes/src/com/rhomobile/rhodes/uri/ExternalHttpHandler.java +14 -6
  129. data/platform/android/Rhodes/src/com/rhomobile/rhodes/uri/LocalFileHandler.java +46 -0
  130. data/platform/android/Rhodes/src/com/rhomobile/rhodes/uri/MailUriHandler.java +4 -24
  131. data/platform/android/Rhodes/src/com/rhomobile/rhodes/uri/UriHandler.java +3 -1
  132. data/platform/android/build/RhodesSRC_build.files +28 -25
  133. data/platform/android/build/android.rake +230 -54
  134. data/platform/android/build/androidcommon.rb +1 -1
  135. data/platform/android/build/librhocommon_build.files +1 -0
  136. data/platform/bb/Hsqldb/BlackBerry_App_Descriptor.xml +20 -0
  137. data/platform/bb/Hsqldb/src/com/rho/db/HsqlDBResult.java +1 -5
  138. data/platform/bb/Hsqldb/src/com/rho/db/HsqlDBStorage.java +6 -1
  139. data/platform/bb/Hsqldb/src/org/hsqldb/rowio/RowOutputBase.java +1 -1
  140. data/platform/bb/Hsqldb/src/org/hsqldb/rowio/RowOutputBinary.java +1 -1
  141. data/platform/bb/RubyVM/BlackBerry_App_Descriptor.xml +20 -0
  142. data/platform/bb/RubyVM/src/com/rho/IRhoRubyHelper.java +2 -0
  143. data/platform/bb/RubyVM/src/com/rho/RhoLogOutputSink.java +0 -1
  144. data/platform/bb/RubyVM/src/com/rho/RhoLogger.java +12 -10
  145. data/platform/bb/RubyVM/src/com/rho/RhoThread.java +16 -0
  146. data/platform/bb/RubyVM/src/com/rho/RhoTimer.java +89 -0
  147. data/platform/bb/RubyVM/src/com/rho/RhodesApp.java +20 -13
  148. data/platform/bb/RubyVM/src/com/rho/SplashScreen.java +1 -2
  149. data/platform/bb/RubyVM/src/com/rho/ThreadQueue.java +2 -2
  150. data/platform/bb/RubyVM/src/com/rho/TimeInterval.java +5 -0
  151. data/platform/bb/RubyVM/src/com/rho/db/DBAdapter.java +54 -48
  152. data/platform/bb/RubyVM/src/com/rho/db/IDBResult.java +0 -1
  153. data/platform/bb/RubyVM/src/com/rho/db/IDBStorage.java +1 -0
  154. data/platform/bb/RubyVM/src/com/rho/net/AsyncHttp.java +1 -1
  155. data/platform/bb/RubyVM/src/com/rho/sync/ClientRegister.java +1 -1
  156. data/platform/bb/RubyVM/src/com/rho/sync/JSONStructIterator.java +1 -1
  157. data/platform/bb/RubyVM/src/com/rho/sync/SyncEngine.java +16 -8
  158. data/platform/bb/RubyVM/src/com/rho/sync/SyncNotify.java +2 -2
  159. data/platform/bb/RubyVM/src/com/rho/sync/SyncSource.java +52 -29
  160. data/platform/bb/RubyVM/src/com/rho/sync/SyncThread.java +1 -3
  161. data/platform/bb/build/RubyVM_build.files +1 -0
  162. data/platform/bb/build/bb.rake +29 -9
  163. data/platform/bb/rhodes/BlackBerry_App_Descriptor.xml +23 -0
  164. data/platform/bb/rhodes/platform/5.0/com/rho/RhodesApplicationPlatform.java +1 -1
  165. data/platform/bb/rhodes/platform/5.0/com/rho/db/SqliteCopyResult.java +0 -4
  166. data/platform/bb/rhodes/platform/5.0/com/rho/db/SqliteResult.java +13 -20
  167. data/platform/bb/rhodes/platform/5.0/com/rho/db/SqliteStorage.java +183 -157
  168. data/platform/bb/rhodes/src/com/rho/RhoRubyHelper.java +22 -0
  169. data/platform/bb/rhodes/src/com/rho/RhodesApplicationPlatform.java +1 -1
  170. data/platform/bb/rhodes/src/com/rho/db/SqliteCopyResult.java +0 -4
  171. data/platform/bb/rhodes/src/com/rho/db/SqliteResult.java +13 -20
  172. data/platform/bb/rhodes/src/com/rho/db/SqliteStorage.java +183 -157
  173. data/platform/bb/rhodes/src/com/rho/rubyext/System.java +46 -1
  174. data/platform/bb/rhodes/src/rhomobile/RhodesApplication.java +8 -1
  175. data/platform/bb/rhodes/src/rhomobile/camera/CameraFilesListener.java +13 -3
  176. data/platform/iphone/Classes/AppManager/AppManager.h +5 -1
  177. data/platform/iphone/Classes/AppManager/AppManager.m +170 -7
  178. data/platform/iphone/Classes/DateTimePicker.m +14 -1
  179. data/platform/iphone/Classes/DateTimePickerDelegate.h +2 -0
  180. data/platform/iphone/Classes/DateTimePickerDelegate.m +36 -2
  181. data/platform/iphone/Classes/NativeBar.h +1 -0
  182. data/platform/iphone/Classes/NativeBar.m +15 -3
  183. data/platform/iphone/Classes/Phonebook/phonebook.m +8 -9
  184. data/platform/iphone/Classes/Rhodes.m +50 -6
  185. data/platform/iphone/Classes/SimpleMainView.m +7 -6
  186. data/platform/iphone/Classes/SplitView/RightViewController.h +3 -1
  187. data/platform/iphone/Classes/SplitView/RightViewController.m +14 -1
  188. data/platform/iphone/Classes/TabbedMainView.h +4 -0
  189. data/platform/iphone/Classes/TabbedMainView.m +43 -26
  190. data/platform/iphone/Info.plist +1 -1
  191. data/platform/iphone/RhoLib/RhoLib.xcodeproj/project.pbxproj +4 -0
  192. data/platform/iphone/curl/curl.xcodeproj/project.pbxproj +3 -3
  193. data/platform/iphone/rbuild/iphone.rake +168 -119
  194. data/platform/iphone/rhoextlib/rhoextlib.xcodeproj/project.pbxproj +4 -2
  195. data/platform/iphone/rhorubylib/rhorubylib.xcodeproj/project.pbxproj +3 -3
  196. data/platform/iphone/rhorunner.xcodeproj/project.pbxproj +2 -2
  197. data/platform/iphone/rhosynclib/rhosynclib.xcodeproj/project.pbxproj +3 -3
  198. data/platform/shared/SyncClient/SyncClient.cpp +20 -8
  199. data/platform/shared/SyncClient/SyncClient.h +2 -1
  200. data/platform/shared/common/RhoDefs.h +4 -0
  201. data/platform/shared/common/RhoPort.h +22 -0
  202. data/platform/shared/common/RhoStd.h +5 -0
  203. data/platform/shared/common/RhoTime.cpp +73 -0
  204. data/platform/shared/common/RhoTime.h +26 -53
  205. data/platform/shared/common/RhodesApp.cpp +29 -28
  206. data/platform/shared/common/RhodesApp.h +4 -1
  207. data/platform/shared/common/StringConverter.h +37 -10
  208. data/platform/shared/common/app_build_capabilities.h +2 -0
  209. data/platform/shared/common/rhoparams.cpp +25 -12
  210. data/platform/shared/common/rhoparams.h +10 -8
  211. data/platform/shared/db/DBAdapter.cpp +0 -22
  212. data/platform/shared/json/RJSONTokener.c +15 -23
  213. data/platform/shared/net/AsyncHttp.cpp +9 -8
  214. data/platform/shared/net/HttpServer.cpp +61 -19
  215. data/platform/shared/net/HttpServer.h +2 -0
  216. data/platform/shared/ruby/ext/datetimepicker/datetimepicker.i +3 -0
  217. data/platform/shared/ruby/ext/datetimepicker/datetimepicker_wrap.c +151 -402
  218. data/platform/shared/ruby/ext/nativebar/nativebar.i +3 -0
  219. data/platform/shared/ruby/ext/nativebar/nativebar_wrap.c +154 -403
  220. data/platform/shared/ruby/ext/rho/rhoruby.c +4 -0
  221. data/platform/shared/ruby/ext/rho/rhoruby.h +2 -0
  222. data/platform/shared/ruby/ext/system/system.i +8 -0
  223. data/platform/shared/ruby/ext/system/system_wrap.c +80 -5
  224. data/platform/shared/ruby/file.c +6 -4
  225. data/platform/shared/ruby/gc.c +1 -1
  226. data/platform/shared/ruby/linux/ruby/config.h +7 -2
  227. data/platform/shared/ruby/missing/acosh.c +3 -3
  228. data/platform/shared/ruby/wince/_time.h +1 -1
  229. data/platform/shared/ruby/wince/stdlib.c +1 -1
  230. data/platform/shared/ruby/wince/string_wce.c +2 -2
  231. data/platform/shared/ruby/wince/sys/timeb.c +1 -0
  232. data/platform/shared/ruby/wince/time_wce.c +8 -0
  233. data/platform/shared/ruby/wince/wince.c +7 -7
  234. data/platform/shared/ruby/wince/wince.h +22 -0
  235. data/platform/shared/rubyext/System.cpp +19 -1
  236. data/platform/shared/sqlite/sqlite3.c +18993 -8129
  237. data/platform/shared/sqlite/sqlite3.h +953 -358
  238. data/platform/shared/sqlite/sqlite3ext.h +42 -0
  239. data/platform/shared/sync/SyncEngine.cpp +10 -0
  240. data/platform/shared/sync/SyncSource.cpp +41 -19
  241. data/platform/shared/sync/SyncSource.h +1 -1
  242. data/platform/shared/tcmalloc/rhomem.h +7 -2
  243. data/platform/shared/tcmalloc/windows/port.h +2 -0
  244. data/platform/shared/unzip/unzip.cpp +1 -0
  245. data/platform/shared/xruby/src/com/xruby/compiler/parser/RubyParser.java +11 -1
  246. data/platform/wm/RhoLib/RhoLib.vcproj +182 -24
  247. data/platform/wm/build/wm.rake +16 -3
  248. data/platform/wm/rhodes.sln +106 -113
  249. data/platform/wm/rhodes/Alert.cpp +6 -7
  250. data/platform/wm/rhodes/AppManager.cpp +8 -17
  251. data/platform/wm/rhodes/DateTimePicker.cpp +3 -0
  252. data/platform/wm/rhodes/DateTimePicker.h +2 -0
  253. data/platform/wm/rhodes/MainWindow.cpp +36 -16
  254. data/platform/wm/rhodes/MainWindow.h +6 -3
  255. data/platform/wm/rhodes/OutlookApp.cpp +3 -3
  256. data/platform/wm/rhodes/Rhodes.cpp +46 -27
  257. data/platform/wm/rhodes/Rhodes.rc +16 -3
  258. data/platform/wm/rhodes/RingtoneManager.cpp +7 -7
  259. data/platform/wm/rhodes/RingtoneManager.h +1 -1
  260. data/platform/wm/rhodes/Utils.cpp +2 -1
  261. data/platform/wm/rhodes/bluetooth/Bluetooth.cpp +1 -13
  262. data/platform/wm/rhodes/bluetooth/Bluetooth.h +1 -2
  263. data/platform/wm/rhodes/camera/Camera.cpp +6 -12
  264. data/platform/wm/rhodes/phonebook/phonebook.cpp +11 -11
  265. data/platform/wm/rhodes/phonebook/phonebook.h +1 -1
  266. data/platform/wm/rhodes/resource.h +3 -1
  267. data/platform/wm/rhodes/rho/net/NetRequestImpl.cpp +7 -5
  268. data/platform/wm/rhodes/rho/rubyext/GeoLocationImpl.cpp +6 -6
  269. data/platform/wm/rhodes/rho/rubyext/GeoLocationImpl.h +1 -1
  270. data/platform/wm/rhodes/rho/rubyext/NativeToolbar.cpp +6 -1
  271. data/platform/wm/rhodes/rho/rubyext/SystemImpl.cpp +84 -19
  272. data/platform/wm/rhodes/rho/rubyext/calendar.cpp +2 -2
  273. data/platform/wm/rhodes/rhodes.vcproj +316 -73
  274. data/platform/wm/rhodes/signature/Signature.cpp +336 -6
  275. data/platform/wm/rhodes/signature/Signature.h +55 -0
  276. data/platform/wm/rhodes/stdafx.h +7 -4
  277. data/platform/wm/rubylib/rubylib.vcproj +261 -91
  278. data/platform/wm/sqlite3/sqlite3.vcproj +223 -69
  279. data/platform/wm/syncengine/syncengine.vcproj +220 -66
  280. data/platform/wm/tcmalloc/tcmalloc.vcproj +197 -43
  281. data/platform/wp7/IronRuby/Languages/Ruby/Ruby/Builtins/ConsoleStream.cs +107 -0
  282. data/platform/wp7/IronRuby/Languages/Ruby/Ruby/Runtime/Loader.cs +1037 -0
  283. data/platform/wp7/IronRuby/Languages/Ruby/Ruby/Runtime/RubyUtils.cs +1476 -0
  284. data/platform/wp7/RhoAppRunner/Program.cs +55 -0
  285. data/platform/wp7/RhoAppRunner/Properties/AssemblyInfo.cs +36 -0
  286. data/platform/wp7/RhoAppRunner/RhoAppRunner.csproj +69 -0
  287. data/platform/wp7/RhoRubyExtGen/GenerateInitializers.cmd +7 -0
  288. data/platform/wp7/RhoRubyExtGen/Properties/AssemblyInfo.cs +36 -0
  289. data/platform/wp7/RhoRubyExtGen/RhoAsyncHttp.cs +38 -0
  290. data/platform/wp7/RhoRubyExtGen/RhoDatabase.cs +93 -0
  291. data/platform/wp7/RhoRubyExtGen/RhoJSON.cs +37 -0
  292. data/platform/wp7/RhoRubyExtGen/RhoNativeBar.cs +106 -0
  293. data/platform/wp7/RhoRubyExtGen/RhoRubyExtGen.csproj +75 -0
  294. data/platform/wp7/RhoRubyExtGen/RhoSyncEngine.cs +123 -0
  295. data/platform/wp7/RhoRubyExtGen/RhoWebView.cs +42 -0
  296. data/platform/wp7/RhoRubyLib/Initializers.Generated.cs +309 -0
  297. data/platform/wp7/RhoRubyLib/Properties/AssemblyInfo.cs +36 -0
  298. data/platform/wp7/RhoRubyLib/RhoAppAdapter.cs +96 -0
  299. data/platform/wp7/RhoRubyLib/RhoRuby.cs +296 -0
  300. data/platform/wp7/RhoRubyLib/RhoRubyLib.csproj +155 -0
  301. data/platform/wp7/RhoRubyLib/WP_PlatformAdaptationLayer.cs +107 -0
  302. data/platform/wp7/RhoRubyLib/common/IInputStream.cs +21 -0
  303. data/platform/wp7/RhoRubyLib/common/Mutex.cs +30 -0
  304. data/platform/wp7/RhoRubyLib/common/RhoConf.cs +389 -0
  305. data/platform/wp7/RhoRubyLib/common/RhoEmptyProfiler.cs +27 -0
  306. data/platform/wp7/RhoRubyLib/common/RhoFile.cs +332 -0
  307. data/platform/wp7/RhoRubyLib/common/RhoFilePath.cs +89 -0
  308. data/platform/wp7/RhoRubyLib/common/RhoParamArray.cs +33 -0
  309. data/platform/wp7/RhoRubyLib/common/RhoParams.cs +66 -0
  310. data/platform/wp7/RhoRubyLib/common/RhoProfiler.cs +145 -0
  311. data/platform/wp7/RhoRubyLib/common/RhoResourceMap.cs +68 -0
  312. data/platform/wp7/RhoRubyLib/common/RhoStd.cs +205 -0
  313. data/platform/wp7/RhoRubyLib/common/RhoThread.cs +114 -0
  314. data/platform/wp7/RhoRubyLib/common/RhodesApp.cs +504 -0
  315. data/platform/wp7/RhoRubyLib/common/ThreadQueue.cs +199 -0
  316. data/platform/wp7/RhoRubyLib/common/TimeInterval.cs +56 -0
  317. data/platform/wp7/RhoRubyLib/common/Tokenizer.cs +52 -0
  318. data/platform/wp7/RhoRubyLib/db/DBAdapter.cs +1129 -0
  319. data/platform/wp7/RhoRubyLib/db/DBAttrManager.cs +92 -0
  320. data/platform/wp7/RhoRubyLib/db/DBException.cs +35 -0
  321. data/platform/wp7/RhoRubyLib/db/IDBCallback.cs +10 -0
  322. data/platform/wp7/RhoRubyLib/db/IDBResult.cs +33 -0
  323. data/platform/wp7/RhoRubyLib/db/IDBStorage.cs +32 -0
  324. data/platform/wp7/RhoRubyLib/db/SqliteCopyResult.cs +79 -0
  325. data/platform/wp7/RhoRubyLib/db/SqliteResult.cs +267 -0
  326. data/platform/wp7/RhoRubyLib/db/SqliteStorage.cs +319 -0
  327. data/platform/wp7/RhoRubyLib/json/JSONArrayIterator.cs +63 -0
  328. data/platform/wp7/RhoRubyLib/json/JSONEntry.cs +96 -0
  329. data/platform/wp7/RhoRubyLib/json/JSONStructIterator.cs +77 -0
  330. data/platform/wp7/RhoRubyLib/json/JsonParser.cs +483 -0
  331. data/platform/wp7/RhoRubyLib/json/RJSONTokener.cs +406 -0
  332. data/platform/wp7/RhoRubyLib/logging/IRhoLogSink.cs +12 -0
  333. data/platform/wp7/RhoRubyLib/logging/RhoLogConf.cs +161 -0
  334. data/platform/wp7/RhoRubyLib/logging/RhoLogFileSink.cs +174 -0
  335. data/platform/wp7/RhoRubyLib/logging/RhoLogger.cs +320 -0
  336. data/platform/wp7/RhoRubyLib/net/AsyncHttp.cs +362 -0
  337. data/platform/wp7/RhoRubyLib/net/HttpServer.cs +466 -0
  338. data/platform/wp7/RhoRubyLib/net/NetRequest.cs +717 -0
  339. data/platform/wp7/RhoRubyLib/net/NetResponse.cs +64 -0
  340. data/platform/wp7/RhoRubyLib/net/URI.cs +187 -0
  341. data/platform/wp7/RhoRubyLib/rubyext/RhoAsyncHttp.cs +43 -0
  342. data/platform/wp7/RhoRubyLib/rubyext/RhoDatabase.cs +177 -0
  343. data/platform/wp7/RhoRubyLib/rubyext/RhoJSON.cs +39 -0
  344. data/platform/wp7/RhoRubyLib/rubyext/RhoKernelOps.cs +19 -0
  345. data/platform/wp7/RhoRubyLib/rubyext/RhoNativeBar.cs +117 -0
  346. data/platform/wp7/RhoRubyLib/rubyext/RhoSyncEngine.cs +199 -0
  347. data/platform/wp7/RhoRubyLib/rubyext/RhoWebView.cs +49 -0
  348. data/platform/wp7/RhoRubyLib/sync/ClientRegister.cs +142 -0
  349. data/platform/wp7/RhoRubyLib/sync/ISyncProtocol.cs +23 -0
  350. data/platform/wp7/RhoRubyLib/sync/ISyncStatusListener.cs +10 -0
  351. data/platform/wp7/RhoRubyLib/sync/SyncEngine.cs +1051 -0
  352. data/platform/wp7/RhoRubyLib/sync/SyncNotify.cs +651 -0
  353. data/platform/wp7/RhoRubyLib/sync/SyncProtocol_3.cs +79 -0
  354. data/platform/wp7/RhoRubyLib/sync/SyncSource.cs +1105 -0
  355. data/platform/wp7/RhoRubyLib/sync/SyncThread.cs +301 -0
  356. data/platform/wp7/WPApplication.sln +50 -0
  357. data/platform/wp7/WPApplication/App.xaml +19 -0
  358. data/platform/wp7/WPApplication/App.xaml.cs +211 -0
  359. data/platform/wp7/WPApplication/ApplicationIcon.png +0 -0
  360. data/platform/wp7/WPApplication/Background.png +0 -0
  361. data/platform/wp7/WPApplication/MainPage.xaml +44 -0
  362. data/platform/wp7/WPApplication/MainPage.xaml.cs +132 -0
  363. data/platform/wp7/WPApplication/Properties/AppManifest.xml +6 -0
  364. data/platform/wp7/WPApplication/Properties/AssemblyInfo.cs +35 -0
  365. data/platform/wp7/WPApplication/Properties/WMAppManifest.xml +32 -0
  366. data/platform/wp7/WPApplication/SplashScreenImage.jpg +0 -0
  367. data/platform/wp7/WPApplication/WPApplication.csproj +201 -0
  368. data/platform/wp7/WPApplication/WP_PlatformAdaptationLayer.cs +88 -0
  369. data/platform/wp7/WPApplication/app_manifest.txt +1 -0
  370. data/platform/wp7/WPApplication/readme.htm +40 -0
  371. data/platform/wp7/WPApplication/readme2.htm +37 -0
  372. data/platform/wp7/WPApplication/rho/apps/app/Model1/edit.bb.erb +29 -0
  373. data/platform/wp7/WPApplication/rho/apps/app/Model1/edit.erb +32 -0
  374. data/platform/wp7/WPApplication/rho/apps/app/Model1/index.bb.erb +21 -0
  375. data/platform/wp7/WPApplication/rho/apps/app/Model1/index.erb +26 -0
  376. data/platform/wp7/WPApplication/rho/apps/app/Model1/model1.rb +10 -0
  377. data/platform/wp7/WPApplication/rho/apps/app/Model1/model1_controller.rb +58 -0
  378. data/platform/wp7/WPApplication/rho/apps/app/Model1/new.bb.erb +29 -0
  379. data/platform/wp7/WPApplication/rho/apps/app/Model1/new.erb +31 -0
  380. data/platform/wp7/WPApplication/rho/apps/app/Model1/show.bb.erb +26 -0
  381. data/platform/wp7/WPApplication/rho/apps/app/Model1/show.erb +28 -0
  382. data/platform/wp7/WPApplication/rho/apps/app/Settings/controller.rb +75 -0
  383. data/platform/wp7/WPApplication/rho/apps/app/Settings/home.bb.erb +17 -0
  384. data/platform/wp7/WPApplication/rho/apps/app/Settings/home.erb +20 -0
  385. data/platform/wp7/WPApplication/rho/apps/app/Settings/index.bb.erb +32 -0
  386. data/platform/wp7/WPApplication/rho/apps/app/Settings/index.erb +30 -0
  387. data/platform/wp7/WPApplication/rho/apps/app/Settings/login.bb.erb +35 -0
  388. data/platform/wp7/WPApplication/rho/apps/app/Settings/login.erb +27 -0
  389. data/platform/wp7/WPApplication/rho/apps/app/Settings/reset.bb.erb +15 -0
  390. data/platform/wp7/WPApplication/rho/apps/app/Settings/reset.erb +17 -0
  391. data/platform/wp7/WPApplication/rho/apps/app/Settings/wait.bb.erb +3 -0
  392. data/platform/wp7/WPApplication/rho/apps/app/Settings/wait.erb +5 -0
  393. data/platform/wp7/WPApplication/rho/apps/app/application.rb +16 -0
  394. data/platform/wp7/WPApplication/rho/apps/app/helpers/application_helper.rb +126 -0
  395. data/platform/wp7/WPApplication/rho/apps/app/helpers/browser_helper.rb +18 -0
  396. data/platform/wp7/WPApplication/rho/apps/app/index.bb.erb +26 -0
  397. data/platform/wp7/WPApplication/rho/apps/app/index.erb +26 -0
  398. data/platform/wp7/WPApplication/rho/apps/app/layout.erb +45 -0
  399. data/platform/wp7/WPApplication/rho/apps/app/loading.html +11 -0
  400. data/platform/wp7/WPApplication/rho/apps/app_manifest.txt +1 -0
  401. data/platform/wp7/WPApplication/rho/apps/public/css/android.css +330 -0
  402. data/platform/wp7/WPApplication/rho/apps/public/css/blackberry.css +115 -0
  403. data/platform/wp7/WPApplication/rho/apps/public/css/iphone.css +410 -0
  404. data/platform/wp7/WPApplication/rho/apps/public/css/windows_mobile.css +222 -0
  405. data/platform/wp7/WPApplication/rho/apps/public/images/IUI_LICENSE.txt +21 -0
  406. data/platform/wp7/WPApplication/rho/apps/public/images/android/btn_check_off.png +0 -0
  407. data/platform/wp7/WPApplication/rho/apps/public/images/android/btn_check_on.png +0 -0
  408. data/platform/wp7/WPApplication/rho/apps/public/images/android/btn_radio_off.png +0 -0
  409. data/platform/wp7/WPApplication/rho/apps/public/images/android/btn_radio_on.png +0 -0
  410. data/platform/wp7/WPApplication/rho/apps/public/images/android/disclosure.png +0 -0
  411. data/platform/wp7/WPApplication/rho/apps/public/images/android/ic_menu_more.png +0 -0
  412. data/platform/wp7/WPApplication/rho/apps/public/images/backButton.png +0 -0
  413. data/platform/wp7/WPApplication/rho/apps/public/images/blueButton.png +0 -0
  414. data/platform/wp7/WPApplication/rho/apps/public/images/cancel.png +0 -0
  415. data/platform/wp7/WPApplication/rho/apps/public/images/grayButton.png +0 -0
  416. data/platform/wp7/WPApplication/rho/apps/public/images/iphone/disclosure.png +0 -0
  417. data/platform/wp7/WPApplication/rho/apps/public/images/iphone/disclosure_detail.png +0 -0
  418. data/platform/wp7/WPApplication/rho/apps/public/images/iphone/jqtouch/backButton.png +0 -0
  419. data/platform/wp7/WPApplication/rho/apps/public/images/iphone/jqtouch/blueButton.png +0 -0
  420. data/platform/wp7/WPApplication/rho/apps/public/images/iphone/jqtouch/cancel.png +0 -0
  421. data/platform/wp7/WPApplication/rho/apps/public/images/iphone/jqtouch/chevron.png +0 -0
  422. data/platform/wp7/WPApplication/rho/apps/public/images/iphone/jqtouch/grayButton.png +0 -0
  423. data/platform/wp7/WPApplication/rho/apps/public/images/iphone/jqtouch/listArrowSel.png +0 -0
  424. data/platform/wp7/WPApplication/rho/apps/public/images/iphone/jqtouch/listGroup.png +0 -0
  425. data/platform/wp7/WPApplication/rho/apps/public/images/iphone/jqtouch/loading.gif +0 -0
  426. data/platform/wp7/WPApplication/rho/apps/public/images/iphone/jqtouch/on_off.png +0 -0
  427. data/platform/wp7/WPApplication/rho/apps/public/images/iphone/jqtouch/pinstripes.png +0 -0
  428. data/platform/wp7/WPApplication/rho/apps/public/images/iphone/jqtouch/selection.png +0 -0
  429. data/platform/wp7/WPApplication/rho/apps/public/images/iphone/jqtouch/thumb.png +0 -0
  430. data/platform/wp7/WPApplication/rho/apps/public/images/iphone/jqtouch/toggle.png +0 -0
  431. data/platform/wp7/WPApplication/rho/apps/public/images/iphone/jqtouch/toggleOn.png +0 -0
  432. data/platform/wp7/WPApplication/rho/apps/public/images/iphone/jqtouch/toolButton.png +0 -0
  433. data/platform/wp7/WPApplication/rho/apps/public/images/iphone/jqtouch/toolbar.png +0 -0
  434. data/platform/wp7/WPApplication/rho/apps/public/images/iphone/jqtouch/whiteButton.png +0 -0
  435. data/platform/wp7/WPApplication/rho/apps/public/images/iphone/radiobutton.png +0 -0
  436. data/platform/wp7/WPApplication/rho/apps/public/images/iphone/select.png +0 -0
  437. data/platform/wp7/WPApplication/rho/apps/public/images/iphone/switch.png +0 -0
  438. data/platform/wp7/WPApplication/rho/apps/public/images/iui-logo-touch-icon.png +0 -0
  439. data/platform/wp7/WPApplication/rho/apps/public/images/listArrow.png +0 -0
  440. data/platform/wp7/WPApplication/rho/apps/public/images/listArrowDown.png +0 -0
  441. data/platform/wp7/WPApplication/rho/apps/public/images/listArrowSel.png +0 -0
  442. data/platform/wp7/WPApplication/rho/apps/public/images/listGroup.png +0 -0
  443. data/platform/wp7/WPApplication/rho/apps/public/images/loading.gif +0 -0
  444. data/platform/wp7/WPApplication/rho/apps/public/images/pinstripes.png +0 -0
  445. data/platform/wp7/WPApplication/rho/apps/public/images/right_button.png +0 -0
  446. data/platform/wp7/WPApplication/rho/apps/public/images/selection.png +0 -0
  447. data/platform/wp7/WPApplication/rho/apps/public/images/thumb.png +0 -0
  448. data/platform/wp7/WPApplication/rho/apps/public/images/toggle.png +0 -0
  449. data/platform/wp7/WPApplication/rho/apps/public/images/toggleOn.png +0 -0
  450. data/platform/wp7/WPApplication/rho/apps/public/images/toolButton.png +0 -0
  451. data/platform/wp7/WPApplication/rho/apps/public/images/toolButton_new.png +0 -0
  452. data/platform/wp7/WPApplication/rho/apps/public/images/toolbar.png +0 -0
  453. data/platform/wp7/WPApplication/rho/apps/public/images/whiteButton.png +0 -0
  454. data/platform/wp7/WPApplication/rho/apps/public/jqtouch/jqtouch-iphone.css +9 -0
  455. data/platform/wp7/WPApplication/rho/apps/public/jqtouch/jqtouch.css +374 -0
  456. data/platform/wp7/WPApplication/rho/apps/public/jqtouch/jqtouch.js +742 -0
  457. data/platform/wp7/WPApplication/rho/apps/public/jqtouch/jqtouch.transitions.js +60 -0
  458. data/platform/wp7/WPApplication/rho/apps/public/jqtouch/jquery.1.3.2.min.js +19 -0
  459. data/platform/wp7/WPApplication/rho/apps/public/js/application.js +1 -0
  460. data/platform/wp7/WPApplication/rho/apps/public/js/rho.js +4 -0
  461. data/platform/wp7/WPApplication/rho/apps/public/js/rhogeolocation-wm.js +59 -0
  462. data/platform/wp7/WPApplication/rho/apps/public/js/rhogeolocation.js +11 -0
  463. data/platform/wp7/WPApplication/rho/apps/rhoconfig.txt +32 -0
  464. data/platform/wp7/WPApplication/rhoconfig.txt +32 -0
  465. data/platform/wp7/WPApplication/windows_mobile.css +222 -0
  466. data/platform/wp7/build/wp.rake +261 -0
  467. data/platform/wp7/rhodes.sln +79 -0
  468. data/platform/wp7/rhodes/App.xaml +19 -0
  469. data/platform/wp7/rhodes/App.xaml.cs +144 -0
  470. data/platform/wp7/rhodes/Background.png +0 -0
  471. data/platform/wp7/rhodes/MainPage.xaml +44 -0
  472. data/platform/wp7/rhodes/MainPage.xaml.cs +98 -0
  473. data/platform/wp7/rhodes/Properties/AppManifest.xml +6 -0
  474. data/platform/wp7/rhodes/Properties/AssemblyInfo.cs +35 -0
  475. data/platform/wp7/rhodes/Properties/WMAppManifest.xml +31 -0
  476. data/platform/wp7/rhodes/Rhodes.csproj +127 -0
  477. data/platform/wp7/rhodes/SplashScreenImage.jpg +0 -0
  478. data/platform/wp7/rhodes/icon.png +0 -0
  479. data/platform/wp7/sqlite3/Properties/AssemblyInfo.cs +35 -0
  480. data/platform/wp7/sqlite3/SQLiteClient.cs +550 -0
  481. data/platform/wp7/sqlite3/SqliteWrapper/BtreeInt_h.cs +774 -0
  482. data/platform/wp7/sqlite3/SqliteWrapper/Btree_h.cs +280 -0
  483. data/platform/wp7/sqlite3/SqliteWrapper/ClassDiagram1.cd +1306 -0
  484. data/platform/wp7/sqlite3/SqliteWrapper/Delagates.cs +365 -0
  485. data/platform/wp7/sqlite3/SqliteWrapper/Hash_h.cs +133 -0
  486. data/platform/wp7/sqlite3/SqliteWrapper/VdbeInt_h.cs +620 -0
  487. data/platform/wp7/sqlite3/SqliteWrapper/Vdbe_h.cs +302 -0
  488. data/platform/wp7/sqlite3/SqliteWrapper/_Custom.cs +449 -0
  489. data/platform/wp7/sqlite3/SqliteWrapper/alter_c.cs +872 -0
  490. data/platform/wp7/sqlite3/SqliteWrapper/analyze_c.cs +757 -0
  491. data/platform/wp7/sqlite3/SqliteWrapper/attach_c.cs +628 -0
  492. data/platform/wp7/sqlite3/SqliteWrapper/auth_c.cs +268 -0
  493. data/platform/wp7/sqlite3/SqliteWrapper/backup_c.cs +737 -0
  494. data/platform/wp7/sqlite3/SqliteWrapper/bitvec_c.cs +509 -0
  495. data/platform/wp7/sqlite3/SqliteWrapper/btmutex_c.cs +379 -0
  496. data/platform/wp7/sqlite3/SqliteWrapper/btree_c.cs +9138 -0
  497. data/platform/wp7/sqlite3/SqliteWrapper/build_c.cs +4189 -0
  498. data/platform/wp7/sqlite3/SqliteWrapper/callback_c.cs +548 -0
  499. data/platform/wp7/sqlite3/SqliteWrapper/complete_c.cs +342 -0
  500. data/platform/wp7/sqlite3/SqliteWrapper/ctime_cs.cs +408 -0
  501. data/platform/wp7/sqlite3/SqliteWrapper/date_c.cs +1317 -0
  502. data/platform/wp7/sqlite3/SqliteWrapper/delete_c.cs +726 -0
  503. data/platform/wp7/sqlite3/SqliteWrapper/expr_c.cs +4406 -0
  504. data/platform/wp7/sqlite3/SqliteWrapper/fault_c.cs +115 -0
  505. data/platform/wp7/sqlite3/SqliteWrapper/fkey_c.cs +1330 -0
  506. data/platform/wp7/sqlite3/SqliteWrapper/func_c.cs +2025 -0
  507. data/platform/wp7/sqlite3/SqliteWrapper/global_c.cs +228 -0
  508. data/platform/wp7/sqlite3/SqliteWrapper/hash_c.cs +351 -0
  509. data/platform/wp7/sqlite3/SqliteWrapper/hwtime_c.cs +101 -0
  510. data/platform/wp7/sqlite3/SqliteWrapper/insert_c.cs +2122 -0
  511. data/platform/wp7/sqlite3/SqliteWrapper/journal_c.cs +247 -0
  512. data/platform/wp7/sqlite3/SqliteWrapper/keywordhash_h.cs +302 -0
  513. data/platform/wp7/sqlite3/SqliteWrapper/legacy_c.cs +223 -0
  514. data/platform/wp7/sqlite3/SqliteWrapper/loadext_c.cs +683 -0
  515. data/platform/wp7/sqlite3/SqliteWrapper/main_c.cs +2716 -0
  516. data/platform/wp7/sqlite3/SqliteWrapper/malloc_c.cs +977 -0
  517. data/platform/wp7/sqlite3/SqliteWrapper/mem_Pool.cs +394 -0
  518. data/platform/wp7/sqlite3/SqliteWrapper/memjournal_c.cs +315 -0
  519. data/platform/wp7/sqlite3/SqliteWrapper/mutex_c.cs +182 -0
  520. data/platform/wp7/sqlite3/SqliteWrapper/mutex_h.cs +91 -0
  521. data/platform/wp7/sqlite3/SqliteWrapper/mutex_noop_c.cs +202 -0
  522. data/platform/wp7/sqlite3/SqliteWrapper/mutex_w32.cs +344 -0
  523. data/platform/wp7/sqlite3/SqliteWrapper/notify_c.cs +347 -0
  524. data/platform/wp7/sqlite3/SqliteWrapper/opcodes_c.cs +171 -0
  525. data/platform/wp7/sqlite3/SqliteWrapper/opcodes_h.cs +346 -0
  526. data/platform/wp7/sqlite3/SqliteWrapper/os_c.cs +367 -0
  527. data/platform/wp7/sqlite3/SqliteWrapper/os_common_h.cs +174 -0
  528. data/platform/wp7/sqlite3/SqliteWrapper/os_h.cs +295 -0
  529. data/platform/wp7/sqlite3/SqliteWrapper/os_win_c.cs +1255 -0
  530. data/platform/wp7/sqlite3/SqliteWrapper/pager_c.cs +6078 -0
  531. data/platform/wp7/sqlite3/SqliteWrapper/pager_h.cs +188 -0
  532. data/platform/wp7/sqlite3/SqliteWrapper/parse_c.cs +4045 -0
  533. data/platform/wp7/sqlite3/SqliteWrapper/parse_h.cs +331 -0
  534. data/platform/wp7/sqlite3/SqliteWrapper/pcache1_c.cs +969 -0
  535. data/platform/wp7/sqlite3/SqliteWrapper/pcache_c.cs +712 -0
  536. data/platform/wp7/sqlite3/SqliteWrapper/pcache_h.cs +213 -0
  537. data/platform/wp7/sqlite3/SqliteWrapper/pragma_c.cs +1767 -0
  538. data/platform/wp7/sqlite3/SqliteWrapper/prepare_c.cs +1015 -0
  539. data/platform/wp7/sqlite3/SqliteWrapper/printf_c.cs +1300 -0
  540. data/platform/wp7/sqlite3/SqliteWrapper/random_c.cs +201 -0
  541. data/platform/wp7/sqlite3/SqliteWrapper/resolve_c.cs +1396 -0
  542. data/platform/wp7/sqlite3/SqliteWrapper/rowset_c.cs +519 -0
  543. data/platform/wp7/sqlite3/SqliteWrapper/select_c.cs +4878 -0
  544. data/platform/wp7/sqlite3/SqliteWrapper/sqlite3_h.cs +6253 -0
  545. data/platform/wp7/sqlite3/SqliteWrapper/sqlite3ext_h.cs +397 -0
  546. data/platform/wp7/sqlite3/SqliteWrapper/sqliteInt_h.cs +4075 -0
  547. data/platform/wp7/sqlite3/SqliteWrapper/sqliteLimit_h.cs +214 -0
  548. data/platform/wp7/sqlite3/SqliteWrapper/sqliteicu_h.cs +39 -0
  549. data/platform/wp7/sqlite3/SqliteWrapper/status_c.cs +155 -0
  550. data/platform/wp7/sqlite3/SqliteWrapper/table_c.cs +222 -0
  551. data/platform/wp7/sqlite3/SqliteWrapper/tokenize_c.cs +673 -0
  552. data/platform/wp7/sqlite3/SqliteWrapper/trigger_c.cs +1219 -0
  553. data/platform/wp7/sqlite3/SqliteWrapper/update_c.cs +766 -0
  554. data/platform/wp7/sqlite3/SqliteWrapper/utf_c.cs +612 -0
  555. data/platform/wp7/sqlite3/SqliteWrapper/util_c.cs +1476 -0
  556. data/platform/wp7/sqlite3/SqliteWrapper/vacuum_c.cs +382 -0
  557. data/platform/wp7/sqlite3/SqliteWrapper/vdbe_c.cs +6566 -0
  558. data/platform/wp7/sqlite3/SqliteWrapper/vdbeapi_c.cs +1557 -0
  559. data/platform/wp7/sqlite3/SqliteWrapper/vdbeaux_c.cs +4019 -0
  560. data/platform/wp7/sqlite3/SqliteWrapper/vdbeblob_c.cs +396 -0
  561. data/platform/wp7/sqlite3/SqliteWrapper/vdbemem_c.cs +1480 -0
  562. data/platform/wp7/sqlite3/SqliteWrapper/vdbetrace_c.cs +181 -0
  563. data/platform/wp7/sqlite3/SqliteWrapper/vtab_c.cs +957 -0
  564. data/platform/wp7/sqlite3/SqliteWrapper/walker_c.cs +174 -0
  565. data/platform/wp7/sqlite3/SqliteWrapper/where_c.cs +4651 -0
  566. data/platform/wp7/sqlite3/sqlite3.csproj +155 -0
  567. data/rakefile.rb +60 -2
  568. data/res/build-tools/7za.exe +0 -0
  569. data/res/build-tools/RhoAppRunner.exe +0 -0
  570. data/res/build-tools/xruby-0.3.3.jar +0 -0
  571. data/res/generators/rhogen.rb +9 -1
  572. data/res/generators/templates/application/app/Settings/reset.erb +1 -1
  573. data/res/generators/templates/application/app/layout.erb +17 -10
  574. data/res/generators/templates/application/build.yml +5 -3
  575. data/res/generators/templates/application/public/jqtouch/changes.txt +20 -0
  576. data/res/generators/templates/application/public/jqtouch/jqtouch.js +12 -4
  577. data/res/generators/templates/application/public/jqtouch/jquery.1.3.2.min.js +1 -1
  578. data/res/generators/templates/application/public/js/wp7.js +7 -0
  579. data/res/generators/templates/model/controller.rb +5 -6
  580. data/rhobuild.yml.example +1 -0
  581. data/rhodes.gemspec +2 -1
  582. data/spec/framework_spec/app/spec/core/dir/close_spec.rb +1 -1
  583. data/spec/framework_spec/app/spec/core/dir/shared/pwd.rb +13 -11
  584. data/spec/framework_spec/app/spec/core/env/shared/store.rb +12 -10
  585. data/spec/framework_spec/app/spec/core/env/update_spec.rb +1 -0
  586. data/spec/framework_spec/app/spec/core/file/expand_path_spec.rb +3 -2
  587. data/spec/framework_spec/app/spec/core/file/fixtures/file_types.rb +7 -1
  588. data/spec/framework_spec/app/spec/core/file/flock_spec.rb +8 -1
  589. data/spec/framework_spec/app/spec/core/file/ftype_spec.rb +5 -3
  590. data/spec/framework_spec/app/spec/core/file/lchmod_spec.rb +1 -1
  591. data/spec/framework_spec/app/spec/core/file/setgid_spec.rb +1 -1
  592. data/spec/framework_spec/app/spec/core/file/setuid_spec.rb +1 -1
  593. data/spec/framework_spec/app/spec/core/file/stat/ftype_spec.rb +6 -4
  594. data/spec/framework_spec/app/spec/core/file/truncate_spec.rb +5 -1
  595. data/spec/framework_spec/app/spec/core/float/to_s_spec.rb +1 -1
  596. data/spec/framework_spec/app/spec/core/process/gid_spec.rb +5 -3
  597. data/spec/framework_spec/app/spec/core/process/groups_spec.rb +11 -9
  598. data/spec/framework_spec/app/spec/core/process/uid_spec.rb +5 -3
  599. data/spec/framework_spec/app/spec/language/execution_spec.rb +10 -6
  600. data/spec/framework_spec/app/spec/shared/file/directory.rb +6 -1
  601. data/spec/framework_spec/app/spec/shared/file/executable.rb +7 -1
  602. data/spec/framework_spec/app/spec/shared/file/file.rb +6 -1
  603. data/spec/framework_spec/app/spec/shared/file/readable.rb +13 -4
  604. data/spec/framework_spec/app/spec/shared/file/writable.rb +6 -1
  605. data/spec/phone_spec/app/spec/rho_controller_spec.rb +11 -0
  606. data/spec/phone_spec/app/spec/rho_spec.rb +11 -0
  607. data/spec/phone_spec/app/spec/rhom_object_spec.rb +102 -6
  608. data/spec/phone_spec/app/spec/string/end_with_spec.rb +4 -1
  609. data/spec/phone_spec/app/spec/string/slice_spec.rb +5 -1
  610. data/spec/phone_spec/app/spec/string/start_with_spec.rb +4 -0
  611. data/spec/phone_spec/app/spec/syncengine_spec.rb +73 -6
  612. data/spec/phone_spec/app/spec_runner.rb +7 -3
  613. metadata +380 -41
  614. data/Manifest.txt +0 -5819
  615. data/platform/bb/Hsqldb/Hsqldb.cso +0 -5
  616. data/platform/bb/Hsqldb/Hsqldb.jdp +0 -197
  617. data/platform/bb/RhoBundle/RhoBundle.cso +0 -5
  618. data/platform/bb/RhoBundle/RhoBundle.jdp +0 -42
  619. data/platform/bb/RubyVM/RubyVM.cso +0 -5
  620. data/platform/bb/RubyVM/RubyVM.jdp +0 -467
  621. data/platform/bb/rhodes/rhodes.csl +0 -3
  622. data/platform/bb/rhodes/rhodes.cso +0 -5
  623. data/platform/bb/rhodes/rhodes.jdp +0 -104
@@ -0,0 +1,2716 @@
1
+ using System;
2
+ using System.Diagnostics;
3
+ using System.Text;
4
+
5
+ using sqlite_int64 = System.Int64;
6
+ using unsigned = System.Int32;
7
+
8
+ using i16 = System.Int16;
9
+ using u8 = System.Byte;
10
+ using u16 = System.UInt16;
11
+ using u32 = System.UInt32;
12
+ using u64 = System.UInt64;
13
+
14
+ using Pgno = System.UInt32;
15
+
16
+ namespace Community.CsharpSqlite
17
+ {
18
+ using sqlite3_value = Sqlite3.Mem;
19
+
20
+ public partial class Sqlite3
21
+ {
22
+ /*
23
+ ** 2001 September 15
24
+ **
25
+ ** The author disclaims copyright to this source code. In place of
26
+ ** a legal notice, here is a blessing:
27
+ **
28
+ ** May you do good and not evil.
29
+ ** May you find forgiveness for yourself and forgive others.
30
+ ** May you share freely, never taking more than you give.
31
+ **
32
+ *************************************************************************
33
+ ** Main file for the SQLite library. The routines in this file
34
+ ** implement the programmer interface to the library. Routines in
35
+ ** other files are for internal use by SQLite and should not be
36
+ ** accessed by users of the library.
37
+ *************************************************************************
38
+ ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart
39
+ ** C#-SQLite is an independent reimplementation of the SQLite software library
40
+ **
41
+ ** SQLITE_SOURCE_ID: 2010-03-09 19:31:43 4ae453ea7be69018d8c16eb8dabe05617397dc4d
42
+ **
43
+ ** $Header$
44
+ *************************************************************************
45
+ */
46
+ //#include "sqliteInt.h"
47
+ #if SQLITE_ENABLE_FTS3
48
+ //# include "fts3.h"
49
+ #endif
50
+ #if SQLITE_ENABLE_RTREE
51
+ //# include "rtree.h"
52
+ #endif
53
+ #if SQLITE_ENABLE_ICU
54
+ //# include "sqliteicu.h"
55
+ #endif
56
+
57
+ /*
58
+ ** The version of the library
59
+ */
60
+ #if !SQLITE_AMALGAMATION
61
+ public static string sqlite3_version = SQLITE_VERSION;
62
+ #endif
63
+ public static string sqlite3_libversion() { return sqlite3_version; }
64
+ public static string sqlite3_sourceid() { return SQLITE_SOURCE_ID; }
65
+ public static int sqlite3_libversion_number() { return SQLITE_VERSION_NUMBER; }
66
+ public static int sqlite3_threadsafe() { return SQLITE_THREADSAFE; }
67
+
68
+ #if !SQLITE_OMIT_TRACE && SQLITE_ENABLE_IOTRACE
69
+ /*
70
+ ** If the following function pointer is not NULL and if
71
+ ** SQLITE_ENABLE_IOTRACE is enabled, then messages describing
72
+ ** I/O active are written using this function. These messages
73
+ ** are intended for debugging activity only.
74
+ */
75
+ //void (*sqlite3IoTrace)(const char*, ...) = 0;
76
+ static void sqlite3IoTrace( string X, params object[] ap ) { }
77
+ #endif
78
+
79
+ /*
80
+ ** If the following global variable points to a string which is the
81
+ ** name of a directory, then that directory will be used to store
82
+ ** temporary files.
83
+ **
84
+ ** See also the "PRAGMA temp_store_directory" SQL command.
85
+ */
86
+ static string sqlite3_temp_directory = "";//char *sqlite3_temp_directory = 0;
87
+
88
+ /*
89
+ ** Initialize SQLite.
90
+ **
91
+ ** This routine must be called to initialize the memory allocation,
92
+ ** VFS, and mutex subsystems prior to doing any serious work with
93
+ ** SQLite. But as long as you do not compile with SQLITE_OMIT_AUTOINIT
94
+ ** this routine will be called automatically by key routines such as
95
+ ** sqlite3_open().
96
+ **
97
+ ** This routine is a no-op except on its very first call for the process,
98
+ ** or for the first call after a call to sqlite3_shutdown.
99
+ **
100
+ ** The first thread to call this routine runs the initialization to
101
+ ** completion. If subsequent threads call this routine before the first
102
+ ** thread has finished the initialization process, then the subsequent
103
+ ** threads must block until the first thread finishes with the initialization.
104
+ **
105
+ ** The first thread might call this routine recursively. Recursive
106
+ ** calls to this routine should not block, of course. Otherwise the
107
+ ** initialization process would never complete.
108
+ **
109
+ ** Let X be the first thread to enter this routine. Let Y be some other
110
+ ** thread. Then while the initial invocation of this routine by X is
111
+ ** incomplete, it is required that:
112
+ **
113
+ ** * Calls to this routine from Y must block until the outer-most
114
+ ** call by X completes.
115
+ **
116
+ ** * Recursive calls to this routine from thread X return immediately
117
+ ** without blocking.
118
+ */
119
+ static int sqlite3_initialize()
120
+ {
121
+ //--------------------------------------------------------------------
122
+ // Under C#, Need to initialize some static variables
123
+ //
124
+ if ( sqlite3_version == null ) sqlite3_version = SQLITE_VERSION;
125
+ if ( sqlite3OpcodeProperty == null ) sqlite3OpcodeProperty = OPFLG_INITIALIZER;
126
+ if ( sqlite3GlobalConfig == null ) sqlite3GlobalConfig = sqlite3Config;
127
+ if ( UpperToLower == null ) UpperToLower = sqlite3UpperToLower;
128
+ //--------------------------------------------------------------------
129
+
130
+
131
+ sqlite3_mutex pMaster; /* The main static mutex */
132
+ int rc; /* Result code */
133
+
134
+ #if SQLITE_OMIT_WSD
135
+ rc = sqlite3_wsd_init(4096, 24);
136
+ if( rc!=SQLITE_OK ){
137
+ return rc;
138
+ }
139
+ #endif
140
+ /* If SQLite is already completely initialized, then this call
141
+ ** to sqlite3_initialize() should be a no-op. But the initialization
142
+ ** must be complete. So isInit must not be set until the very end
143
+ ** of this routine.
144
+ */
145
+ if ( sqlite3GlobalConfig.isInit != 0 ) return SQLITE_OK;
146
+
147
+ /* Make sure the mutex subsystem is initialized. If unable to
148
+ ** initialize the mutex subsystem, return early with the error.
149
+ ** If the system is so sick that we are unable to allocate a mutex,
150
+ ** there is not much SQLite is going to be able to do.
151
+ **
152
+ ** The mutex subsystem must take care of serializing its own
153
+ ** initialization.
154
+ */
155
+ rc = sqlite3MutexInit();
156
+ if ( rc != 0 ) return rc;
157
+
158
+ /* Initialize the malloc() system and the recursive pInitMutex mutex.
159
+ ** This operation is protected by the STATIC_MASTER mutex. Note that
160
+ ** MutexAlloc() is called for a static mutex prior to initializing the
161
+ ** malloc subsystem - this implies that the allocation of a static
162
+ ** mutex must not require support from the malloc subsystem.
163
+ */
164
+ pMaster = sqlite3MutexAlloc( SQLITE_MUTEX_STATIC_MASTER );
165
+ sqlite3_mutex_enter( pMaster );
166
+ sqlite3GlobalConfig.isMutexInit = 1;
167
+ if ( sqlite3GlobalConfig.isMallocInit == 0 )
168
+ {
169
+ rc = sqlite3MallocInit();
170
+ }
171
+ if ( rc == SQLITE_OK )
172
+ {
173
+ sqlite3GlobalConfig.isMallocInit = 1;
174
+ if ( sqlite3GlobalConfig.pInitMutex == null )
175
+ {
176
+ sqlite3GlobalConfig.pInitMutex =
177
+ sqlite3MutexAlloc( SQLITE_MUTEX_RECURSIVE );
178
+ if ( sqlite3GlobalConfig.bCoreMutex && sqlite3GlobalConfig.pInitMutex == null )
179
+ {
180
+ rc = SQLITE_NOMEM;
181
+ }
182
+ }
183
+ }
184
+ if ( rc == SQLITE_OK )
185
+ {
186
+ sqlite3GlobalConfig.nRefInitMutex++;
187
+ }
188
+ sqlite3_mutex_leave( pMaster );
189
+ /* If rc is not SQLITE_OK at this point, then either the malloc
190
+ ** subsystem could not be initialized or the system failed to allocate
191
+ ** the pInitMutex mutex. Return an error in either case. */
192
+ if ( rc != SQLITE_OK )
193
+ {
194
+ return rc;
195
+ }
196
+
197
+ /* Do the rest of the initialization under the recursive mutex so
198
+ ** that we will be able to handle recursive calls into
199
+ ** sqlite3_initialize(). The recursive calls normally come through
200
+ ** sqlite3_os_init() when it invokes sqlite3_vfs_register(), but other
201
+ ** recursive calls might also be possible.
202
+ */
203
+ sqlite3_mutex_enter( sqlite3GlobalConfig.pInitMutex );
204
+ if ( sqlite3GlobalConfig.isInit == 0 && sqlite3GlobalConfig.inProgress == 0 )
205
+ {
206
+ sqlite3GlobalConfig.inProgress = 1;
207
+ #if SQLITE_OMIT_WSD
208
+ FuncDefHash *pHash = &GLOBAL(FuncDefHash, sqlite3GlobalFunctions);
209
+ memset( pHash, 0, sizeof( sqlite3GlobalFunctions ) );
210
+ #else
211
+ sqlite3GlobalFunctions = new FuncDefHash();
212
+ FuncDefHash pHash = sqlite3GlobalFunctions;
213
+ #endif
214
+ sqlite3RegisterGlobalFunctions();
215
+ if ( sqlite3GlobalConfig.isPCacheInit == 0 )
216
+ {
217
+ rc = sqlite3PcacheInitialize();
218
+ }
219
+ if ( rc == SQLITE_OK )
220
+ {
221
+ sqlite3GlobalConfig.isPCacheInit = 1;
222
+ rc = sqlite3_os_init();
223
+ }
224
+ if ( rc == SQLITE_OK )
225
+ {
226
+ sqlite3PCacheBufferSetup( sqlite3GlobalConfig.pPage,
227
+ sqlite3GlobalConfig.szPage, sqlite3GlobalConfig.nPage );
228
+ sqlite3GlobalConfig.isInit = 1;
229
+ }
230
+ sqlite3GlobalConfig.inProgress = 0;
231
+ }
232
+ sqlite3_mutex_leave( sqlite3GlobalConfig.pInitMutex );
233
+ /* Go back under the static mutex and clean up the recursive
234
+ ** mutex to prevent a resource leak.
235
+ */
236
+ sqlite3_mutex_enter( pMaster );
237
+ sqlite3GlobalConfig.nRefInitMutex--;
238
+ if ( sqlite3GlobalConfig.nRefInitMutex <= 0 )
239
+ {
240
+ Debug.Assert( sqlite3GlobalConfig.nRefInitMutex == 0 );
241
+ sqlite3_mutex_free( ref sqlite3GlobalConfig.pInitMutex );
242
+ sqlite3GlobalConfig.pInitMutex = null;
243
+ }
244
+ sqlite3_mutex_leave( pMaster );
245
+
246
+ /* The following is just a sanity check to make sure SQLite has
247
+ ** been compiled correctly. It is important to run this code, but
248
+ ** we don't want to run it too often and soak up CPU cycles for no
249
+ ** reason. So we run it once during initialization.
250
+ */
251
+ #if !NDEBUG
252
+ #if !SQLITE_OMIT_FLOATING_POINT
253
+ /* This section of code's only "output" is via Debug.Assert() statements. */
254
+ if ( rc == SQLITE_OK )
255
+ {
256
+ //u64 x = ( ( (u64)1 ) << 63 ) - 1;
257
+ //double y;
258
+ //Debug.Assert( sizeof( u64 ) == 8 );
259
+ //Debug.Assert( sizeof( u64 ) == sizeof( double ) );
260
+ //memcpy( &y, x, 8 );
261
+ //Debug.Assert( sqlite3IsNaN( y ) );
262
+ }
263
+ #endif
264
+ #endif
265
+
266
+ return rc;
267
+ }
268
+
269
+ /*
270
+ ** Undo the effects of sqlite3_initialize(). Must not be called while
271
+ ** there are outstanding database connections or memory allocations or
272
+ ** while any part of SQLite is otherwise in use in any thread. This
273
+ ** routine is not threadsafe. But it is safe to invoke this routine
274
+ ** on when SQLite is already shut down. If SQLite is already shut down
275
+ ** when this routine is invoked, then this routine is a harmless no-op.
276
+ */
277
+ public static int sqlite3_shutdown()
278
+ {
279
+ if ( sqlite3GlobalConfig.isInit != 0 )
280
+ {
281
+ sqlite3_os_end();
282
+ sqlite3_reset_auto_extension();
283
+ sqlite3GlobalConfig.isInit = 0;
284
+ }
285
+ if ( sqlite3GlobalConfig.isPCacheInit != 0 )
286
+ {
287
+ sqlite3PcacheShutdown();
288
+ sqlite3GlobalConfig.isPCacheInit = 0;
289
+ }
290
+ if ( sqlite3GlobalConfig.isMallocInit != 0 )
291
+ {
292
+ sqlite3MallocEnd();
293
+ sqlite3GlobalConfig.isMallocInit = 0;
294
+ }
295
+ if ( sqlite3GlobalConfig.isMutexInit != 0 )
296
+ {
297
+ sqlite3MutexEnd();
298
+ sqlite3GlobalConfig.isMutexInit = 0;
299
+ }
300
+ return SQLITE_OK;
301
+ }
302
+
303
+ /*
304
+ ** This API allows applications to modify the global configuration of
305
+ ** the SQLite library at run-time.
306
+ **
307
+ ** This routine should only be called when there are no outstanding
308
+ ** database connections or memory allocations. This routine is not
309
+ ** threadsafe. Failure to heed these warnings can lead to unpredictable
310
+ ** behavior.
311
+ */
312
+ // Overloads for ap assignments
313
+ static int sqlite3_config( int op, sqlite3_pcache_methods ap )
314
+ { // va_list ap;
315
+ int rc = SQLITE_OK;
316
+ switch ( op )
317
+ {
318
+ case SQLITE_CONFIG_PCACHE:
319
+ {
320
+ /* Specify an alternative malloc implementation */
321
+ sqlite3GlobalConfig.pcache = ap; //sqlite3GlobalConfig.pcache = (sqlite3_pcache_methods)va_arg(ap, "sqlite3_pcache_methods");
322
+ break;
323
+ }
324
+ }
325
+ return rc;
326
+ }
327
+
328
+ static int sqlite3_config( int op, ref sqlite3_pcache_methods ap )
329
+ { // va_list ap;
330
+ int rc = SQLITE_OK;
331
+ switch ( op )
332
+ {
333
+ case SQLITE_CONFIG_GETPCACHE:
334
+ {
335
+ if ( sqlite3GlobalConfig.pcache.xInit == null )
336
+ {
337
+ sqlite3PCacheSetDefault();
338
+ }
339
+ ap = sqlite3GlobalConfig.pcache;//va_arg(ap, sqlite3_pcache_methods*) = sqlite3GlobalConfig.pcache;
340
+ break;
341
+ }
342
+ }
343
+ return rc;
344
+ }
345
+
346
+ static int sqlite3_config( int op, sqlite3_mem_methods ap )
347
+ { // va_list ap;
348
+ int rc = SQLITE_OK;
349
+ switch ( op )
350
+ {
351
+ case SQLITE_CONFIG_MALLOC:
352
+ {
353
+ /* Specify an alternative malloc implementation */
354
+ sqlite3GlobalConfig.m = ap;// (sqlite3_mem_methods)va_arg( ap, "sqlite3_mem_methods" );
355
+ break;
356
+ }
357
+ }
358
+ return rc;
359
+ }
360
+
361
+ static int sqlite3_config( int op, ref sqlite3_mem_methods ap )
362
+ { // va_list ap;
363
+ int rc = SQLITE_OK;
364
+ switch ( op )
365
+ {
366
+ case SQLITE_CONFIG_GETMALLOC:
367
+ {
368
+ /* Retrieve the current malloc() implementation */
369
+ //if ( sqlite3GlobalConfig.m.xMalloc == null ) sqlite3MemSetDefault();
370
+ ap = sqlite3GlobalConfig.m;//va_arg(ap, sqlite3_mem_methods*) = sqlite3GlobalConfig.m;
371
+ break;
372
+ }
373
+ }
374
+ return rc;
375
+ }
376
+
377
+ #if SQLITE_THREADSAFE // && SQLITE_THREADSAFE>0
378
+ static int sqlite3_config( int op, sqlite3_mutex_methods ap )
379
+ {
380
+ // va_list ap;
381
+ int rc = SQLITE_OK;
382
+ switch ( op )
383
+ {
384
+ case SQLITE_CONFIG_MUTEX:
385
+ {
386
+ /* Specify an alternative mutex implementation */
387
+ sqlite3GlobalConfig.mutex = ap;// (sqlite3_mutex_methods)va_arg( ap, "sqlite3_mutex_methods" );
388
+ break;
389
+ }
390
+ }
391
+ return rc;
392
+ }
393
+
394
+ static int sqlite3_config( int op, ref sqlite3_mutex_methods ap )
395
+ {
396
+ // va_list ap;
397
+ int rc = SQLITE_OK;
398
+ switch ( op )
399
+ {
400
+ case SQLITE_CONFIG_GETMUTEX:
401
+ {
402
+ /* Retrieve the current mutex implementation */
403
+ ap = sqlite3GlobalConfig.mutex;// *va_arg(ap, sqlite3_mutex_methods*) = sqlite3GlobalConfig.mutex;
404
+ break;
405
+ }
406
+ }
407
+ return rc;
408
+ }
409
+ #endif
410
+
411
+ static int sqlite3_config( int op, params object[] ap )
412
+ {
413
+ // va_list ap;
414
+ int rc = SQLITE_OK;
415
+
416
+ /* sqlite3_config() shall return SQLITE_MISUSE if it is invoked while
417
+ ** the SQLite library is in use. */
418
+ if (sqlite3GlobalConfig.isInit != 0) return SQLITE_MISUSE_BKPT();
419
+
420
+ va_start( ap, null );
421
+ switch ( op )
422
+ {
423
+
424
+ /* Mutex configuration options are only available in a threadsafe
425
+ ** compile.
426
+ */
427
+ #if SQLITE_THREADSAFE
428
+ case SQLITE_CONFIG_SINGLETHREAD:
429
+ {
430
+ /* Disable all mutexing */
431
+ sqlite3GlobalConfig.bCoreMutex = false;
432
+ sqlite3GlobalConfig.bFullMutex = false;
433
+ break;
434
+ }
435
+ case SQLITE_CONFIG_MULTITHREAD:
436
+ {
437
+ /* Disable mutexing of database connections */
438
+ /* Enable mutexing of core data structures */
439
+ sqlite3GlobalConfig.bCoreMutex = true;
440
+ sqlite3GlobalConfig.bFullMutex = false;
441
+ break;
442
+ }
443
+ case SQLITE_CONFIG_SERIALIZED:
444
+ {
445
+ /* Enable all mutexing */
446
+ sqlite3GlobalConfig.bCoreMutex = true;
447
+ sqlite3GlobalConfig.bFullMutex = true;
448
+ break;
449
+ }
450
+ case SQLITE_CONFIG_MUTEX: {
451
+ /* Specify an alternative mutex implementation */
452
+ sqlite3GlobalConfig.mutex = *va_arg(ap, sqlite3_mutex_methods*);
453
+ break;
454
+ }
455
+ case SQLITE_CONFIG_GETMUTEX: {
456
+ /* Retrieve the current mutex implementation */
457
+ *va_arg(ap, sqlite3_mutex_methods*) = sqlite3GlobalConfig.mutex;
458
+ break;
459
+ }
460
+ #endif
461
+ case SQLITE_CONFIG_MALLOC:
462
+ {
463
+ Debugger.Break(); // TODO --
464
+ /* Specify an alternative malloc implementation */
465
+ sqlite3GlobalConfig.m = (sqlite3_mem_methods)va_arg( ap, "sqlite3_mem_methods" );
466
+ break;
467
+ }
468
+ case SQLITE_CONFIG_GETMALLOC:
469
+ {
470
+ /* Retrieve the current malloc() implementation */
471
+ //if ( sqlite3GlobalConfig.m.xMalloc == null ) sqlite3MemSetDefault();
472
+ //Debugger.Break(); // TODO --//va_arg(ap, sqlite3_mem_methods*) = sqlite3GlobalConfig.m;
473
+ break;
474
+ }
475
+ case SQLITE_CONFIG_MEMSTATUS:
476
+ {
477
+ /* Enable or disable the malloc status collection */
478
+ sqlite3GlobalConfig.bMemstat = (int)va_arg( ap, "int" ) != 0;
479
+ break;
480
+ }
481
+ case SQLITE_CONFIG_SCRATCH:
482
+ {
483
+ /* Designate a buffer for scratch memory space */
484
+ sqlite3GlobalConfig.pScratch = (byte[][])va_arg( ap, "byte[][]" );
485
+ sqlite3GlobalConfig.szScratch = (int)va_arg( ap, "int" );
486
+ sqlite3GlobalConfig.nScratch = (int)va_arg( ap, "int" );
487
+ break;
488
+ }
489
+
490
+ case SQLITE_CONFIG_PAGECACHE:
491
+ {
492
+ /* Designate a buffer for page cache memory space */
493
+ sqlite3GlobalConfig.pPage = (MemPage)va_arg( ap, "MemPage" );
494
+ sqlite3GlobalConfig.szPage = (int)va_arg( ap, "int" );
495
+ sqlite3GlobalConfig.nPage = (int)va_arg( ap, "int" );
496
+ break;
497
+ }
498
+
499
+ case SQLITE_CONFIG_PCACHE:
500
+ {
501
+ /* Specify an alternative page cache implementation */
502
+ Debugger.Break(); // TODO --sqlite3GlobalConfig.pcache = (sqlite3_pcache_methods)va_arg(ap, "sqlite3_pcache_methods");
503
+ break;
504
+ }
505
+
506
+ case SQLITE_CONFIG_GETPCACHE:
507
+ {
508
+ if ( sqlite3GlobalConfig.pcache.xInit == null )
509
+ {
510
+ sqlite3PCacheSetDefault();
511
+ }
512
+ Debugger.Break(); // TODO -- *va_arg(ap, sqlite3_pcache_methods*) = sqlite3GlobalConfig.pcache;
513
+ break;
514
+ }
515
+
516
+ #if SQLITE_ENABLE_MEMSYS3 || SQLITE_ENABLE_MEMSYS5
517
+ case SQLITE_CONFIG_HEAP: {
518
+ /* Designate a buffer for heap memory space */
519
+ sqlite3GlobalConfig.pHeap = va_arg(ap, void*);
520
+ sqlite3GlobalConfig.nHeap = va_arg(ap, int);
521
+ sqlite3GlobalConfig.mnReq = va_arg(ap, int);
522
+
523
+ if( sqlite3GlobalConfig.pHeap==0 ){
524
+ /* If the heap pointer is NULL, then restore the malloc implementation
525
+ ** back to NULL pointers too. This will cause the malloc to go
526
+ ** back to its default implementation when sqlite3_initialize() is
527
+ ** run.
528
+ */
529
+ memset(& sqlite3GlobalConfig.m, 0, sizeof( sqlite3GlobalConfig.m));
530
+ }else{
531
+ /* The heap pointer is not NULL, then install one of the
532
+ ** mem5.c/mem3.c methods. If neither ENABLE_MEMSYS3 nor
533
+ ** ENABLE_MEMSYS5 is defined, return an error.
534
+ */
535
+ #if SQLITE_ENABLE_MEMSYS3
536
+ sqlite3GlobalConfig.m = *sqlite3MemGetMemsys3();
537
+ #endif
538
+ #if SQLITE_ENABLE_MEMSYS5
539
+ sqlite3GlobalConfig.m = *sqlite3MemGetMemsys5();
540
+ #endif
541
+ }
542
+ break;
543
+ }
544
+ #endif
545
+
546
+ case SQLITE_CONFIG_LOOKASIDE:
547
+ {
548
+ sqlite3GlobalConfig.szLookaside = (int)va_arg( ap, "int" );
549
+ sqlite3GlobalConfig.nLookaside = (int)va_arg( ap, "int" );
550
+ break;
551
+ }
552
+
553
+ /* Record a pointer to the logger funcction and its first argument.
554
+ ** The default is NULL. Logging is disabled if the function pointer is
555
+ ** NULL.
556
+ */
557
+ case SQLITE_CONFIG_LOG: {
558
+ /* MSVC is picky about pulling func ptrs from va lists.
559
+ ** http://support.microsoft.com/kb/47961
560
+ ** sqlite3GlobalConfig.xLog = va_arg(ap, void(*)(void*,int,const char*));
561
+ */
562
+ //typedef void(*LOGFUNC_t)(void*,int,const char*);
563
+ sqlite3GlobalConfig.xLog = (dxLog)va_arg(ap, "LOGFUNC_t");
564
+ sqlite3GlobalConfig.pLogArg = va_arg(ap, "void*");
565
+ break;
566
+ }
567
+ default:
568
+ {
569
+ rc = SQLITE_ERROR;
570
+ break;
571
+ }
572
+ }
573
+ va_end( ap );
574
+ return rc;
575
+ }
576
+
577
+ /*
578
+ ** Set up the lookaside buffers for a database connection.
579
+ ** Return SQLITE_OK on success.
580
+ ** If lookaside is already active, return SQLITE_BUSY.
581
+ **
582
+ ** The sz parameter is the number of bytes in each lookaside slot.
583
+ ** The cnt parameter is the number of slots. If pStart is NULL the
584
+ ** space for the lookaside memory is obtained from sqlite3_malloc().
585
+ ** If pStart is not NULL then it is sz*cnt bytes of memory to use for
586
+ ** the lookaside memory.
587
+ */
588
+ static int setupLookaside( sqlite3 db, byte[] pBuf, int sz, int cnt )
589
+ {
590
+ //void* pStart;
591
+ //if ( db.lookaside.nOut )
592
+ //{
593
+ // return SQLITE_BUSY;
594
+ //}
595
+ ///* Free any existing lookaside buffer for this handle before
596
+ //** allocating a new one so we don't have to have space for
597
+ //** both at the same time.
598
+ //*/
599
+ //if ( db.lookaside.bMalloced )
600
+ //{
601
+ // //sqlite3_free( db.lookaside.pStart );
602
+ //}
603
+ ///* The size of a lookaside slot needs to be larger than a pointer
604
+ //** to be useful.
605
+ //*/
606
+ //if ( sz <= (int)sizeof( LookasideSlot* ) ) sz = 0;
607
+ //if ( cnt < 0 ) cnt = 0;
608
+ //if ( sz == 0 || cnt == 0 )
609
+ //{
610
+ // sz = 0;
611
+ // pStart = 0;
612
+ //}
613
+ //else if ( pBuf == 0 )
614
+ //{
615
+ // sz = ROUND8(sz);
616
+ // sqlite3BeginBenignMalloc();
617
+ // pStart = sqlite3Malloc( sz * cnt );
618
+ // sqlite3EndBenignMalloc();
619
+ //}
620
+ //else
621
+ //{
622
+ // ROUNDDOWN8(sz);
623
+ // pStart = pBuf;
624
+ //}
625
+ //db.lookaside.pStart = pStart;
626
+ //db.lookaside.pFree = 0;
627
+ //db.lookaside.sz = (u16)sz;
628
+ //if ( pStart )
629
+ //{
630
+ // int i;
631
+ // LookasideSlot* p;
632
+ // Debug.Assert( sz > sizeof( LookasideSlot* ) );
633
+ // p = (LookasideSlot*)pStart;
634
+ // for ( i = cnt - 1 ; i >= 0 ; i-- )
635
+ // {
636
+ // p.pNext = db.lookaside.pFree;
637
+ // db.lookaside.pFree = p;
638
+ // p = (LookasideSlot*)&( (u8*)p )[sz];
639
+ // }
640
+ // db.lookaside.pEnd = p;
641
+ // db.lookaside.bEnabled = 1;
642
+ // db.lookaside.bMalloced = pBuf == 0 ? 1 : 0;
643
+ //}
644
+ //else
645
+ //{
646
+ // db.lookaside.pEnd = 0;
647
+ // db.lookaside.bEnabled = 0;
648
+ // db.lookaside.bMalloced = 0;
649
+ //}
650
+ return SQLITE_OK;
651
+ }
652
+
653
+ /*
654
+ ** Return the mutex associated with a database connection.
655
+ */
656
+ sqlite3_mutex sqlite3_db_mutex( sqlite3 db )
657
+ {
658
+ return db.mutex;
659
+ }
660
+
661
+ /*
662
+ ** Configuration settings for an individual database connection
663
+ */
664
+ static int sqlite3_db_config( sqlite3 db, int op, params object[] ap )
665
+ {
666
+ //va_list ap;
667
+ int rc;
668
+ va_start( ap, "" );
669
+ switch ( op )
670
+ {
671
+ case SQLITE_DBCONFIG_LOOKASIDE:
672
+ {
673
+ byte[] pBuf = (byte[])va_arg( ap, "byte[]" );
674
+ int sz = (int)va_arg( ap, "int" );
675
+ int cnt = (int)va_arg( ap, "int" );
676
+ rc = setupLookaside( db, pBuf, sz, cnt );
677
+ break;
678
+ }
679
+ default:
680
+ {
681
+ rc = SQLITE_ERROR;
682
+ break;
683
+ }
684
+ }
685
+ va_end( ap );
686
+ return rc;
687
+ }
688
+
689
+
690
+ /*
691
+ ** Return true if the buffer z[0..n-1] contains all spaces.
692
+ */
693
+ static bool allSpaces( string z, int iStart, int n )
694
+ {
695
+ while ( n > 0 && z[iStart + n - 1] == ' ' ) { n--; }
696
+ return n == 0;
697
+ }
698
+
699
+ /*
700
+ ** This is the default collating function named "BINARY" which is always
701
+ ** available.
702
+ **
703
+ ** If the padFlag argument is not NULL then space padding at the end
704
+ ** of strings is ignored. This implements the RTRIM collation.
705
+ */
706
+ static int binCollFunc(
707
+ object padFlag,
708
+ int nKey1, string pKey1,
709
+ int nKey2, string pKey2
710
+ )
711
+ {
712
+ int rc, n;
713
+ n = nKey1 < nKey2 ? nKey1 : nKey2;
714
+ rc = memcmp( pKey1, pKey2, n );
715
+ if ( rc == 0 )
716
+ {
717
+ if ( (int)padFlag != 0 && allSpaces( pKey1, n, nKey1 - n ) && allSpaces( pKey2, n, nKey2 - n ) )
718
+ {
719
+ /* Leave rc unchanged at 0 */
720
+ }
721
+ else
722
+ {
723
+ rc = nKey1 - nKey2;
724
+ }
725
+ }
726
+ return rc;
727
+ }
728
+
729
+ /*
730
+ ** Another built-in collating sequence: NOCASE.
731
+ **
732
+ ** This collating sequence is intended to be used for "case independant
733
+ ** comparison". SQLite's knowledge of upper and lower case equivalents
734
+ ** extends only to the 26 characters used in the English language.
735
+ **
736
+ ** At the moment there is only a UTF-8 implementation.
737
+ */
738
+ static int nocaseCollatingFunc(
739
+ object NotUsed,
740
+ int nKey1, string pKey1,
741
+ int nKey2, string pKey2
742
+ )
743
+ {
744
+ int n = ( nKey1 < nKey2 ) ? nKey1 : nKey2;
745
+ int r = sqlite3StrNICmp( pKey1, pKey2, ( nKey1 < nKey2 ) ? nKey1 : nKey2 );
746
+ UNUSED_PARAMETER( NotUsed );
747
+ if ( 0 == r )
748
+ {
749
+ r = nKey1 - nKey2;
750
+ }
751
+ return r;
752
+ }
753
+
754
+ /*
755
+ ** Return the ROWID of the most recent insert
756
+ */
757
+ static public sqlite_int64 sqlite3_last_insert_rowid( sqlite3 db )
758
+ {
759
+ return db.lastRowid;
760
+ }
761
+
762
+ /*
763
+ ** Return the number of changes in the most recent call to sqlite3_exec().
764
+ */
765
+ static public int sqlite3_changes( sqlite3 db )
766
+ {
767
+ return db.nChange;
768
+ }
769
+
770
+ /*
771
+ ** Return the number of changes since the database handle was opened.
772
+ */
773
+ static public int sqlite3_total_changes( sqlite3 db )
774
+ {
775
+ return db.nTotalChange;
776
+ }
777
+
778
+ /*
779
+ ** Close all open savepoints. This function only manipulates fields of the
780
+ ** database handle object, it does not close any savepoints that may be open
781
+ ** at the b-tree/pager level.
782
+ */
783
+ static void sqlite3CloseSavepoints( sqlite3 db )
784
+ {
785
+ while ( db.pSavepoint != null )
786
+ {
787
+ Savepoint pTmp = db.pSavepoint;
788
+ db.pSavepoint = pTmp.pNext;
789
+ sqlite3DbFree( db, ref pTmp );
790
+ }
791
+ db.nSavepoint = 0;
792
+ db.nStatement = 0;
793
+ db.isTransactionSavepoint = 0;
794
+ }
795
+
796
+ /*
797
+ ** Close an existing SQLite database
798
+ */
799
+ public static int sqlite3_close( sqlite3 db )
800
+ {
801
+ HashElem i;
802
+ int j;
803
+
804
+ if ( db == null )
805
+ {
806
+ return SQLITE_OK;
807
+ }
808
+ if ( !sqlite3SafetyCheckSickOrOk( db ) )
809
+ {
810
+ return SQLITE_MISUSE_BKPT();
811
+ }
812
+ sqlite3_mutex_enter( db.mutex );
813
+
814
+ sqlite3ResetInternalSchema( db, 0 );
815
+
816
+ /* Tell the code in notify.c that the connection no longer holds any
817
+ ** locks and does not require any further unlock-notify callbacks.
818
+ */
819
+ sqlite3ConnectionClosed( db );
820
+
821
+ /* If a transaction is open, the ResetInternalSchema() call above
822
+ ** will not have called the xDisconnect() method on any virtual
823
+ ** tables in the db.aVTrans[] array. The following sqlite3VtabRollback()
824
+ ** call will do so. We need to do this before the check for active
825
+ ** SQL statements below, as the v-table implementation may be storing
826
+ ** some prepared statements internally.
827
+ */
828
+
829
+ sqlite3VtabRollback( db );
830
+
831
+ /* If there are any outstanding VMs, return SQLITE_BUSY. */
832
+ if ( db.pVdbe != null )
833
+ {
834
+ sqlite3Error( db, SQLITE_BUSY,
835
+ "unable to close due to unfinalised statements" );
836
+ sqlite3_mutex_leave( db.mutex );
837
+ return SQLITE_BUSY;
838
+ }
839
+ Debug.Assert( sqlite3SafetyCheckSickOrOk( db ) );
840
+
841
+ for ( j = 0; j < db.nDb; j++ )
842
+ {
843
+ Btree pBt = db.aDb[j].pBt;
844
+ if ( pBt != null && sqlite3BtreeIsInBackup( pBt ) )
845
+ {
846
+ sqlite3Error( db, SQLITE_BUSY,
847
+ "unable to close due to unfinished backup operation" );
848
+ sqlite3_mutex_leave( db.mutex );
849
+ return SQLITE_BUSY;
850
+ }
851
+ }
852
+
853
+ /* Free any outstanding Savepoint structures. */
854
+ sqlite3CloseSavepoints( db );
855
+
856
+ for ( j = 0; j < db.nDb; j++ )
857
+ {
858
+ Db pDb = db.aDb[j];
859
+ if ( pDb.pBt != null )
860
+ {
861
+ sqlite3BtreeClose( ref pDb.pBt );
862
+ pDb.pBt = null;
863
+ if ( j != 1 )
864
+ {
865
+ pDb.pSchema = null;
866
+ }
867
+ }
868
+ }
869
+ sqlite3ResetInternalSchema( db, 0 );
870
+ Debug.Assert( db.nDb <= 2 );
871
+ Debug.Assert( db.aDb[0].Equals( db.aDbStatic[0] ) );
872
+ for ( j = 0; j < ArraySize( db.aFunc.a ); j++ )
873
+ {
874
+ FuncDef pNext, pHash, p;
875
+ for ( p = db.aFunc.a[j]; p != null; p = pHash )
876
+ {
877
+ pHash = p.pHash;
878
+ while ( p != null )
879
+ {
880
+ pNext = p.pNext;
881
+ sqlite3DbFree( db, ref p );
882
+ p = pNext;
883
+ }
884
+
885
+ }
886
+ }
887
+
888
+ for ( i = db.aCollSeq.first; i != null; i = i.next )
889
+ {//sqliteHashFirst(db.aCollSeq); i!=null; i=sqliteHashNext(i)){
890
+ CollSeq[] pColl = (CollSeq[])i.data;// sqliteHashData(i);
891
+ /* Invoke any destructors registered for collation sequence user data. */
892
+ for ( j = 0; j < 3; j++ )
893
+ {
894
+ if ( pColl[j].xDel != null )
895
+ {
896
+ pColl[j].xDel( ref pColl[j].pUser );
897
+ }
898
+ }
899
+ sqlite3DbFree( db, ref pColl );
900
+ }
901
+ sqlite3HashClear( db.aCollSeq );
902
+ #if !SQLITE_OMIT_VIRTUALTABLE
903
+ for(i=sqliteHashFirst(&db.aModule); i; i=sqliteHashNext(i)){
904
+ Module pMod = (Module *)sqliteHashData(i);
905
+ if( pMod.xDestroy ){
906
+ pMod.xDestroy(pMod.pAux);
907
+ }
908
+ sqlite3DbFree(db,ref pMod);
909
+ }
910
+ sqlite3HashClear(&db.aModule);
911
+ #endif
912
+
913
+ sqlite3Error( db, SQLITE_OK, 0 ); /* Deallocates any cached error strings. */
914
+ if ( db.pErr != null )
915
+ {
916
+ sqlite3ValueFree( ref db.pErr );
917
+ }
918
+ #if !SQLITE_OMIT_LOAD_EXTENSION
919
+ sqlite3CloseExtensions( db );
920
+ #endif
921
+
922
+ db.magic = SQLITE_MAGIC_ERROR;
923
+
924
+ /* The temp.database schema is allocated differently from the other schema
925
+ ** objects (using sqliteMalloc() directly, instead of sqlite3BtreeSchema()).
926
+ ** So it needs to be freed here. Todo: Why not roll the temp schema into
927
+ ** the same sqliteMalloc() as the one that allocates the database
928
+ ** structure?
929
+ */
930
+ sqlite3DbFree( db, ref db.aDb[1].pSchema );
931
+ sqlite3_mutex_leave( db.mutex );
932
+ db.magic = SQLITE_MAGIC_CLOSED;
933
+ sqlite3_mutex_free( ref db.mutex );
934
+ Debug.Assert( db.lookaside.nOut == 0 ); /* Fails on a lookaside memory leak */
935
+ //if ( db.lookaside.bMalloced )
936
+ //{
937
+ // sqlite3_free( ref db.lookaside.pStart );
938
+ //}
939
+ //sqlite3_free( ref db );
940
+ return SQLITE_OK;
941
+ }
942
+
943
+ /*
944
+ ** Rollback all database files.
945
+ */
946
+ static void sqlite3RollbackAll( sqlite3 db )
947
+ {
948
+ int i;
949
+ int inTrans = 0;
950
+ Debug.Assert( sqlite3_mutex_held( db.mutex ) );
951
+ sqlite3BeginBenignMalloc();
952
+ for ( i = 0; i < db.nDb; i++ )
953
+ {
954
+ if ( db.aDb[i].pBt != null )
955
+ {
956
+ if ( sqlite3BtreeIsInTrans( db.aDb[i].pBt ) )
957
+ {
958
+ inTrans = 1;
959
+ }
960
+ sqlite3BtreeRollback( db.aDb[i].pBt );
961
+ db.aDb[i].inTrans = 0;
962
+ }
963
+ }
964
+
965
+ sqlite3VtabRollback( db );
966
+ sqlite3EndBenignMalloc();
967
+ if ( ( db.flags & SQLITE_InternChanges ) != 0 )
968
+ {
969
+ sqlite3ExpirePreparedStatements( db );
970
+ sqlite3ResetInternalSchema( db, 0 );
971
+ }
972
+
973
+ /* Any deferred constraint violations have now been resolved. */
974
+ db.nDeferredCons = 0;
975
+
976
+ /* If one has been configured, invoke the rollback-hook callback */
977
+ if ( db.xRollbackCallback != null && ( inTrans != 0 || 0 == db.autoCommit ) )
978
+ {
979
+ db.xRollbackCallback( db.pRollbackArg );
980
+ }
981
+ }
982
+
983
+ /*
984
+ ** Return a static string that describes the kind of error specified in the
985
+ ** argument.
986
+ */
987
+ static string sqlite3ErrStr( int rc )
988
+ {
989
+ string[] aMsg = new string[]{
990
+ /* SQLITE_OK */ "not an error",
991
+ /* SQLITE_ERROR */ "SQL logic error or missing database",
992
+ /* SQLITE_INTERNAL */ "",
993
+ /* SQLITE_PERM */ "access permission denied",
994
+ /* SQLITE_ABORT */ "callback requested query abort",
995
+ /* SQLITE_BUSY */ "database is locked",
996
+ /* SQLITE_LOCKED */ "database table is locked",
997
+ /* SQLITE_NOMEM */ "out of memory",
998
+ /* SQLITE_READONLY */ "attempt to write a readonly database",
999
+ /* SQLITE_INTERRUPT */ "interrupted",
1000
+ /* SQLITE_IOERR */ "disk I/O error",
1001
+ /* SQLITE_CORRUPT */ "database disk image is malformed",
1002
+ /* SQLITE_NOTFOUND */ "",
1003
+ /* SQLITE_FULL */ "database or disk is full",
1004
+ /* SQLITE_CANTOPEN */ "unable to open database file",
1005
+ /* SQLITE_PROTOCOL */ "",
1006
+ /* SQLITE_EMPTY */ "table contains no data",
1007
+ /* SQLITE_SCHEMA */ "database schema has changed",
1008
+ /* SQLITE_TOOBIG */ "string or blob too big",
1009
+ /* SQLITE_CONSTRAINT */ "constraint failed",
1010
+ /* SQLITE_MISMATCH */ "datatype mismatch",
1011
+ /* SQLITE_MISUSE */ "library routine called out of sequence",
1012
+ /* SQLITE_NOLFS */ "large file support is disabled",
1013
+ /* SQLITE_AUTH */ "authorization denied",
1014
+ /* SQLITE_FORMAT */ "auxiliary database format error",
1015
+ /* SQLITE_RANGE */ "bind or column index out of range",
1016
+ /* SQLITE_NOTADB */ "file is encrypted or is not a database",
1017
+ };
1018
+ rc &= 0xff;
1019
+ if ( ALWAYS( rc >= 0 ) && rc < aMsg.Length && aMsg[rc] != "" )//(int)(sizeof(aMsg)/sizeof(aMsg[0]))
1020
+ {
1021
+ return aMsg[rc];
1022
+ }
1023
+ else
1024
+ {
1025
+ return "unknown error";
1026
+ }
1027
+ }
1028
+
1029
+ /*
1030
+ ** This routine implements a busy callback that sleeps and tries
1031
+ ** again until a timeout value is reached. The timeout value is
1032
+ ** an integer number of milliseconds passed in as the first
1033
+ ** argument.
1034
+ */
1035
+ static int sqliteDefaultBusyCallback(
1036
+ object ptr, /* Database connection */
1037
+ int count /* Number of times table has been busy */
1038
+ )
1039
+ {
1040
+ #if SQLITE_OS_WIN || HAVE_USLEEP
1041
+ u8[] delays = new u8[] { 1, 2, 5, 10, 15, 20, 25, 25, 25, 50, 50, 100 };
1042
+ u8[] totals = new u8[] { 0, 1, 3, 8, 18, 33, 53, 78, 103, 128, 178, 228 };
1043
+ //# define NDELAY (delays.Length/sizeof(delays[0]))
1044
+ int NDELAY = delays.Length;
1045
+ sqlite3 db = (sqlite3)ptr;
1046
+ int timeout = db.busyTimeout;
1047
+ int delay, prior;
1048
+
1049
+ Debug.Assert( count >= 0 );
1050
+ if ( count < NDELAY )
1051
+ {
1052
+ delay = delays[count];
1053
+ prior = totals[count];
1054
+ }
1055
+ else
1056
+ {
1057
+ delay = delays[NDELAY - 1];
1058
+ prior = totals[NDELAY - 1] + delay * ( count - ( NDELAY - 1 ) );
1059
+ }
1060
+ if ( prior + delay > timeout )
1061
+ {
1062
+ delay = timeout - prior;
1063
+ if ( delay <= 0 ) return 0;
1064
+ }
1065
+ sqlite3OsSleep( db.pVfs, delay * 1000 );
1066
+ return 1;
1067
+ #else
1068
+ sqlite3 db = (sqlite3)ptr;
1069
+ int timeout = ( (sqlite3)ptr ).busyTimeout;
1070
+ if ( ( count + 1 ) * 1000 > timeout )
1071
+ {
1072
+ return 0;
1073
+ }
1074
+ sqlite3OsSleep( db.pVfs, 1000000 );
1075
+ return 1;
1076
+ #endif
1077
+ }
1078
+
1079
+ /*
1080
+ ** Invoke the given busy handler.
1081
+ **
1082
+ ** This routine is called when an operation failed with a lock.
1083
+ ** If this routine returns non-zero, the lock is retried. If it
1084
+ ** returns 0, the operation aborts with an SQLITE_BUSY error.
1085
+ */
1086
+ static int sqlite3InvokeBusyHandler( BusyHandler p )
1087
+ {
1088
+ int rc;
1089
+ if ( NEVER( p == null ) || p.xFunc == null || p.nBusy < 0 ) return 0;
1090
+ rc = p.xFunc( p.pArg, p.nBusy );
1091
+ if ( rc == 0 )
1092
+ {
1093
+ p.nBusy = -1;
1094
+ }
1095
+ else
1096
+ {
1097
+ p.nBusy++;
1098
+ }
1099
+ return rc;
1100
+ }
1101
+
1102
+ /*
1103
+ ** This routine sets the busy callback for an Sqlite database to the
1104
+ ** given callback function with the given argument.
1105
+ */
1106
+ static int sqlite3_busy_handler(
1107
+ sqlite3 db,
1108
+ dxBusy xBusy,
1109
+ object pArg
1110
+ )
1111
+ {
1112
+ sqlite3_mutex_enter( db.mutex );
1113
+ db.busyHandler.xFunc = xBusy;
1114
+ db.busyHandler.pArg = pArg;
1115
+ db.busyHandler.nBusy = 0;
1116
+ sqlite3_mutex_leave( db.mutex );
1117
+ return SQLITE_OK;
1118
+ }
1119
+
1120
+ #if !SQLITE_OMIT_PROGRESS_CALLBACK
1121
+ /*
1122
+ ** This routine sets the progress callback for an Sqlite database to the
1123
+ ** given callback function with the given argument. The progress callback will
1124
+ ** be invoked every nOps opcodes.
1125
+ */
1126
+ static void sqlite3_progress_handler(
1127
+ sqlite3 db,
1128
+ int nOps,
1129
+ dxProgress xProgress, //int (xProgress)(void*),
1130
+ object pArg
1131
+ )
1132
+ {
1133
+ sqlite3_mutex_enter( db.mutex );
1134
+ if ( nOps > 0 )
1135
+ {
1136
+ db.xProgress = xProgress;
1137
+ db.nProgressOps = nOps;
1138
+ db.pProgressArg = pArg;
1139
+ }
1140
+ else
1141
+ {
1142
+ db.xProgress = null;
1143
+ db.nProgressOps = 0;
1144
+ db.pProgressArg = null;
1145
+ }
1146
+ sqlite3_mutex_leave( db.mutex );
1147
+ }
1148
+ #endif
1149
+
1150
+
1151
+ /*
1152
+ ** This routine installs a default busy handler that waits for the
1153
+ ** specified number of milliseconds before returning 0.
1154
+ */
1155
+ static public int sqlite3_busy_timeout( sqlite3 db, int ms )
1156
+ {
1157
+ if ( ms > 0 )
1158
+ {
1159
+ db.busyTimeout = ms;
1160
+ sqlite3_busy_handler( db, sqliteDefaultBusyCallback, db );
1161
+ }
1162
+ else
1163
+ {
1164
+ sqlite3_busy_handler( db, null, null );
1165
+ }
1166
+ return SQLITE_OK;
1167
+ }
1168
+
1169
+ /*
1170
+ ** Cause any pending operation to stop at its earliest opportunity.
1171
+ */
1172
+ static void sqlite3_interrupt( sqlite3 db )
1173
+ {
1174
+ db.u1.isInterrupted = true;
1175
+ }
1176
+
1177
+
1178
+ /*
1179
+ ** This function is exactly the same as sqlite3_create_function(), except
1180
+ ** that it is designed to be called by internal code. The difference is
1181
+ ** that if a malloc() fails in sqlite3_create_function(), an error code
1182
+ ** is returned and the mallocFailed flag cleared.
1183
+ */
1184
+ static int sqlite3CreateFunc(
1185
+ sqlite3 db,
1186
+ string zFunctionName,
1187
+ int nArg,
1188
+ u8 enc,
1189
+ object pUserData,
1190
+ dxFunc xFunc, //)(sqlite3_context*,int,sqlite3_value **),
1191
+ dxStep xStep,//)(sqlite3_context*,int,sqlite3_value **),
1192
+ dxFinal xFinal//)(sqlite3_context*)
1193
+ )
1194
+ {
1195
+ FuncDef p;
1196
+ int nName;
1197
+
1198
+ Debug.Assert( sqlite3_mutex_held( db.mutex ) );
1199
+ if ( zFunctionName == null ||
1200
+ ( xFunc != null && ( xFinal != null || xStep != null ) ) ||
1201
+ ( xFunc == null && ( xFinal != null && xStep == null ) ) ||
1202
+ ( xFunc == null && ( xFinal == null && xStep != null ) ) ||
1203
+ ( nArg < -1 || nArg > SQLITE_MAX_FUNCTION_ARG ) ||
1204
+ ( 255 < ( nName = sqlite3Strlen30( zFunctionName ) ) ) )
1205
+ {
1206
+ return SQLITE_MISUSE_BKPT();
1207
+ }
1208
+
1209
+ #if !SQLITE_OMIT_UTF16
1210
+ /* If SQLITE_UTF16 is specified as the encoding type, transform this
1211
+ ** to one of SQLITE_UTF16LE or SQLITE_UTF16BE using the
1212
+ ** SQLITE_UTF16NATIVE macro. SQLITE_UTF16 is not used internally.
1213
+ **
1214
+ ** If SQLITE_ANY is specified, add three versions of the function
1215
+ ** to the hash table.
1216
+ */
1217
+ if( enc==SQLITE_UTF16 ){
1218
+ enc = SQLITE_UTF16NATIVE;
1219
+ }else if( enc==SQLITE_ANY ){
1220
+ int rc;
1221
+ rc = sqlite3CreateFunc(db, zFunctionName, nArg, SQLITE_UTF8,
1222
+ pUserData, xFunc, xStep, xFinal);
1223
+ if( rc==SQLITE_OK ){
1224
+ rc = sqlite3CreateFunc(db, zFunctionName, nArg, SQLITE_UTF16LE,
1225
+ pUserData, xFunc, xStep, xFinal);
1226
+ }
1227
+ if( rc!=SQLITE_OK ){
1228
+ return rc;
1229
+ }
1230
+ enc = SQLITE_UTF16BE;
1231
+ }
1232
+ #else
1233
+ enc = SQLITE_UTF8;
1234
+ #endif
1235
+
1236
+ /* Check if an existing function is being overridden or deleted. If so,
1237
+ ** and there are active VMs, then return SQLITE_BUSY. If a function
1238
+ ** is being overridden/deleted but there are no active VMs, allow the
1239
+ ** operation to continue but invalidate all precompiled statements.
1240
+ */
1241
+ p = sqlite3FindFunction( db, zFunctionName, nName, nArg, enc, 0 );
1242
+ if ( p != null && p.iPrefEnc == enc && p.nArg == nArg )
1243
+ {
1244
+ if ( db.activeVdbeCnt != 0 )
1245
+ {
1246
+ sqlite3Error( db, SQLITE_BUSY,
1247
+ "unable to delete/modify user-function due to active statements" );
1248
+ //Debug.Assert( 0 == db.mallocFailed );
1249
+ return SQLITE_BUSY;
1250
+ }
1251
+ else
1252
+ {
1253
+ sqlite3ExpirePreparedStatements( db );
1254
+ }
1255
+ }
1256
+
1257
+ p = sqlite3FindFunction( db, zFunctionName, nName, nArg, enc, 1 );
1258
+ Debug.Assert( p != null /*|| db.mallocFailed != 0 */ );
1259
+ if ( p == null )
1260
+ {
1261
+ return SQLITE_NOMEM;
1262
+ }
1263
+ p.flags = 0;
1264
+ p.xFunc = xFunc;
1265
+ p.xStep = xStep;
1266
+ p.xFinalize = xFinal;
1267
+ p.pUserData = pUserData;
1268
+ p.nArg = (i16)nArg;
1269
+ return SQLITE_OK;
1270
+ }
1271
+
1272
+ /*
1273
+ ** Create new user functions.
1274
+ */
1275
+ static public int sqlite3_create_function(
1276
+ sqlite3 db,
1277
+ string zFunctionName,
1278
+ int nArg,
1279
+ u8 enc,
1280
+ object p,
1281
+ dxFunc xFunc, //)(sqlite3_context*,int,sqlite3_value **),
1282
+ dxStep xStep,//)(sqlite3_context*,int,sqlite3_value **),
1283
+ dxFinal xFinal//)(sqlite3_context*)
1284
+ )
1285
+ {
1286
+ int rc;
1287
+ sqlite3_mutex_enter( db.mutex );
1288
+ rc = sqlite3CreateFunc( db, zFunctionName, nArg, enc, p, xFunc, xStep, xFinal );
1289
+ rc = sqlite3ApiExit( db, rc );
1290
+ sqlite3_mutex_leave( db.mutex );
1291
+ return rc;
1292
+ }
1293
+
1294
+ #if !SQLITE_OMIT_UTF16
1295
+ static int sqlite3_create_function16(
1296
+ sqlite3 db,
1297
+ string zFunctionName,
1298
+ int nArg,
1299
+ int eTextRep,
1300
+ object p,
1301
+ dxFunc xFunc, //)(sqlite3_context*,int,sqlite3_value**),
1302
+ dxStep xStep, //)(sqlite3_context*,int,sqlite3_value**),
1303
+ dxFinal xFinal //)(sqlite3_context*)
1304
+ ){
1305
+ int rc;
1306
+ string zFunc8;
1307
+ sqlite3_mutex_enter(db.mutex);
1308
+ Debug.Assert( 0==db.mallocFailed );
1309
+ zFunc8 = sqlite3Utf16to8(db, zFunctionName, -1, SQLITE_UTF16NATIVE);
1310
+ rc = sqlite3CreateFunc(db, zFunc8, nArg, eTextRep, p, xFunc, xStep, xFinal);
1311
+ sqlite3DbFree(db,ref zFunc8);
1312
+ rc = sqlite3ApiExit(db, rc);
1313
+ sqlite3_mutex_leave(db.mutex);
1314
+ return rc;
1315
+ }
1316
+ #endif
1317
+
1318
+
1319
+ /*
1320
+ ** Declare that a function has been overloaded by a virtual table.
1321
+ **
1322
+ ** If the function already exists as a regular global function, then
1323
+ ** this routine is a no-op. If the function does not exist, then create
1324
+ ** a new one that always throws a run-time error.
1325
+ **
1326
+ ** When virtual tables intend to provide an overloaded function, they
1327
+ ** should call this routine to make sure the global function exists.
1328
+ ** A global function must exist in order for name resolution to work
1329
+ ** properly.
1330
+ */
1331
+ static int sqlite3_overload_function(
1332
+ sqlite3 db,
1333
+ string zName,
1334
+ int nArg
1335
+ )
1336
+ {
1337
+ int nName = sqlite3Strlen30( zName );
1338
+ int rc;
1339
+ sqlite3_mutex_enter( db.mutex );
1340
+ if ( sqlite3FindFunction( db, zName, nName, nArg, SQLITE_UTF8, 0 ) == null )
1341
+ {
1342
+ sqlite3CreateFunc( db, zName, nArg, SQLITE_UTF8,
1343
+ 0, (dxFunc)sqlite3InvalidFunction, null, null );
1344
+ }
1345
+ rc = sqlite3ApiExit( db, SQLITE_OK );
1346
+ sqlite3_mutex_leave( db.mutex );
1347
+ return rc;
1348
+ }
1349
+
1350
+ #if !SQLITE_OMIT_TRACE
1351
+ /*
1352
+ ** Register a trace function. The pArg from the previously registered trace
1353
+ ** is returned.
1354
+ **
1355
+ ** A NULL trace function means that no tracing is executes. A non-NULL
1356
+ ** trace is a pointer to a function that is invoked at the start of each
1357
+ ** SQL statement.
1358
+ */
1359
+ static object sqlite3_trace( sqlite3 db, dxTrace xTrace, object pArg )
1360
+ {// (*xTrace)(void*,const char*), object pArg){
1361
+ object pOld;
1362
+ sqlite3_mutex_enter( db.mutex );
1363
+ pOld = db.pTraceArg;
1364
+ db.xTrace = xTrace;
1365
+ db.pTraceArg = pArg;
1366
+ sqlite3_mutex_leave( db.mutex );
1367
+ return pOld;
1368
+ }
1369
+ /*
1370
+ ** Register a profile function. The pArg from the previously registered
1371
+ ** profile function is returned.
1372
+ **
1373
+ ** A NULL profile function means that no profiling is executes. A non-NULL
1374
+ ** profile is a pointer to a function that is invoked at the conclusion of
1375
+ ** each SQL statement that is run.
1376
+ */
1377
+ static object sqlite3_profile(
1378
+ sqlite3 db,
1379
+ dxProfile xProfile,//void (*xProfile)(void*,const char*,sqlite_u3264),
1380
+ object pArg
1381
+ )
1382
+ {
1383
+ object pOld;
1384
+ sqlite3_mutex_enter( db.mutex );
1385
+ pOld = db.pProfileArg;
1386
+ db.xProfile = xProfile;
1387
+ db.pProfileArg = pArg;
1388
+ sqlite3_mutex_leave( db.mutex );
1389
+ return pOld;
1390
+ }
1391
+ #endif // * SQLITE_OMIT_TRACE */
1392
+
1393
+ /*** EXPERIMENTAL ***
1394
+ **
1395
+ ** Register a function to be invoked when a transaction comments.
1396
+ ** If the invoked function returns non-zero, then the commit becomes a
1397
+ ** rollback.
1398
+ */
1399
+ static object sqlite3_commit_hook(
1400
+ sqlite3 db, /* Attach the hook to this database */
1401
+ dxCommitCallback xCallback, //int (*xCallback)(void*), /* Function to invoke on each commit */
1402
+ object pArg /* Argument to the function */
1403
+ )
1404
+ {
1405
+ object pOld;
1406
+ sqlite3_mutex_enter( db.mutex );
1407
+ pOld = db.pCommitArg;
1408
+ db.xCommitCallback = xCallback;
1409
+ db.pCommitArg = pArg;
1410
+ sqlite3_mutex_leave( db.mutex );
1411
+ return pOld;
1412
+ }
1413
+
1414
+ /*
1415
+ ** Register a callback to be invoked each time a row is updated,
1416
+ ** inserted or deleted using this database connection.
1417
+ */
1418
+ static object sqlite3_update_hook(
1419
+ sqlite3 db, /* Attach the hook to this database */
1420
+ dxUpdateCallback xCallback, //void (*xCallback)(void*,int,char const *,char const *,sqlite_int64),
1421
+ object pArg /* Argument to the function */
1422
+ )
1423
+ {
1424
+ object pRet;
1425
+ sqlite3_mutex_enter( db.mutex );
1426
+ pRet = db.pUpdateArg;
1427
+ db.xUpdateCallback = xCallback;
1428
+ db.pUpdateArg = pArg;
1429
+ sqlite3_mutex_leave( db.mutex );
1430
+ return pRet;
1431
+ }
1432
+
1433
+ /*
1434
+ ** Register a callback to be invoked each time a transaction is rolled
1435
+ ** back by this database connection.
1436
+ */
1437
+ static object sqlite3_rollback_hook(
1438
+ sqlite3 db, /* Attach the hook to this database */
1439
+ dxRollbackCallback xCallback, //void (*xCallback)(void*), /* Callback function */
1440
+ object pArg /* Argument to the function */
1441
+ )
1442
+ {
1443
+ object pRet;
1444
+ sqlite3_mutex_enter( db.mutex );
1445
+ pRet = db.pRollbackArg;
1446
+ db.xRollbackCallback = xCallback;
1447
+ db.pRollbackArg = pArg;
1448
+ sqlite3_mutex_leave( db.mutex );
1449
+ return pRet;
1450
+ }
1451
+
1452
+ /*
1453
+ ** This function returns true if main-memory should be used instead of
1454
+ ** a temporary file for transient pager files and statement journals.
1455
+ ** The value returned depends on the value of db->temp_store (runtime
1456
+ ** parameter) and the compile time value of SQLITE_TEMP_STORE. The
1457
+ ** following table describes the relationship between these two values
1458
+ ** and this functions return value.
1459
+ **
1460
+ ** SQLITE_TEMP_STORE db->temp_store Location of temporary database
1461
+ ** ----------------- -------------- ------------------------------
1462
+ ** 0 any file (return 0)
1463
+ ** 1 1 file (return 0)
1464
+ ** 1 2 memory (return 1)
1465
+ ** 1 0 file (return 0)
1466
+ ** 2 1 file (return 0)
1467
+ ** 2 2 memory (return 1)
1468
+ ** 2 0 memory (return 1)
1469
+ ** 3 any memory (return 1)
1470
+ */
1471
+ static bool sqlite3TempInMemory( sqlite3 db )
1472
+ {
1473
+ //#if SQLITE_TEMP_STORE==1
1474
+ if ( SQLITE_TEMP_STORE == 1 )
1475
+ return ( db.temp_store == 2 );
1476
+ //#endif
1477
+ //#if SQLITE_TEMP_STORE==2
1478
+ if ( SQLITE_TEMP_STORE == 2 )
1479
+ return ( db.temp_store != 1 );
1480
+ //#endif
1481
+ //#if SQLITE_TEMP_STORE==3
1482
+ if ( SQLITE_TEMP_STORE == 3 )
1483
+ return true;
1484
+ //#endif
1485
+ //#if SQLITE_TEMP_STORE<1 || SQLITE_TEMP_STORE>3
1486
+ if ( SQLITE_TEMP_STORE < 1 || SQLITE_TEMP_STORE > 3 )
1487
+ return false;
1488
+ //#endif
1489
+ return false;
1490
+ }
1491
+
1492
+ /*
1493
+ ** This routine is called to create a connection to a database BTree
1494
+ ** driver. If zFilename is the name of a file, then that file is
1495
+ ** opened and used. If zFilename is the magic name ":memory:" then
1496
+ ** the database is stored in memory (and is thus forgotten as soon as
1497
+ ** the connection is closed.) If zFilename is NULL then the database
1498
+ ** is a "virtual" database for transient use only and is deleted as
1499
+ ** soon as the connection is closed.
1500
+ **
1501
+ ** A virtual database can be either a disk file (that is automatically
1502
+ ** deleted when the file is closed) or it an be held entirely in memory.
1503
+ ** The sqlite3TempInMemory() function is used to determine which.
1504
+ */
1505
+ static int sqlite3BtreeFactory(
1506
+ sqlite3 db, /* Main database when opening aux otherwise 0 */
1507
+ string zFilename, /* Name of the file containing the BTree database */
1508
+ bool omitJournal, /* if TRUE then do not journal this file */
1509
+ int nCache, /* How many pages in the page cache */
1510
+ int vfsFlags, /* Flags passed through to vfsOpen */
1511
+ ref Btree ppBtree /* Pointer to new Btree object written here */
1512
+ )
1513
+ {
1514
+ int btFlags = 0;
1515
+ int rc;
1516
+
1517
+ Debug.Assert( sqlite3_mutex_held( db.mutex ) );
1518
+ //Debug.Assert( ppBtree != null);
1519
+ if ( omitJournal )
1520
+ {
1521
+ btFlags |= BTREE_OMIT_JOURNAL;
1522
+ }
1523
+ if ( ( db.flags & SQLITE_NoReadlock ) != 0 )
1524
+ {
1525
+ btFlags |= BTREE_NO_READLOCK;
1526
+ }
1527
+ #if !SQLITE_OMIT_MEMORYDB
1528
+ if ( String.IsNullOrEmpty( zFilename ) && sqlite3TempInMemory( db ) )
1529
+ {
1530
+
1531
+ zFilename = ":memory:";
1532
+ }
1533
+ #endif // * SQLITE_OMIT_MEMORYDB */
1534
+
1535
+ if ( ( vfsFlags & SQLITE_OPEN_MAIN_DB ) != 0 && ( zFilename == null ) )
1536
+ {// || *zFilename==0) ){
1537
+ vfsFlags = ( vfsFlags & ~SQLITE_OPEN_MAIN_DB ) | SQLITE_OPEN_TEMP_DB;
1538
+ }
1539
+ rc = sqlite3BtreeOpen( zFilename, db, ref ppBtree, btFlags, vfsFlags );
1540
+ /* If the B-Tree was successfully opened, set the pager-cache size to the
1541
+ ** default value. Except, if the call to BtreeOpen() returned a handle
1542
+ ** open on an existing shared pager-cache, do not change the pager-cache
1543
+ ** size.
1544
+ */
1545
+ if ( rc == SQLITE_OK && null == sqlite3BtreeSchema( ppBtree, 0, null ) )
1546
+ {
1547
+ sqlite3BtreeSetCacheSize( ppBtree, nCache );
1548
+ }
1549
+ return rc;
1550
+ }
1551
+
1552
+ /*
1553
+ ** Return UTF-8 encoded English language explanation of the most recent
1554
+ ** error.
1555
+ */
1556
+ public static string sqlite3_errmsg( sqlite3 db )
1557
+ {
1558
+ string z;
1559
+ if ( db == null )
1560
+ {
1561
+ return sqlite3ErrStr( SQLITE_NOMEM );
1562
+ }
1563
+ if ( !sqlite3SafetyCheckSickOrOk( db ) )
1564
+ {
1565
+ return sqlite3ErrStr(SQLITE_MISUSE_BKPT());
1566
+ }
1567
+ sqlite3_mutex_enter( db.mutex );
1568
+ //if ( db.mallocFailed != 0 )
1569
+ //{
1570
+ // z = sqlite3ErrStr( SQLITE_NOMEM );
1571
+ //}
1572
+ //else
1573
+ {
1574
+ z = sqlite3_value_text( db.pErr );
1575
+ //Debug.Assert( 0 == db.mallocFailed );
1576
+ if ( String.IsNullOrEmpty( z ) )
1577
+ {
1578
+ z = sqlite3ErrStr( db.errCode );
1579
+ }
1580
+ }
1581
+ sqlite3_mutex_leave( db.mutex );
1582
+ return z;
1583
+ }
1584
+
1585
+ #if !SQLITE_OMIT_UTF16
1586
+ /*
1587
+ ** Return UTF-16 encoded English language explanation of the most recent
1588
+ ** error.
1589
+ */
1590
+ const void *sqlite3_errmsg16(sqlite3 *db){
1591
+ static const u16 outOfMem[] = {
1592
+ 'o', 'u', 't', ' ', 'o', 'f', ' ', 'm', 'e', 'm', 'o', 'r', 'y', 0
1593
+ };
1594
+ static const u16 misuse[] = {
1595
+ 'l', 'i', 'b', 'r', 'a', 'r', 'y', ' ',
1596
+ 'r', 'o', 'u', 't', 'i', 'n', 'e', ' ',
1597
+ 'c', 'a', 'l', 'l', 'e', 'd', ' ',
1598
+ 'o', 'u', 't', ' ',
1599
+ 'o', 'f', ' ',
1600
+ 's', 'e', 'q', 'u', 'e', 'n', 'c', 'e', 0
1601
+ };
1602
+
1603
+ const void *z;
1604
+ if( !db ){
1605
+ return (void *)outOfMem;
1606
+ }
1607
+ if( !sqlite3SafetyCheckSickOrOk(db) ){
1608
+ return (void *)misuse;
1609
+ }
1610
+ sqlite3_mutex_enter(db->mutex);
1611
+ if( db->mallocFailed ){
1612
+ z = (void *)outOfMem;
1613
+ }else{
1614
+ z = sqlite3_value_text16(db->pErr);
1615
+ if( z==0 ){
1616
+ sqlite3ValueSetStr(db->pErr, -1, sqlite3ErrStr(db->errCode),
1617
+ SQLITE_UTF8, SQLITE_STATIC);
1618
+ z = sqlite3_value_text16(db->pErr);
1619
+ }
1620
+ /* A malloc() may have failed within the call to sqlite3_value_text16()
1621
+ ** above. If this is the case, then the db->mallocFailed flag needs to
1622
+ ** be cleared before returning. Do this directly, instead of via
1623
+ ** sqlite3ApiExit(), to avoid setting the database handle error message.
1624
+ */
1625
+ db->mallocFailed = 0;
1626
+ }
1627
+ sqlite3_mutex_leave(db->mutex);
1628
+ return z;
1629
+ }
1630
+ #endif // * SQLITE_OMIT_UTF16 */
1631
+
1632
+ /*
1633
+ ** Return the most recent error code generated by an SQLite routine. If NULL is
1634
+ ** passed to this function, we assume a malloc() failed during sqlite3_open().
1635
+ */
1636
+ static public int sqlite3_errcode( sqlite3 db )
1637
+ {
1638
+ if ( db != null && !sqlite3SafetyCheckSickOrOk( db ) )
1639
+ {
1640
+ return SQLITE_MISUSE_BKPT();
1641
+ }
1642
+ if ( null == db /*|| db.mallocFailed != 0 */ )
1643
+ {
1644
+ return SQLITE_NOMEM;
1645
+ }
1646
+ return db.errCode & db.errMask;
1647
+ }
1648
+ static int sqlite3_extended_errcode( sqlite3 db )
1649
+ {
1650
+ if ( db != null && !sqlite3SafetyCheckSickOrOk( db ) )
1651
+ {
1652
+ return SQLITE_MISUSE_BKPT();
1653
+ }
1654
+ if ( null == db /*|| db.mallocFailed != 0 */ )
1655
+ {
1656
+ return SQLITE_NOMEM;
1657
+ }
1658
+ return db.errCode;
1659
+ }
1660
+ /*
1661
+ ** Create a new collating function for database "db". The name is zName
1662
+ ** and the encoding is enc.
1663
+ */
1664
+ static int createCollation(
1665
+ sqlite3 db,
1666
+ string zName,
1667
+ u8 enc,
1668
+ u8 collType,
1669
+ object pCtx,
1670
+ dxCompare xCompare,//)(void*,int,const void*,int,const void*),
1671
+ dxDelCollSeq xDel//)(void*)
1672
+ )
1673
+ {
1674
+ CollSeq pColl;
1675
+ int enc2;
1676
+ int nName = sqlite3Strlen30( zName );
1677
+
1678
+ Debug.Assert( sqlite3_mutex_held( db.mutex ) );
1679
+
1680
+ /* If SQLITE_UTF16 is specified as the encoding type, transform this
1681
+ ** to one of SQLITE_UTF16LE or SQLITE_UTF16BE using the
1682
+ ** SQLITE_UTF16NATIVE macro. SQLITE_UTF16 is not used internally.
1683
+ */
1684
+ enc2 = enc;
1685
+ testcase( enc2 == SQLITE_UTF16 );
1686
+ testcase( enc2 == SQLITE_UTF16_ALIGNED );
1687
+ if ( enc2 == SQLITE_UTF16 || enc2 == SQLITE_UTF16_ALIGNED )
1688
+ {
1689
+ enc2 = SQLITE_UTF16NATIVE;
1690
+ }
1691
+ if ( enc2 < SQLITE_UTF8 || enc2 > SQLITE_UTF16BE )
1692
+ {
1693
+ return SQLITE_MISUSE_BKPT();
1694
+ }
1695
+
1696
+ /* Check if this call is removing or replacing an existing collation
1697
+ ** sequence. If so, and there are active VMs, return busy. If there
1698
+ ** are no active VMs, invalidate any pre-compiled statements.
1699
+ */
1700
+ pColl = sqlite3FindCollSeq( db, (u8)enc2, zName, 0 );
1701
+ if ( pColl != null && pColl.xCmp != null )
1702
+ {
1703
+ if ( db.activeVdbeCnt != 0 )
1704
+ {
1705
+ sqlite3Error( db, SQLITE_BUSY,
1706
+ "unable to delete/modify collation sequence due to active statements" );
1707
+ return SQLITE_BUSY;
1708
+ }
1709
+ sqlite3ExpirePreparedStatements( db );
1710
+
1711
+ /* If collation sequence pColl was created directly by a call to
1712
+ ** sqlite3_create_collation, and not generated by synthCollSeq(),
1713
+ ** then any copies made by synthCollSeq() need to be invalidated.
1714
+ ** Also, collation destructor - CollSeq.xDel() - function may need
1715
+ ** to be called.
1716
+ */
1717
+ if ( ( pColl.enc & ~SQLITE_UTF16_ALIGNED ) == enc2 )
1718
+ {
1719
+ CollSeq[] aColl = (CollSeq[])sqlite3HashFind( db.aCollSeq, zName, nName );
1720
+ int j;
1721
+ for ( j = 0; j < 3; j++ )
1722
+ {
1723
+ CollSeq p = aColl[j];
1724
+ if ( p.enc == pColl.enc )
1725
+ {
1726
+ if ( p.xDel != null )
1727
+ {
1728
+ p.xDel( ref p.pUser );
1729
+ }
1730
+ p.xCmp = null;
1731
+ }
1732
+ }
1733
+ }
1734
+ }
1735
+
1736
+ pColl = sqlite3FindCollSeq( db, (u8)enc2, zName, 1 );
1737
+ if ( pColl != null )
1738
+ {
1739
+ pColl.xCmp = xCompare;
1740
+ pColl.pUser = pCtx;
1741
+ pColl.xDel = xDel;
1742
+ pColl.enc = (u8)( enc2 | ( enc & SQLITE_UTF16_ALIGNED ) );
1743
+ pColl.type = collType;
1744
+ }
1745
+ sqlite3Error( db, SQLITE_OK, 0 );
1746
+ return SQLITE_OK;
1747
+ }
1748
+
1749
+ /*
1750
+ ** This array defines hard upper bounds on limit values. The
1751
+ ** initializer must be kept in sync with the SQLITE_LIMIT_*
1752
+ ** #defines in sqlite3.h.
1753
+ */
1754
+ static int[] aHardLimit = new int[] {
1755
+ SQLITE_MAX_LENGTH,
1756
+ SQLITE_MAX_SQL_LENGTH,
1757
+ SQLITE_MAX_COLUMN,
1758
+ SQLITE_MAX_EXPR_DEPTH,
1759
+ SQLITE_MAX_COMPOUND_SELECT,
1760
+ SQLITE_MAX_VDBE_OP,
1761
+ SQLITE_MAX_FUNCTION_ARG,
1762
+ SQLITE_MAX_ATTACHED,
1763
+ SQLITE_MAX_LIKE_PATTERN_LENGTH,
1764
+ SQLITE_MAX_VARIABLE_NUMBER,
1765
+ SQLITE_MAX_TRIGGER_DEPTH,
1766
+ };
1767
+
1768
+ /*
1769
+ ** Make sure the hard limits are set to reasonable values
1770
+ */
1771
+ //#if SQLITE_MAX_LENGTH<100
1772
+ //# error SQLITE_MAX_LENGTH must be at least 100
1773
+ //#endif
1774
+ //#if SQLITE_MAX_SQL_LENGTH<100
1775
+ //# error SQLITE_MAX_SQL_LENGTH must be at least 100
1776
+ //#endif
1777
+ //#if SQLITE_MAX_SQL_LENGTH>SQLITE_MAX_LENGTH
1778
+ //# error SQLITE_MAX_SQL_LENGTH must not be greater than SQLITE_MAX_LENGTH
1779
+ //#endif
1780
+ //#if SQLITE_MAX_COMPOUND_SELECT<2
1781
+ //# error SQLITE_MAX_COMPOUND_SELECT must be at least 2
1782
+ //#endif
1783
+ //#if SQLITE_MAX_VDBE_OP<40
1784
+ //# error SQLITE_MAX_VDBE_OP must be at least 40
1785
+ //#endif
1786
+ //#if SQLITE_MAX_FUNCTION_ARG<0 || SQLITE_MAX_FUNCTION_ARG>1000
1787
+ //# error SQLITE_MAX_FUNCTION_ARG must be between 0 and 1000
1788
+ //#endif
1789
+ //#if SQLITE_MAX_ATTACHED<0 || SQLITE_MAX_ATTACHED>30
1790
+ //# error SQLITE_MAX_ATTACHED must be between 0 and 30
1791
+ //#endif
1792
+ //#if SQLITE_MAX_LIKE_PATTERN_LENGTH<1
1793
+ //# error SQLITE_MAX_LIKE_PATTERN_LENGTH must be at least 1
1794
+ //#endif
1795
+ //#if SQLITE_MAX_COLUMN>32767
1796
+ //# error SQLITE_MAX_COLUMN must not exceed 32767
1797
+ //#endif
1798
+ //#if SQLITE_MAX_TRIGGER_DEPTH<1
1799
+ //# error SQLITE_MAX_TRIGGER_DEPTH must be at least 1
1800
+ //#endif
1801
+
1802
+ /*
1803
+ ** Change the value of a limit. Report the old value.
1804
+ ** If an invalid limit index is supplied, report -1.
1805
+ ** Make no changes but still report the old value if the
1806
+ ** new limit is negative.
1807
+ **
1808
+ ** A new lower limit does not shrink existing constructs.
1809
+ ** It merely prevents new constructs that exceed the limit
1810
+ ** from forming.
1811
+ */
1812
+ static int sqlite3_limit( sqlite3 db, int limitId, int newLimit )
1813
+ {
1814
+ int oldLimit;
1815
+ if ( limitId < 0 || limitId >= SQLITE_N_LIMIT )
1816
+ {
1817
+ return -1;
1818
+ }
1819
+ oldLimit = db.aLimit[limitId];
1820
+ if ( newLimit >= 0 )
1821
+ {
1822
+ if ( newLimit > aHardLimit[limitId] )
1823
+ {
1824
+ newLimit = aHardLimit[limitId];
1825
+ }
1826
+ db.aLimit[limitId] = newLimit;
1827
+ }
1828
+ return oldLimit;
1829
+ }
1830
+ /*
1831
+ ** This routine does the work of opening a database on behalf of
1832
+ ** sqlite3_open() and sqlite3_open16(). The database filename "zFilename"
1833
+ ** is UTF-8 encoded.
1834
+ */
1835
+ static int openDatabase(
1836
+ string zFilename, /* Database filename UTF-8 encoded */
1837
+ ref sqlite3 ppDb, /* OUT: Returned database handle */
1838
+ unsigned flags, /* Operational flags */
1839
+ string zVfs /* Name of the VFS to use */
1840
+ )
1841
+ {
1842
+ sqlite3 db;
1843
+ int rc;
1844
+ int isThreadsafe;
1845
+
1846
+ ppDb = null;
1847
+ #if !SQLITE_OMIT_AUTOINIT
1848
+ rc = sqlite3_initialize();
1849
+ if ( rc != 0 ) return rc;
1850
+ #endif
1851
+
1852
+ if ( sqlite3GlobalConfig.bCoreMutex == false )
1853
+ {
1854
+ isThreadsafe = 0;
1855
+ }
1856
+ else if ( ( flags & SQLITE_OPEN_NOMUTEX ) != 0 )
1857
+ {
1858
+ isThreadsafe = 0;
1859
+ }
1860
+ else if ( ( flags & SQLITE_OPEN_FULLMUTEX ) != 0 )
1861
+ {
1862
+ isThreadsafe = 1;
1863
+ }
1864
+ else
1865
+ {
1866
+ isThreadsafe = sqlite3GlobalConfig.bFullMutex ? 1 : 0;
1867
+ }
1868
+ if ( ( flags & SQLITE_OPEN_PRIVATECACHE ) != 0 )
1869
+ {
1870
+ flags &= ~SQLITE_OPEN_SHAREDCACHE;
1871
+ }
1872
+ else if ( sqlite3GlobalConfig.sharedCacheEnabled )
1873
+ {
1874
+ flags |= SQLITE_OPEN_SHAREDCACHE;
1875
+ }
1876
+
1877
+ /* Remove harmful bits from the flags parameter
1878
+ **
1879
+ ** The SQLITE_OPEN_NOMUTEX and SQLITE_OPEN_FULLMUTEX flags were
1880
+ ** dealt with in the previous code block. Besides these, the only
1881
+ ** valid input flags for sqlite3_open_v2() are SQLITE_OPEN_READONLY,
1882
+ ** SQLITE_OPEN_READWRITE, and SQLITE_OPEN_CREATE. Silently mask
1883
+ ** off all other flags.
1884
+ */
1885
+ flags &= ~( SQLITE_OPEN_DELETEONCLOSE |
1886
+ SQLITE_OPEN_EXCLUSIVE |
1887
+ SQLITE_OPEN_MAIN_DB |
1888
+ SQLITE_OPEN_TEMP_DB |
1889
+ SQLITE_OPEN_TRANSIENT_DB |
1890
+ SQLITE_OPEN_MAIN_JOURNAL |
1891
+ SQLITE_OPEN_TEMP_JOURNAL |
1892
+ SQLITE_OPEN_SUBJOURNAL |
1893
+ SQLITE_OPEN_MASTER_JOURNAL |
1894
+ SQLITE_OPEN_NOMUTEX |
1895
+ SQLITE_OPEN_FULLMUTEX
1896
+ );
1897
+
1898
+
1899
+ /* Allocate the sqlite data structure */
1900
+ db = new sqlite3();//sqlite3MallocZero( sqlite3.Length );
1901
+ if ( db == null ) goto opendb_out;
1902
+ if ( sqlite3GlobalConfig.bFullMutex && isThreadsafe != 0 )
1903
+ {
1904
+ db.mutex = sqlite3MutexAlloc( SQLITE_MUTEX_RECURSIVE );
1905
+ if ( db.mutex == null )
1906
+ {
1907
+ //sqlite3_free( ref db );
1908
+ goto opendb_out;
1909
+ }
1910
+ }
1911
+ sqlite3_mutex_enter( db.mutex );
1912
+ db.errMask = 0xff;
1913
+ db.nDb = 2;
1914
+ db.magic = SQLITE_MAGIC_BUSY;
1915
+ Array.Copy( db.aDbStatic, db.aDb, db.aDbStatic.Length );// db.aDb = db.aDbStatic;
1916
+ Debug.Assert( db.aLimit.Length == aHardLimit.Length );
1917
+ Buffer.BlockCopy( aHardLimit, 0, db.aLimit, 0, aHardLimit.Length * sizeof( int ) );//memcpy(db.aLimit, aHardLimit, sizeof(db.aLimit));
1918
+ db.autoCommit = 1;
1919
+ db.nextAutovac = -1;
1920
+ db.nextPagesize = 0;
1921
+ db.flags |= SQLITE_ShortColNames;
1922
+ if ( SQLITE_DEFAULT_FILE_FORMAT < 4 )
1923
+ db.flags |= SQLITE_LegacyFileFmt
1924
+ #if SQLITE_ENABLE_LOAD_EXTENSION
1925
+ | SQLITE_LoadExtension
1926
+ #endif
1927
+ #if SQLITE_DEFAULT_RECURSIVE_TRIGGERS
1928
+ | SQLITE_RecTriggers
1929
+ #endif
1930
+ ;
1931
+ sqlite3HashInit( db.aCollSeq );
1932
+ #if !SQLITE_OMIT_VIRTUALTABLE
1933
+ sqlite3HashInit( ref db.aModule );
1934
+ #endif
1935
+ db.pVfs = sqlite3_vfs_find( zVfs );
1936
+ if ( db.pVfs == null )
1937
+ {
1938
+ rc = SQLITE_ERROR;
1939
+ sqlite3Error( db, rc, "no such vfs: %s", zVfs );
1940
+ goto opendb_out;
1941
+ }
1942
+
1943
+ /* Add the default collation sequence BINARY. BINARY works for both UTF-8
1944
+ ** and UTF-16, so add a version for each to avoid any unnecessary
1945
+ ** conversions. The only error that can occur here is a malloc() failure.
1946
+ */
1947
+ createCollation( db, "BINARY", SQLITE_UTF8, SQLITE_COLL_BINARY, 0,
1948
+ binCollFunc, null );
1949
+ createCollation( db, "BINARY", SQLITE_UTF16BE, SQLITE_COLL_BINARY, 0,
1950
+ binCollFunc, null );
1951
+ createCollation( db, "BINARY", SQLITE_UTF16LE, SQLITE_COLL_BINARY, 0,
1952
+ binCollFunc, null );
1953
+ createCollation( db, "RTRIM", SQLITE_UTF8, SQLITE_COLL_USER, 1,
1954
+ binCollFunc, null );
1955
+ //if ( db.mallocFailed != 0 )
1956
+ //{
1957
+ // goto opendb_out;
1958
+ //}
1959
+ db.pDfltColl = sqlite3FindCollSeq( db, SQLITE_UTF8, "BINARY", 0 );
1960
+ Debug.Assert( db.pDfltColl != null );
1961
+
1962
+ /* Also add a UTF-8 case-insensitive collation sequence. */
1963
+ createCollation( db, "NOCASE", SQLITE_UTF8, SQLITE_COLL_NOCASE, 0,
1964
+ nocaseCollatingFunc, null );
1965
+
1966
+ /* Open the backend database driver */
1967
+ db.openFlags = flags;
1968
+ rc = sqlite3BtreeFactory( db, zFilename, false, SQLITE_DEFAULT_CACHE_SIZE,
1969
+ flags | SQLITE_OPEN_MAIN_DB,
1970
+ ref db.aDb[0].pBt );
1971
+ if ( rc != SQLITE_OK )
1972
+ {
1973
+ if ( rc == SQLITE_IOERR_NOMEM )
1974
+ {
1975
+ rc = SQLITE_NOMEM;
1976
+ }
1977
+ sqlite3Error( db, rc, 0 );
1978
+ goto opendb_out;
1979
+ }
1980
+ db.aDb[0].pSchema = sqlite3SchemaGet( db, db.aDb[0].pBt );
1981
+ db.aDb[1].pSchema = sqlite3SchemaGet( db, null );
1982
+
1983
+
1984
+ /* The default safety_level for the main database is 'full'; for the temp
1985
+ ** database it is 'NONE'. This matches the pager layer defaults.
1986
+ */
1987
+ db.aDb[0].zName = "main";
1988
+ db.aDb[0].safety_level = 3;
1989
+ db.aDb[1].zName = "temp";
1990
+ db.aDb[1].safety_level = 1;
1991
+
1992
+ db.magic = SQLITE_MAGIC_OPEN;
1993
+ //if ( db.mallocFailed != 0 )
1994
+ //{
1995
+ // goto opendb_out;
1996
+ //}
1997
+
1998
+ /* Register all built-in functions, but do not attempt to read the
1999
+ ** database schema yet. This is delayed until the first time the database
2000
+ ** is accessed.
2001
+ */
2002
+ sqlite3Error( db, SQLITE_OK, 0 );
2003
+ sqlite3RegisterBuiltinFunctions( db );
2004
+
2005
+ /* Load automatic extensions - extensions that have been registered
2006
+ ** using the sqlite3_automatic_extension() API.
2007
+ */
2008
+ sqlite3AutoLoadExtensions( db );
2009
+ rc = sqlite3_errcode( db );
2010
+ if ( rc != SQLITE_OK )
2011
+ {
2012
+ goto opendb_out;
2013
+ }
2014
+
2015
+
2016
+ #if SQLITE_ENABLE_FTS1
2017
+ if( 0==db.mallocFailed ){
2018
+ extern int sqlite3Fts1Init(sqlite3*);
2019
+ rc = sqlite3Fts1Init(db);
2020
+ }
2021
+ #endif
2022
+
2023
+ #if SQLITE_ENABLE_FTS2
2024
+ if( 0==db.mallocFailed && rc==SQLITE_OK ){
2025
+ extern int sqlite3Fts2Init(sqlite3*);
2026
+ rc = sqlite3Fts2Init(db);
2027
+ }
2028
+ #endif
2029
+
2030
+ #if SQLITE_ENABLE_FTS3
2031
+ if( 0==db.mallocFailed && rc==SQLITE_OK ){
2032
+ rc = sqlite3Fts3Init(db);
2033
+ }
2034
+ #endif
2035
+
2036
+ #if SQLITE_ENABLE_ICU
2037
+ if( 0==db.mallocFailed && rc==SQLITE_OK ){
2038
+ extern int sqlite3IcuInit(sqlite3*);
2039
+ rc = sqlite3IcuInit(db);
2040
+ }
2041
+ #endif
2042
+
2043
+ #if SQLITE_ENABLE_RTREE
2044
+ if( 0==db.mallocFailed && rc==SQLITE_OK){
2045
+ rc = sqlite3RtreeInit(db);
2046
+ }
2047
+ #endif
2048
+
2049
+ sqlite3Error( db, rc, 0 );
2050
+
2051
+ /* -DSQLITE_DEFAULT_LOCKING_MODE=1 makes EXCLUSIVE the default locking
2052
+ ** mode. -DSQLITE_DEFAULT_LOCKING_MODE=0 make NORMAL the default locking
2053
+ ** mode. Doing nothing at all also makes NORMAL the default.
2054
+ */
2055
+ #if SQLITE_DEFAULT_LOCKING_MODE
2056
+ db.dfltLockMode = SQLITE_DEFAULT_LOCKING_MODE;
2057
+ sqlite3PagerLockingMode(sqlite3BtreePager(db.aDb[0].pBt),
2058
+ SQLITE_DEFAULT_LOCKING_MODE);
2059
+ #endif
2060
+
2061
+ /* Enable the lookaside-malloc subsystem */
2062
+ setupLookaside( db, null, sqlite3GlobalConfig.szLookaside,
2063
+ sqlite3GlobalConfig.nLookaside );
2064
+
2065
+ opendb_out:
2066
+ if ( db != null )
2067
+ {
2068
+ Debug.Assert( db.mutex != null || isThreadsafe == 0 || !sqlite3GlobalConfig.bFullMutex );
2069
+ sqlite3_mutex_leave( db.mutex );
2070
+ }
2071
+ rc = sqlite3_errcode( db );
2072
+ if ( rc == SQLITE_NOMEM )
2073
+ {
2074
+ sqlite3_close( db );
2075
+ db = null;
2076
+ }
2077
+ else if ( rc != SQLITE_OK )
2078
+ {
2079
+ db.magic = SQLITE_MAGIC_SICK;
2080
+ }
2081
+ ppDb = db;
2082
+ return sqlite3ApiExit( 0, rc );
2083
+ }
2084
+
2085
+ /*
2086
+ ** Open a new database handle.
2087
+ */
2088
+ static public int sqlite3_open(
2089
+ string zFilename,
2090
+ ref sqlite3 ppDb
2091
+ )
2092
+ {
2093
+ return openDatabase( zFilename, ref ppDb,
2094
+ SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, null );
2095
+ }
2096
+
2097
+ static public int sqlite3_open_v2(
2098
+ string filename, /* Database filename (UTF-8) */
2099
+ ref sqlite3 ppDb, /* OUT: SQLite db handle */
2100
+ int flags, /* Flags */
2101
+ string zVfs /* Name of VFS module to use */
2102
+ )
2103
+ {
2104
+ return openDatabase( filename, ref ppDb, flags, zVfs );
2105
+ }
2106
+
2107
+ #if !SQLITE_OMIT_UTF16
2108
+
2109
+ /*
2110
+ ** Open a new database handle.
2111
+ */
2112
+ int sqlite3_open16(
2113
+ const void *zFilename,
2114
+ sqlite3 **ppDb
2115
+ ){
2116
+ char const *zFilename8; /* zFilename encoded in UTF-8 instead of UTF-16 */
2117
+ sqlite3_value pVal;
2118
+ int rc;
2119
+
2120
+ Debug.Assert(zFilename );
2121
+ Debug.Assert(ppDb );
2122
+ *ppDb = 0;
2123
+ #if !SQLITE_OMIT_AUTOINIT
2124
+ rc = sqlite3_initialize();
2125
+ if( rc !=0) return rc;
2126
+ #endif
2127
+ pVal = sqlite3ValueNew(0);
2128
+ sqlite3ValueSetStr(pVal, -1, zFilename, SQLITE_UTF16NATIVE, SQLITE_STATIC);
2129
+ zFilename8 = sqlite3ValueText(pVal, SQLITE_UTF8);
2130
+ if( zFilename8 ){
2131
+ rc = openDatabase(zFilename8, ppDb,
2132
+ SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, 0);
2133
+ Debug.Assert(*ppDb || rc==SQLITE_NOMEM );
2134
+ if( rc==SQLITE_OK && !DbHasProperty(*ppDb, 0, DB_SchemaLoaded) ){
2135
+ ENC(*ppDb) = SQLITE_UTF16NATIVE;
2136
+ }
2137
+ }else{
2138
+ rc = SQLITE_NOMEM;
2139
+ }
2140
+ sqlite3ValueFree(pVal);
2141
+
2142
+ return sqlite3ApiExit(0, rc);
2143
+ }
2144
+ #endif // * SQLITE_OMIT_UTF16 */
2145
+
2146
+ /*
2147
+ ** Register a new collation sequence with the database handle db.
2148
+ */
2149
+ static int sqlite3_create_collation(
2150
+ sqlite3 db,
2151
+ string zName,
2152
+ int enc,
2153
+ object pCtx,
2154
+ dxCompare xCompare
2155
+ )
2156
+ {
2157
+ int rc;
2158
+ sqlite3_mutex_enter( db.mutex );
2159
+ //Debug.Assert( 0 == db.mallocFailed );
2160
+ rc = createCollation( db, zName, (u8)enc, SQLITE_COLL_USER, pCtx, xCompare, null );
2161
+ rc = sqlite3ApiExit( db, rc );
2162
+ sqlite3_mutex_leave( db.mutex );
2163
+ return rc;
2164
+ }
2165
+
2166
+ /*
2167
+ ** Register a new collation sequence with the database handle db.
2168
+ */
2169
+ static int sqlite3_create_collation_v2(
2170
+ sqlite3 db,
2171
+ string zName,
2172
+ int enc,
2173
+ object pCtx,
2174
+ dxCompare xCompare, //int(*xCompare)(void*,int,const void*,int,const void*),
2175
+ dxDelCollSeq xDel //void(*xDel)(void*)
2176
+ )
2177
+ {
2178
+ int rc;
2179
+ sqlite3_mutex_enter( db.mutex );
2180
+ //Debug.Assert( 0 == db.mallocFailed );
2181
+ rc = createCollation( db, zName, (u8)enc, SQLITE_COLL_USER, pCtx, xCompare, xDel );
2182
+ rc = sqlite3ApiExit( db, rc );
2183
+ sqlite3_mutex_leave( db.mutex );
2184
+ return rc;
2185
+ }
2186
+
2187
+ #if !SQLITE_OMIT_UTF16
2188
+ /*
2189
+ ** Register a new collation sequence with the database handle db.
2190
+ */
2191
+ //int sqlite3_create_collation16(
2192
+ // sqlite3* db,
2193
+ // string zName,
2194
+ // int enc,
2195
+ // void* pCtx,
2196
+ // int(*xCompare)(void*,int,const void*,int,const void*)
2197
+ //){
2198
+ // int rc = SQLITE_OK;
2199
+ // char *zName8;
2200
+ // sqlite3_mutex_enter(db.mutex);
2201
+ // Debug.Assert( 0==db.mallocFailed );
2202
+ // zName8 = sqlite3Utf16to8(db, zName, -1, SQLITE_UTF16NATIVE);
2203
+ // if( zName8 ){
2204
+ // rc = createCollation(db, zName8, (u8)enc, SQLITE_COLL_USER, pCtx, xCompare, 0);
2205
+ // sqlite3DbFree(db,ref zName8);
2206
+ // }
2207
+ // rc = sqlite3ApiExit(db, rc);
2208
+ // sqlite3_mutex_leave(db.mutex);
2209
+ // return rc;
2210
+ //}
2211
+ #endif // * SQLITE_OMIT_UTF16 */
2212
+
2213
+ /*
2214
+ ** Register a collation sequence factory callback with the database handle
2215
+ ** db. Replace any previously installed collation sequence factory.
2216
+ */
2217
+ static int sqlite3_collation_needed(
2218
+ sqlite3 db,
2219
+ object pCollNeededArg,
2220
+ dxCollNeeded xCollNeeded
2221
+ )
2222
+ {
2223
+ sqlite3_mutex_enter( db.mutex );
2224
+ db.xCollNeeded = xCollNeeded;
2225
+ db.xCollNeeded16 = null;
2226
+ db.pCollNeededArg = pCollNeededArg;
2227
+ sqlite3_mutex_leave( db.mutex );
2228
+ return SQLITE_OK;
2229
+ }
2230
+
2231
+ #if !SQLITE_OMIT_UTF16
2232
+ /*
2233
+ ** Register a collation sequence factory callback with the database handle
2234
+ ** db. Replace any previously installed collation sequence factory.
2235
+ */
2236
+ //int sqlite3_collation_needed16(
2237
+ // sqlite3 db,
2238
+ // void pCollNeededArg,
2239
+ // void(*xCollNeeded16)(void*,sqlite3*,int eTextRep,const void*)
2240
+ //){
2241
+ // sqlite3_mutex_enter(db.mutex);
2242
+ // db.xCollNeeded = 0;
2243
+ // db.xCollNeeded16 = xCollNeeded16;
2244
+ // db.pCollNeededArg = pCollNeededArg;
2245
+ // sqlite3_mutex_leave(db.mutex);
2246
+ // return SQLITE_OK;
2247
+ //}
2248
+ #endif // * SQLITE_OMIT_UTF16 */
2249
+
2250
+ #if !SQLITE_OMIT_GLOBALRECOVER
2251
+ #if !SQLITE_OMIT_DEPRECATED
2252
+ /*
2253
+ ** This function is now an anachronism. It used to be used to recover from a
2254
+ ** malloc() failure, but SQLite now does this automatically.
2255
+ */
2256
+ static int sqlite3_global_recover()
2257
+ {
2258
+ return SQLITE_OK;
2259
+ }
2260
+ #endif
2261
+ #endif
2262
+
2263
+ /*
2264
+ ** Test to see whether or not the database connection is in autocommit
2265
+ ** mode. Return TRUE if it is and FALSE if not. Autocommit mode is on
2266
+ ** by default. Autocommit is disabled by a BEGIN statement and reenabled
2267
+ ** by the next COMMIT or ROLLBACK.
2268
+ **
2269
+ ******* THIS IS AN EXPERIMENTAL API AND IS SUBJECT TO CHANGE ******
2270
+ */
2271
+ static u8 sqlite3_get_autocommit( sqlite3 db )
2272
+ {
2273
+ return db.autoCommit;
2274
+ }
2275
+
2276
+ /*
2277
+ ** The following routines are subtitutes for constants SQLITE_CORRUPT,
2278
+ ** SQLITE_MISUSE, SQLITE_CANTOPEN, SQLITE_IOERR and possibly other error
2279
+ ** constants. They server two purposes:
2280
+ **
2281
+ ** 1. Serve as a convenient place to set a breakpoint in a debugger
2282
+ ** to detect when version error conditions occurs.
2283
+ **
2284
+ ** 2. Invoke sqlite3_log() to provide the source code location where
2285
+ ** a low-level error is first detected.
2286
+ */
2287
+ static int sqlite3CorruptError(int lineno)
2288
+ {
2289
+ testcase(sqlite3GlobalConfig.xLog != null);
2290
+ sqlite3_log(SQLITE_CORRUPT,
2291
+ "database corruption found by source line %d", lineno);
2292
+ return SQLITE_CORRUPT;
2293
+ }
2294
+ static int sqlite3MisuseError(int lineno)
2295
+ {
2296
+ testcase(sqlite3GlobalConfig.xLog != null);
2297
+ sqlite3_log(SQLITE_MISUSE, "misuse detected by source line %d", lineno);
2298
+ return SQLITE_MISUSE;
2299
+ }
2300
+ static int sqlite3CantopenError(int lineno)
2301
+ {
2302
+ testcase(sqlite3GlobalConfig.xLog != null);
2303
+ sqlite3_log(SQLITE_CANTOPEN, "cannot open file at source line %d", lineno);
2304
+ return SQLITE_CANTOPEN;
2305
+ }
2306
+
2307
+ #if !SQLITE_OMIT_DEPRECATED
2308
+ /*
2309
+ ** This is a convenience routine that makes sure that all thread-specific
2310
+ ** data for this thread has been deallocated.
2311
+ **
2312
+ ** SQLite no longer uses thread-specific data so this routine is now a
2313
+ ** no-op. It is retained for historical compatibility.
2314
+ */
2315
+ void sqlite3_thread_cleanup()
2316
+ {
2317
+ }
2318
+ #endif
2319
+ /*
2320
+ ** Return meta information about a specific column of a database table.
2321
+ ** See comment in sqlite3.h (sqlite.h.in) for details.
2322
+ */
2323
+ #if SQLITE_ENABLE_COLUMN_METADATA
2324
+
2325
+ int sqlite3_table_column_metadata(
2326
+ sqlite3 db, /* Connection handle */
2327
+ string zDbName, /* Database name or NULL */
2328
+ string zTableName, /* Table name */
2329
+ string zColumnName, /* Column name */
2330
+ ref byte[] pzDataType, /* OUTPUT: Declared data type */
2331
+ ref byte[] pzCollSeq, /* OUTPUT: Collation sequence name */
2332
+ ref int pNotNull, /* OUTPUT: True if NOT NULL constraint exists */
2333
+ ref int pPrimaryKey, /* OUTPUT: True if column part of PK */
2334
+ ref int pAutoinc /* OUTPUT: True if column is auto-increment */
2335
+ ){
2336
+ int rc;
2337
+ string zErrMsg = "";
2338
+ Table pTab = null;
2339
+ Column pCol = null;
2340
+ int iCol;
2341
+
2342
+ char const *zDataType = 0;
2343
+ char const *zCollSeq = 0;
2344
+ int notnull = 0;
2345
+ int primarykey = 0;
2346
+ int autoinc = 0;
2347
+
2348
+ /* Ensure the database schema has been loaded */
2349
+ sqlite3_mutex_enter(db.mutex);
2350
+ sqlite3BtreeEnterAll(db);
2351
+ rc = sqlite3Init(db, zErrMsg);
2352
+ if( SQLITE_OK!=rc ){
2353
+ goto error_out;
2354
+ }
2355
+
2356
+ /* Locate the table in question */
2357
+ pTab = sqlite3FindTable(db, zTableName, zDbName);
2358
+ if( null==pTab || pTab.pSelect ){
2359
+ pTab = 0;
2360
+ goto error_out;
2361
+ }
2362
+
2363
+ /* Find the column for which info is requested */
2364
+ if( sqlite3IsRowid(zColumnName) ){
2365
+ iCol = pTab.iPKey;
2366
+ if( iCol>=0 ){
2367
+ pCol = pTab.aCol[iCol];
2368
+ }
2369
+ }else{
2370
+ for(iCol=0; iCol<pTab.nCol; iCol++){
2371
+ pCol = pTab.aCol[iCol];
2372
+ if( 0==sqlite3StrICmp(pCol.zName, zColumnName) ){
2373
+ break;
2374
+ }
2375
+ }
2376
+ if( iCol==pTab.nCol ){
2377
+ pTab = 0;
2378
+ goto error_out;
2379
+ }
2380
+ }
2381
+
2382
+ /* The following block stores the meta information that will be returned
2383
+ ** to the caller in local variables zDataType, zCollSeq, notnull, primarykey
2384
+ ** and autoinc. At this point there are two possibilities:
2385
+ **
2386
+ ** 1. The specified column name was rowid", "oid" or "_rowid_"
2387
+ ** and there is no explicitly declared IPK column.
2388
+ **
2389
+ ** 2. The table is not a view and the column name identified an
2390
+ ** explicitly declared column. Copy meta information from pCol.
2391
+ */
2392
+ if( pCol ){
2393
+ zDataType = pCol.zType;
2394
+ zCollSeq = pCol.zColl;
2395
+ notnull = pCol->notNull!=0;
2396
+ primarykey = pCol->isPrimKey!=0;
2397
+ autoinc = pTab.iPKey==iCol && (pTab.tabFlags & TF_Autoincrement)!=0;
2398
+ }else{
2399
+ zDataType = "INTEGER";
2400
+ primarykey = 1;
2401
+ }
2402
+ if( !zCollSeq ){
2403
+ zCollSeq = "BINARY";
2404
+ }
2405
+
2406
+ error_out:
2407
+ sqlite3BtreeLeaveAll(db);
2408
+
2409
+ /* Whether the function call succeeded or failed, set the output parameters
2410
+ ** to whatever their local counterparts contain. If an error did occur,
2411
+ ** this has the effect of zeroing all output parameters.
2412
+ */
2413
+ if( pzDataType ) pzDataType = zDataType;
2414
+ if( pzCollSeq ) pzCollSeq = zCollSeq;
2415
+ if( pNotNull ) pNotNull = notnull;
2416
+ if( pPrimaryKey ) pPrimaryKey = primarykey;
2417
+ if( pAutoinc ) pAutoinc = autoinc;
2418
+
2419
+ if( SQLITE_OK==rc && !pTab ){
2420
+ sqlite3DbFree(db, ref zErrMsg);
2421
+ zErrMsg = sqlite3MPrintf(db, "no such table column: %s.%s", zTableName,
2422
+ zColumnName);
2423
+ rc = SQLITE_ERROR;
2424
+ }
2425
+ sqlite3Error(db, rc, (zErrMsg?"%s":0), zErrMsg);
2426
+ sqlite3DbFree(db, ref zErrMsg);
2427
+ rc = sqlite3ApiExit(db, rc);
2428
+ sqlite3_mutex_leave(db.mutex);
2429
+ return rc;
2430
+ }
2431
+ #endif
2432
+
2433
+ /*
2434
+ ** Sleep for a little while. Return the amount of time slept.
2435
+ */
2436
+ static public int sqlite3_sleep( int ms )
2437
+ {
2438
+ sqlite3_vfs pVfs;
2439
+ int rc;
2440
+ pVfs = sqlite3_vfs_find( null );
2441
+ if ( pVfs == null ) return 0;
2442
+
2443
+ /* This function works in milliseconds, but the underlying OsSleep()
2444
+ ** API uses microseconds. Hence the 1000's.
2445
+ */
2446
+ rc = ( sqlite3OsSleep( pVfs, 1000 * ms ) / 1000 );
2447
+ return rc;
2448
+ }
2449
+
2450
+ /*
2451
+ ** Enable or disable the extended result codes.
2452
+ */
2453
+ static int sqlite3_extended_result_codes( sqlite3 db, bool onoff )
2454
+ {
2455
+ sqlite3_mutex_enter( db.mutex );
2456
+ db.errMask = (int)( onoff ? 0xffffffff : 0xff );
2457
+ sqlite3_mutex_leave( db.mutex );
2458
+ return SQLITE_OK;
2459
+ }
2460
+
2461
+ /*
2462
+ ** Invoke the xFileControl method on a particular database.
2463
+ */
2464
+ static int sqlite3_file_control( sqlite3 db, string zDbName, int op, ref int pArg )
2465
+ {
2466
+ int rc = SQLITE_ERROR;
2467
+ int iDb;
2468
+ sqlite3_mutex_enter( db.mutex );
2469
+ if ( zDbName == null )
2470
+ {
2471
+ iDb = 0;
2472
+ }
2473
+ else
2474
+ {
2475
+ for ( iDb = 0; iDb < db.nDb; iDb++ )
2476
+ {
2477
+ if ( db.aDb[iDb].zName == zDbName ) break;
2478
+ }
2479
+ }
2480
+ if ( iDb < db.nDb )
2481
+ {
2482
+ Btree pBtree = db.aDb[iDb].pBt;
2483
+ if ( pBtree != null )
2484
+ {
2485
+ Pager pPager;
2486
+ sqlite3_file fd;
2487
+ sqlite3BtreeEnter( pBtree );
2488
+ pPager = sqlite3BtreePager( pBtree );
2489
+ Debug.Assert( pPager != null );
2490
+ fd = sqlite3PagerFile( pPager );
2491
+ Debug.Assert( fd != null );
2492
+ if ( fd.pMethods != null )
2493
+ {
2494
+ rc = sqlite3OsFileControl( fd, (u32)op, ref pArg );
2495
+ }
2496
+ sqlite3BtreeLeave( pBtree );
2497
+ }
2498
+ }
2499
+ sqlite3_mutex_leave( db.mutex );
2500
+ return rc;
2501
+ }
2502
+
2503
+ /*
2504
+ ** Interface to the testing logic.
2505
+ */
2506
+ static int sqlite3_test_control( int op, params object[] ap )
2507
+ {
2508
+ int rc = 0;
2509
+ #if !SQLITE_OMIT_BUILTIN_TEST
2510
+ // va_list ap;
2511
+ va_start( ap, "op" );
2512
+ switch ( op )
2513
+ {
2514
+
2515
+ /*
2516
+ ** Save the current state of the PRNG.
2517
+ */
2518
+ case SQLITE_TESTCTRL_PRNG_SAVE:
2519
+ {
2520
+ sqlite3PrngSaveState();
2521
+ break;
2522
+ }
2523
+
2524
+ /*
2525
+ ** Restore the state of the PRNG to the last state saved using
2526
+ ** PRNG_SAVE. If PRNG_SAVE has never before been called, then
2527
+ ** this verb acts like PRNG_RESET.
2528
+ */
2529
+ case SQLITE_TESTCTRL_PRNG_RESTORE:
2530
+ {
2531
+ sqlite3PrngRestoreState();
2532
+ break;
2533
+ }
2534
+
2535
+ /*
2536
+ ** Reset the PRNG back to its uninitialized state. The next call
2537
+ ** to sqlite3_randomness() will reseed the PRNG using a single call
2538
+ ** to the xRandomness method of the default VFS.
2539
+ */
2540
+ case SQLITE_TESTCTRL_PRNG_RESET:
2541
+ {
2542
+ sqlite3PrngResetState();
2543
+ break;
2544
+ }
2545
+
2546
+ /*
2547
+ ** sqlite3_test_control(BITVEC_TEST, size, program)
2548
+ **
2549
+ ** Run a test against a Bitvec object of size. The program argument
2550
+ ** is an array of integers that defines the test. Return -1 on a
2551
+ ** memory allocation error, 0 on success, or non-zero for an error.
2552
+ ** See the sqlite3BitvecBuiltinTest() for additional information.
2553
+ */
2554
+ case SQLITE_TESTCTRL_BITVEC_TEST:
2555
+ {
2556
+ int sz = (int)va_arg( ap, "int" );
2557
+ int[] aProg = (int[])va_arg( ap, "int[]" );
2558
+ rc = sqlite3BitvecBuiltinTest( (u32)sz, aProg );
2559
+ break;
2560
+ }
2561
+
2562
+ /*
2563
+ ** sqlite3_test_control(BENIGN_MALLOC_HOOKS, xBegin, xEnd)
2564
+ **
2565
+ ** Register hooks to call to indicate which malloc() failures
2566
+ ** are benign.
2567
+ */
2568
+ case SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS:
2569
+ {
2570
+ //typedef void (*void_function)(void);
2571
+ void_function xBenignBegin;
2572
+ void_function xBenignEnd;
2573
+ xBenignBegin = (void_function)va_arg( ap, "void_function" );
2574
+ xBenignEnd = (void_function)va_arg( ap, "void_function" );
2575
+ sqlite3BenignMallocHooks( xBenignBegin, xBenignEnd );
2576
+ break;
2577
+ }
2578
+ /*
2579
+ ** sqlite3_test_control(SQLITE_TESTCTRL_PENDING_BYTE, unsigned int X)
2580
+ **
2581
+ ** Set the PENDING byte to the value in the argument, if X>0.
2582
+ ** Make no changes if X==0. Return the value of the pending byte
2583
+ ** as it existing before this routine was called.
2584
+ **
2585
+ ** IMPORTANT: Changing the PENDING byte from 0x40000000 results in
2586
+ ** an incompatible database file format. Changing the PENDING byte
2587
+ ** while any database connection is open results in undefined and
2588
+ ** dileterious behavior.
2589
+ */
2590
+ case SQLITE_TESTCTRL_PENDING_BYTE:
2591
+ {
2592
+ u32 newVal = (u32)va_arg( ap, "u32" );
2593
+ rc = sqlite3PendingByte;
2594
+ if ( newVal != 0 )
2595
+ {
2596
+ if ( sqlite3PendingByte != newVal )
2597
+ sqlite3PendingByte = (int)newVal;
2598
+ #if DEBUG && !NO_TCL
2599
+ TCLsqlite3PendingByte.iValue = sqlite3PendingByte;
2600
+ #endif
2601
+ PENDING_BYTE = sqlite3PendingByte;
2602
+ }
2603
+ break;
2604
+ }
2605
+
2606
+ /*
2607
+ ** sqlite3_test_control(SQLITE_TESTCTRL_ASSERT, int X)
2608
+ **
2609
+ ** This action provides a run-time test to see whether or not
2610
+ ** assert() was enabled at compile-time. If X is true and assert()
2611
+ ** is enabled, then the return value is true. If X is true and
2612
+ ** assert() is disabled, then the return value is zero. If X is
2613
+ ** false and assert() is enabled, then the assertion fires and the
2614
+ ** process aborts. If X is false and assert() is disabled, then the
2615
+ ** return value is zero.
2616
+ */
2617
+ case SQLITE_TESTCTRL_ASSERT:
2618
+ {
2619
+ int x = 0;
2620
+ Debug.Assert( ( x = (int)va_arg( ap, "int" ) ) != 0 );
2621
+ rc = x;
2622
+ break;
2623
+ }
2624
+
2625
+
2626
+ /*
2627
+ ** sqlite3_test_control(SQLITE_TESTCTRL_ALWAYS, int X)
2628
+ **
2629
+ ** This action provides a run-time test to see how the ALWAYS and
2630
+ ** NEVER macros were defined at compile-time.
2631
+ **
2632
+ ** The return value is ALWAYS(X).
2633
+ **
2634
+ ** The recommended test is X==2. If the return value is 2, that means
2635
+ ** ALWAYS() and NEVER() are both no-op pass-through macros, which is the
2636
+ ** default setting. If the return value is 1, then ALWAYS() is either
2637
+ ** hard-coded to true or else it asserts if its argument is false.
2638
+ ** The first behavior (hard-coded to true) is the case if
2639
+ ** SQLITE_TESTCTRL_ASSERT shows that assert() is disabled and the second
2640
+ ** behavior (assert if the argument to ALWAYS() is false) is the case if
2641
+ ** SQLITE_TESTCTRL_ASSERT shows that assert() is enabled.
2642
+ **
2643
+ ** The run-time test procedure might look something like this:
2644
+ **
2645
+ ** if( sqlite3_test_control(SQLITE_TESTCTRL_ALWAYS, 2)==2 ){
2646
+ ** // ALWAYS() and NEVER() are no-op pass-through macros
2647
+ ** }else if( sqlite3_test_control(SQLITE_TESTCTRL_ASSERT, 1) ){
2648
+ ** // ALWAYS(x) asserts that x is true. NEVER(x) asserts x is false.
2649
+ ** }else{
2650
+ ** // ALWAYS(x) is a constant 1. NEVER(x) is a constant 0.
2651
+ ** }
2652
+ */
2653
+ case SQLITE_TESTCTRL_ALWAYS:
2654
+ {
2655
+ int x = (int)va_arg( ap, "int" );
2656
+ rc = ALWAYS( x );
2657
+ break;
2658
+ }
2659
+
2660
+ /* sqlite3_test_control(SQLITE_TESTCTRL_RESERVE, sqlite3 *db, int N)
2661
+ **
2662
+ ** Set the nReserve size to N for the main database on the database
2663
+ ** connection db.
2664
+ */
2665
+ case SQLITE_TESTCTRL_RESERVE:
2666
+ {
2667
+ sqlite3 db = (sqlite3)va_arg( ap, "sqlite3" );
2668
+ int x = (int)va_arg( ap, "int" );
2669
+ sqlite3_mutex_enter( db.mutex );
2670
+ sqlite3BtreeSetPageSize( db.aDb[0].pBt, 0, x, 0 );
2671
+ sqlite3_mutex_leave( db.mutex );
2672
+ break;
2673
+ }
2674
+
2675
+ /* sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS, sqlite3 *db, int N)
2676
+ **
2677
+ ** Enable or disable various optimizations for testing purposes. The
2678
+ ** argument N is a bitmask of optimizations to be disabled. For normal
2679
+ ** operation N should be 0. The idea is that a test program (like the
2680
+ ** SQL Logic Test or SLT test module) can run the same SQL multiple times
2681
+ ** with various optimizations disabled to verify that the same answer
2682
+ ** is obtained in every case.
2683
+ */
2684
+ case SQLITE_TESTCTRL_OPTIMIZATIONS:
2685
+ {
2686
+ sqlite3 db = (sqlite3)va_arg( ap, "sqlite3" );//sqlite3 *db = va_arg(ap, sqlite3*);
2687
+ int x = (int)va_arg( ap, "int" );//int x = va_arg(ap,int);
2688
+ db.flags = ( x & SQLITE_OptMask ) | ( db.flags & ~SQLITE_OptMask );
2689
+ break;
2690
+ }
2691
+
2692
+ //#ifdef SQLITE_N_KEYWORD
2693
+ /* sqlite3_test_control(SQLITE_TESTCTRL_ISKEYWORD, const char *zWord)
2694
+ **
2695
+ ** If zWord is a keyword recognized by the parser, then return the
2696
+ ** number of keywords. Or if zWord is not a keyword, return 0.
2697
+ **
2698
+ ** This test feature is only available in the amalgamation since
2699
+ ** the SQLITE_N_KEYWORD macro is not defined in this file if SQLite
2700
+ ** is built using separate source files.
2701
+ */
2702
+ case SQLITE_TESTCTRL_ISKEYWORD:
2703
+ {
2704
+ string zWord = (string)va_arg( ap, "char*" );
2705
+ int n = sqlite3Strlen30( zWord );
2706
+ rc = ( sqlite3KeywordCode( zWord, n ) != TK_ID ) ? SQLITE_N_KEYWORD : 0;
2707
+ break;
2708
+ }
2709
+ //#endif
2710
+ }
2711
+ va_end( ap );
2712
+ #endif //* SQLITE_OMIT_BUILTIN_TEST */
2713
+ return rc;
2714
+ }
2715
+ }
2716
+ }