(module sqlite-ffi mzscheme
(require (lib "foreign.ss"))
(unsafe!)
(provide (all-from (lib "foreign.ss"))
(all-defined))
(define sqlite (ffi-lib "libsqlite3"))
(define-syntax define-sqlite
(syntax-rules ()
[(_ id type)
(define id (get-ffi-obj (quote id) sqlite type))]))
(define _sqlite3_ptr _pointer)
(define _sqlite3_ptr_ptr _pointer)
(define _sqlite3_stmt_ptr _pointer)
(define _sqlite3_stmt_ptr_ptr _pointer)
(define _sqlite_callback (_fun _pointer _int _pointer _pointer -> _int))
(define _sqlite3_busy_handler (_fun _pointer _int -> _int))
(define _string_ptr _pointer)
(define _string_array _pointer)
(define _string_array_ptr _pointer)
(define _int_ptr _pointer)
(define-sqlite sqlite3_libversion_number (_fun -> _int))
(define-sqlite sqlite3_close (_fun _sqlite3_ptr -> _int))
(define-sqlite sqlite3_exec (_fun _sqlite3_ptr _string _sqlite_callback _string_array _string_array -> _int))
(define-sqlite sqlite3_last_insert_rowid (_fun _sqlite3_ptr -> _int64))
(define-sqlite sqlite3_changes (_fun _sqlite3_ptr -> _int))
(define-sqlite sqlite3_total_changes (_fun _sqlite3_ptr -> _int))
(define-sqlite sqlite3_interrupt (_fun _sqlite3_ptr -> _void))
(define-sqlite sqlite3_complete (_fun _string -> _int))
(define-sqlite sqlite3_get_table (_fun _sqlite3_ptr _string _string_array_ptr _int_ptr _int_ptr _pointer -> _int))
(define-sqlite sqlite3_free_table (_fun _string_array -> _void))
(define-sqlite sqlite3_open (_fun _path _sqlite3_ptr_ptr -> _int))
(define-sqlite sqlite3_errcode (_fun _sqlite3_ptr -> _int))
(define-sqlite sqlite3_errmsg (_fun _sqlite3_ptr -> _string))
(define-sqlite sqlite3_prepare (_fun _sqlite3_ptr _string _int _sqlite3_stmt_ptr_ptr _string_ptr -> _int))
(define-sqlite sqlite3_bind_int (_fun _sqlite3_stmt_ptr _int _int -> _int))
(define-sqlite sqlite3_bind_double (_fun _sqlite3_stmt_ptr _int _double -> _int))
(define-sqlite sqlite3_bind_text (_fun (stmt col the-string) ::
(stmt : _sqlite3_stmt_ptr)
(col : _int)
(string-ptr : _string = the-string)
(string-len : _int = (string-length the-string))
(flag : _int = -1)
-> _int))
(define-sqlite sqlite3_bind_blob (_fun (stmt col the-bytes) ::
(stmt : _sqlite3_stmt_ptr)
(col : _int)
(byte-ptr : _bytes = the-bytes)
(byte-len : _int = (bytes-length the-bytes))
(flag : _int = -1)
-> _int))
(define-sqlite sqlite3_bind_null (_fun _sqlite3_stmt_ptr _int -> _int))
(define-sqlite sqlite3_bind_parameter_count (_fun _sqlite3_stmt_ptr -> _int))
(define-sqlite sqlite3_bind_parameter_name (_fun _sqlite3_stmt_ptr _int -> _string))
(define-sqlite sqlite3_bind_parameter_index (_fun _sqlite3_stmt_ptr _string -> _int))
(define-sqlite sqlite3_column_count (_fun _sqlite3_stmt_ptr -> _int))
(define-sqlite sqlite3_column_name (_fun _sqlite3_stmt_ptr _int -> _string))
(define-sqlite sqlite3_column_decltype (_fun _sqlite3_stmt_ptr _int -> _string))
(define-sqlite sqlite3_step (_fun _sqlite3_stmt_ptr -> _int))
(define-sqlite sqlite3_data_count (_fun _sqlite3_stmt_ptr -> _int))
(define-sqlite sqlite3_column_int (_fun _sqlite3_stmt_ptr _int -> _int))
(define-sqlite sqlite3_column_double (_fun _sqlite3_stmt_ptr _int -> _double))
(define-sqlite sqlite3_column_text (_fun _sqlite3_stmt_ptr _int -> _string))
(define-sqlite sqlite3_column_bytes (_fun _sqlite3_stmt_ptr _int -> _int))
(define-sqlite sqlite3_column_blob (_fun (stmt : _sqlite3_stmt_ptr)
(col : _int)
-> (blob : _bytes)
-> (let ([len (sqlite3_column_bytes stmt col)])
(make-sized-byte-string blob len))))
(define-sqlite sqlite3_finalize (_fun _sqlite3_stmt_ptr -> _int))
(define-sqlite sqlite3_reset (_fun _sqlite3_stmt_ptr -> _int))
(define-sqlite sqlite3_expired (_fun _sqlite3_ptr -> _int))
(define SQLITE_OK 0 ) (define SQLITE_ERROR 1 ) (define SQLITE_INTERNAL 2 ) (define SQLITE_PERM 3 ) (define SQLITE_ABORT 4 ) (define SQLITE_BUSY 5 ) (define SQLITE_LOCKED 6 ) (define SQLITE_NOMEM 7 ) (define SQLITE_READONLY 8 ) (define SQLITE_INTERRUPT 9 ) (define SQLITE_IOERR 10 ) (define SQLITE_CORRUPT 11 ) (define SQLITE_NOTFOUND 12 ) (define SQLITE_FULL 13 ) (define SQLITE_CANTOPEN 14 ) (define SQLITE_PROTOCOL 15 ) (define SQLITE_EMPTY 16 ) (define SQLITE_SCHEMA 17 ) (define SQLITE_TOOBIG 18 ) (define SQLITE_CONSTRAINT 19 ) (define SQLITE_MISMATCH 20 ) (define SQLITE_MISUSE 21 ) (define SQLITE_NOLFS 22 ) (define SQLITE_AUTH 23 ) (define SQLITE_FORMAT 24 ) (define SQLITE_RANGE 25 ) (define SQLITE_NOTADB 26 ) (define SQLITE_ROW 100 ) (define SQLITE_DONE 101 )
(define SQLITE_INTEGER 1)
(define SQLITE_FLOAT 2)
(define SQLITE3_TEXT 3)
(define SQLITE_BLOB 4)
(define SQLITE_NULL 5)
(define SQLITE_STATIC 0)
(define SQLITE_TRANSIENT -1)
)