1 (defpackage :sqlite-ffi
14 :sqlite3-clear-bindings
19 :sqlite3-column-double
23 :sqlite3-bind-parameter-count
24 :sqlite3-bind-parameter-name
25 :sqlite3-bind-parameter-index
33 :sqlite3-last-insert-rowid
))
35 (in-package :sqlite-ffi
)
37 (define-foreign-library sqlite3-lib
38 (:darwin
(:default
"libsqlite3"))
39 (:unix
(:or
"libsqlite3.so.0" "libsqlite3.so"))
40 (t (:or
(:default
"libsqlite3") (:default
"sqlite3"))))
42 (use-foreign-library sqlite3-lib
)
77 (defctype p-sqlite3
(:pointer sqlite3
))
79 (defcfun sqlite3-open error-code
81 (db (:pointer p-sqlite3
)))
83 (defcfun sqlite3-close error-code
86 (defcfun sqlite3-errmsg
:string
89 (defcfun sqlite3-busy-timeout
:int
93 (defcstruct sqlite3-stmt
)
95 (defctype p-sqlite3-stmt
(:pointer sqlite3-stmt
))
97 (defcfun (sqlite3-prepare "sqlite3_prepare_v2") error-code
100 (sql-length-bytes :int
)
101 (stmt (:pointer p-sqlite3-stmt
))
102 (tail (:pointer
(:pointer
:char
))))
104 (defcfun sqlite3-finalize error-code
105 (statement p-sqlite3-stmt
))
107 (defcfun sqlite3-step error-code
108 (statement p-sqlite3-stmt
))
110 (defcfun sqlite3-reset error-code
111 (statement p-sqlite3-stmt
))
113 (defcfun sqlite3-clear-bindings error-code
114 (statement p-sqlite3-stmt
))
116 (defcfun sqlite3-column-count
:int
117 (statement p-sqlite3-stmt
))
126 (defcfun sqlite3-column-type type-code
127 (statement p-sqlite3-stmt
)
128 (column-number :int
))
130 (defcfun sqlite3-column-text
:string
131 (statement p-sqlite3-stmt
)
132 (column-number :int
))
134 (defcfun sqlite3-column-int64
:int64
135 (statement p-sqlite3-stmt
)
136 (column-number :int
))
138 (defcfun sqlite3-column-double
:double
139 (statement p-sqlite3-stmt
)
140 (column-number :int
))
142 (defcfun sqlite3-column-bytes
:int
143 (statement p-sqlite3-stmt
)
144 (column-number :int
))
146 (defcfun sqlite3-column-blob
:pointer
147 (statement p-sqlite3-stmt
)
148 (column-number :int
))
150 (defcfun sqlite3-column-name
:string
151 (statement p-sqlite3-stmt
)
152 (column-number :int
))
154 (defcfun sqlite3-bind-parameter-count
:int
155 (statement p-sqlite3-stmt
))
157 (defcfun sqlite3-bind-parameter-name
:string
158 (statement p-sqlite3-stmt
)
159 (column-number :int
))
161 (defcfun sqlite3-bind-parameter-index
:int
162 (statement p-sqlite3-stmt
)
165 (defcfun sqlite3-bind-double error-code
166 (statement p-sqlite3-stmt
)
167 (parameter-index :int
)
170 (defcfun sqlite3-bind-int64 error-code
171 (statement p-sqlite3-stmt
)
172 (parameter-index :int
)
175 (defcfun sqlite3-bind-null error-code
176 (statement p-sqlite3-stmt
)
177 (parameter-index :int
))
179 (defcfun sqlite3-bind-text error-code
180 (statement p-sqlite3-stmt
)
181 (parameter-index :int
)
184 (destructor :pointer
))
186 (defcfun sqlite3-bind-blob error-code
187 (statement p-sqlite3-stmt
)
188 (parameter-index :int
)
191 (destructor :pointer
))
193 (defconstant destructor-transient-address
(mod -
1 (expt 2 (* 8 (cffi:foreign-type-size
:pointer
)))))
195 (defun destructor-transient () (cffi:make-pointer destructor-transient-address
))
197 (defun destructor-static () (cffi:make-pointer
0))
199 (defcfun sqlite3-last-insert-rowid
:int64