2
0

common.bmx 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. ' Copyright (c) 2007-2023 Bruce A Henderson
  2. ' All rights reserved.
  3. '
  4. ' Redistribution and use in source and binary forms, with or without
  5. ' modification, are permitted provided that the following conditions are met:
  6. ' * Redistributions of source code must retain the above copyright
  7. ' notice, this list of conditions and the following disclaimer.
  8. ' * Redistributions in binary form must reproduce the above copyright
  9. ' notice, this list of conditions and the following disclaimer in the
  10. ' documentation and/or other materials provided with the distribution.
  11. ' * Neither the auther nor the names of its contributors may be used to
  12. ' endorse or promote products derived from this software without specific
  13. ' prior written permission.
  14. '
  15. ' THIS SOFTWARE IS PROVIDED BY Bruce A Henderson ``AS IS'' AND ANY
  16. ' EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  17. ' WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  18. ' DISCLAIMED. IN NO EVENT SHALL Bruce A Henderson BE LIABLE FOR ANY
  19. ' DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  20. ' (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  21. ' LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  22. ' ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  23. ' (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  24. ' SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25. '
  26. SuperStrict
  27. ' source
  28. Import "src/*.h"
  29. Import "src/sqlite3.c"
  30. ?linux
  31. Import "-ldl" ' links to the dynamic link library library
  32. ?
  33. Import "sqlitehelper.c"
  34. ' Constants
  35. Const SQLITE_OK:Int = 0 ' Successful result
  36. Const SQLITE_ERROR:Int = 1 ' SQL error Or missing database
  37. Const SQLITE_INTERNAL:Int = 2 ' An internal logic error in SQLite
  38. Const SQLITE_PERM:Int = 3 ' Access permission denied
  39. Const SQLITE_ABORT:Int = 4 ' Callback routine requested an abort
  40. Const SQLITE_BUSY:Int = 5 ' The database file is locked
  41. Const SQLITE_LOCKED:Int = 6 ' A table in the database is locked
  42. Const SQLITE_NOMEM:Int = 7 ' A malloc() failed
  43. Const SQLITE_READONLY:Int = 8 ' Attempt To write a readonly database
  44. Const SQLITE_INTERRUPT:Int = 9 ' Operation terminated by sqlite_interrupt()
  45. Const SQLITE_IOERR:Int = 10 ' Some kind of disk I/O error occurred
  46. Const SQLITE_CORRUPT:Int = 11 ' The database disk image is malformed
  47. Const SQLITE_NOTFOUND:Int = 12 ' (Internal Only) Table Or record Not found
  48. Const SQLITE_FULL:Int = 13 ' Insertion failed because database is full
  49. Const SQLITE_CANTOPEN:Int = 14 ' Unable To open the database file
  50. Const SQLITE_PROTOCOL:Int = 15 ' Database lock protocol error
  51. Const SQLITE_EMPTY:Int = 16 ' (Internal Only) Database table is empty
  52. Const SQLITE_SCHEMA:Int = 17 ' The database schema changed
  53. Const SQLITE_TOOBIG:Int = 18 ' Too much data For one row of a table
  54. Const SQLITE_CONSTRAINT:Int = 19 ' Abort due To constraint violation
  55. Const SQLITE_MISMATCH:Int = 20 ' Data Type mismatch
  56. Const SQLITE_MISUSE:Int = 21 ' Library used incorrectly
  57. Const SQLITE_NOLFS:Int = 22 ' Uses OS features Not supported on host
  58. Const SQLITE_AUTH:Int = 23 ' Authorization denied
  59. Const SQLITE_FORMAT:Int = 24 ' Not used
  60. Const SQLITE_RANGE:Int = 25 ' 2nd parameter to sqlite3_bind out of range
  61. Const SQLITE_NOTADB:Int = 26 ' File opened that is not a database file
  62. Const SQLITE_NOTICE:Int = 27 ' Notifications from sqlite3_log()
  63. Const SQLITE_WARNING:Int = 28 ' Warnings from sqlite3_log()
  64. Const SQLITE_ROW:Int = 100 ' sqlite_step() has another row ready
  65. Const SQLITE_DONE:Int = 101 ' sqlite_step() has finished executing
  66. Const SQLITE_INTEGER:Int = 1
  67. Const SQLITE_FLOAT:Int = 2
  68. Const SQLITE_TEXT:Int = 3
  69. Const SQLITE_BLOB:Int = 4
  70. Const SQLITE_NULL:Int = 5
  71. Const SQLITE_OPEN_READONLY:Int = $00000001 ' Ok for sqlite3_open_v2()
  72. Const SQLITE_OPEN_READWRITE:Int = $00000002 ' Ok for sqlite3_open_v2()
  73. Const SQLITE_OPEN_CREATE:Int = $00000004 ' Ok for sqlite3_open_v2()
  74. Const SQLITE_OPEN_DELETEONCLOSE:Int = $00000008 ' VFS only
  75. Const SQLITE_OPEN_EXCLUSIVE:Int = $00000010 ' VFS only
  76. Const SQLITE_OPEN_AUTOPROXY:Int = $00000020 ' VFS only
  77. Const SQLITE_OPEN_URI:Int = $00000040 ' Ok for sqlite3_open_v2()
  78. Const SQLITE_OPEN_MEMORY:Int = $00000080 ' Ok for sqlite3_open_v2()
  79. Const SQLITE_OPEN_MAIN_DB:Int = $00000100 ' VFS only
  80. Const SQLITE_OPEN_TEMP_DB:Int = $00000200 ' VFS only
  81. Const SQLITE_OPEN_TRANSIENT_DB:Int = $00000400 ' VFS only
  82. Const SQLITE_OPEN_MAIN_JOURNAL:Int = $00000800 ' VFS only
  83. Const SQLITE_OPEN_TEMP_JOURNAL:Int = $00001000 ' VFS only
  84. Const SQLITE_OPEN_SUBJOURNAL:Int = $00002000 ' VFS only
  85. Const SQLITE_OPEN_MASTER_JOURNAL:Int = $00004000 ' VFS only
  86. Const SQLITE_OPEN_NOMUTEX:Int = $00008000 ' Ok for sqlite3_open_v2()
  87. Const SQLITE_OPEN_FULLMUTEX:Int = $00010000 ' Ok for sqlite3_open_v2()
  88. Const SQLITE_OPEN_SHAREDCACHE:Int = $00020000 ' Ok for sqlite3_open_v2()
  89. Const SQLITE_OPEN_PRIVATECACHE:Int = $00040000 ' Ok for sqlite3_open_v2()
  90. Const SQLITE_OPEN_WAL:Int = $00080000 ' VFS only
  91. Const SQLITE_OPEN_NOFOLLOW:Int = $01000000 ' Ok for sqlite3_open_v2()
  92. Const SQLITE_OPEN_EXRESCODE:Int = $02000000 ' Extended result codes
  93. ' Externs
  94. Extern
  95. Function sqlite3_close:Int(handle:Byte Ptr)
  96. Function sqlite3_open_v2:Int(dhname:Byte Ptr, handle:Byte Ptr, flags:Int, fvs:Byte Ptr)
  97. Function sqlite3_prepare_v2:Int(dbhandle:Byte Ptr, sql:Byte Ptr, size:Int, stmtHandle:Byte Ptr Ptr, pzTail:Int)
  98. Function sqlite3_finalize(stmtHandle:Byte Ptr)
  99. Function sqlite3_reset:Int(stmtHandle:Byte Ptr)
  100. Function sqlite3_step:Int(stmtHandle:Byte Ptr)
  101. Function sqlite3_column_count:Int(stmtHandle:Byte Ptr)
  102. Function sqlite3_column_name:Byte Ptr(stmtHandle:Byte Ptr, index:Int)
  103. Function sqlite3_column_decltype:Byte Ptr(stmtHandle:Byte Ptr, index:Int)
  104. Function sqlite3_column_type:Int(stmtHandle:Byte Ptr, index:Int)
  105. Function sqlite3_column_int:Int(stmtHandle:Byte Ptr, index:Int)
  106. Function sqlite3_column_int64:Long(stmtHandle:Byte Ptr, index:Int)
  107. Function sqlite3_column_double:Double(stmtHandle:Byte Ptr, index:Int)
  108. Function sqlite3_column_blob:Byte Ptr(stmtHandle:Byte Ptr, index:Int)
  109. Function sqlite3_column_bytes:Int(stmtHandle:Byte Ptr, index:Int)
  110. Function sqlite3_column_text:Byte Ptr(stmtHandle:Byte Ptr, index:Int)
  111. Function sqlite3_bind_parameter_count:Int(stmtHandle:Byte Ptr)
  112. Function sqlite3_bind_null:Int(stmtHandle:Byte Ptr, index:Int)
  113. Function sqlite3_bind_int:Int(stmtHandle:Byte Ptr, index:Int, value:Int)
  114. Function sqlite3_bind_int64:Int(stmtHandle:Byte Ptr, index:Int, value:Long)
  115. Function sqlite3_bind_double:Int(stmtHandle:Byte Ptr, index:Int, value:Double)
  116. Function sqlite3_changes:Int(handle:Byte Ptr)
  117. Function sqlite3_errmsg:Byte Ptr(handle:Byte Ptr)
  118. Function sqlite3_backup_init:Byte Ptr(toHandle:Byte Ptr, dbTo:Byte Ptr, fromHandle:Byte Ptr, dbFrom:Byte Ptr)
  119. Function sqlite3_backup_step:Int(handle:Byte Ptr, page:Int)
  120. Function sqlite3_backup_finish:Int(handle:Byte Ptr)
  121. Function sqlite3_errcode:Int(handle:Byte Ptr)
  122. Function bmx_sqlite3_bind_text64:Int(stmtHandle:Byte Ptr, index:Int, value:Byte Ptr, size:Long, how:Int)
  123. Function bmx_sqlite3_bind_blob64:Int(stmtHandle:Byte Ptr, index:Int, value:Byte Ptr, size:Long, how:Int)
  124. Function bmx_sqlite3_column_int64(stmtHandle:Byte Ptr, index:Int, value:Long Ptr)
  125. Function bmx_sqlite3_last_insert_rowid(handle:Byte Ptr, id:Long Ptr)
  126. Function sqlite3_user_authenticate:Int(dbhandle:Byte Ptr, username:Byte Ptr, password:Byte Ptr, passlen:Int)
  127. Function sqlite3_user_add:Int(dbhandle:Byte Ptr, username:Byte Ptr, password:Byte Ptr, passlen:Int, isAdmin:Int)
  128. Function sqlite3_user_change:Int(dbhandle:Byte Ptr, username:Byte Ptr, password:Byte Ptr, passlen:Int, isAdmin:Int)
  129. Function sqlite3_user_delete:Int(dbhandle:Byte Ptr, username:Byte Ptr)
  130. End Extern