1 (defpackage :sqlite-ffi
13 :sqlite3-clear-bindings
18 :sqlite3-column-double
22 :sqlite3-bind-parameter-count
23 :sqlite3-bind-parameter-name
24 :sqlite3-bind-parameter-index
32 :sqlite3-last-insert-rowid
35 (in-package :sqlite-ffi
)
37 (define-foreign-library sqlite3-lib
38 (:unix
(:or
"libsqlite3.so.0" "libsqlite3.so"))
39 (t (:default
"libsqlite3")))
41 (use-foreign-library sqlite3-lib
)
76 (defctype p-sqlite3
(:pointer sqlite3
))
78 (defcfun sqlite3-open error-code
80 (db (:pointer p-sqlite3
)))
82 (defcfun sqlite3-close error-code
85 (defcfun sqlite3-errmsg
:string
88 (defcstruct sqlite3-stmt
)
90 (defctype p-sqlite3-stmt
(:pointer sqlite3-stmt
))
92 (defcfun (sqlite3-prepare "sqlite3_prepare_v2") error-code
95 (sql-length-bytes :int
)
96 (stmt (:pointer p-sqlite3-stmt
))
97 (tail (:pointer
(:pointer
:char
))))
99 (defcfun sqlite3-finalize error-code
100 (statement p-sqlite3-stmt
))
102 (defcfun sqlite3-step error-code
103 (statement p-sqlite3-stmt
))
105 (defcfun sqlite3-reset error-code
106 (statement p-sqlite3-stmt
))
108 (defcfun sqlite3-clear-bindings error-code
109 (statement p-sqlite3-stmt
))
111 (defcfun sqlite3-column-count
:int
112 (statement p-sqlite3-stmt
))
121 (defcfun sqlite3-column-type type-code
122 (statement p-sqlite3-stmt
)
123 (column-number :int
))
125 (defcfun sqlite3-column-text
:string
126 (statement p-sqlite3-stmt
)
127 (column-number :int
))
129 (defcfun sqlite3-column-int64
:int64
130 (statement p-sqlite3-stmt
)
131 (column-number :int
))
133 (defcfun sqlite3-column-double
:double
134 (statement p-sqlite3-stmt
)
135 (column-number :int
))
137 (defcfun sqlite3-column-bytes
:int
138 (statement p-sqlite3-stmt
)
139 (column-number :int
))
141 (defcfun sqlite3-column-blob
:pointer
142 (statement p-sqlite3-stmt
)
143 (column-number :int
))
145 (defcfun sqlite3-column-name
:string
146 (statement p-sqlite3-stmt
)
147 (column-number :int
))
149 (defcfun sqlite3-bind-parameter-count
:int
150 (statement p-sqlite3-stmt
))
152 (defcfun sqlite3-bind-parameter-name
:string
153 (statement p-sqlite3-stmt
)
154 (column-number :int
))
156 (defcfun sqlite3-bind-parameter-index
:int
157 (statement p-sqlite3-stmt
)
160 (defcfun sqlite3-bind-double error-code
161 (statement p-sqlite3-stmt
)
162 (parameter-index :int
)
165 (defcfun sqlite3-bind-int64 error-code
166 (statement p-sqlite3-stmt
)
167 (parameter-index :int
)
170 (defcfun sqlite3-bind-null error-code
171 (statement p-sqlite3-stmt
)
172 (parameter-index :int
))
174 (defcfun sqlite3-bind-text error-code
175 (statement p-sqlite3-stmt
)
176 (parameter-index :int
)
179 (destructor :pointer
))
181 (defcfun sqlite3-bind-blob error-code
182 (statement p-sqlite3-stmt
)
183 (parameter-index :int
)
186 (destructor :pointer
))
188 (defconstant destructor-transient-address
(mod -
1 (expt 2 (* 8 (cffi:foreign-type-size
:pointer
)))))
190 (defun destructor-transient () (cffi:make-pointer destructor-transient-address
))
192 (defun destructor-static () (cffi:make-pointer
0))
194 (defcfun sqlite3-last-insert-rowid
:int64
197 (defcfun sqlite3-next-stmt p-sqlite3-stmt
199 (stmt p-sqlite3-stmt
))