X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=db-sqlite%2Fsqlite-api-uffi.lisp;h=98667493ad0c94c581019abcfb65b9bc7f9f208a;hb=f1ff5842ce264fbe47e8ef98e33e4aca3b71d863;hp=77649a5d15533817e3eb68ddf56f79abf4bd1395;hpb=f68111d8749473df1879d4431aa7c74ee2eea87d;p=clsql.git diff --git a/db-sqlite/sqlite-api-uffi.lisp b/db-sqlite/sqlite-api-uffi.lisp index 77649a5..9866749 100644 --- a/db-sqlite/sqlite-api-uffi.lisp +++ b/db-sqlite/sqlite-api-uffi.lisp @@ -2,14 +2,15 @@ ;;;; ************************************************************************* ;;;; FILE IDENTIFICATION ;;;; -;;;; Name: sqlite-api-uffi.lisp -;;;; Purpose: Low-level SQLite interface using UFFI -;;;; Programmers: Aurelio Bignoli and Kevin Rosenberg -;;;; Date Started: Nov 2003 +;;;; Name: sqlite-api-uffi.lisp +;;;; Purpose: Low-level SQLite interface using UFFI +;;;; Authors: Aurelio Bignoli and Kevin Rosenberg +;;;; Created: Nov 2003 ;;;; ;;;; $Id$ ;;;; ;;;; This file, part of CLSQL, is Copyright (c) 2003 by Aurelio Bignoli +;;;; and Copyright (c) 2003-2004 by Kevin Rosenberg ;;;; ;;;; CLSQL users are granted the rights to distribute and use this software ;;;; as governed by the terms of the Lisp Lesser GNU Public License @@ -84,7 +85,8 @@ :code code :message (if message message - (sqlite-error-string code))))) + (uffi:convert-from-cstring + (sqlite-error-string code)))))) (unless (signal condition) (invoke-debugger condition)))) @@ -92,11 +94,11 @@ ;;;; ;;;; Foreign types definitions. ;;;; -(def-foreign-type errmsg (* :char)) +(def-foreign-type errmsg (* :unsigned-char)) (def-foreign-type sqlite-db :pointer-void) (def-foreign-type sqlite-vm :pointer-void) -(def-foreign-type string-pointer (* (* :char))) -(def-foreign-type sqlite-row-pointer (* string-pointer)) +(def-foreign-type string-pointer (* (* :unsigned-char))) +(def-foreign-type sqlite-row-pointer (* (* :unsigned-char))) (defvar +null-errmsg-pointer+ (make-null-pointer 'errmsg)) (defvar +null-string-pointer-pointer+ (make-null-pointer 'string-pointer)) @@ -151,7 +153,7 @@ ("sqlite_compile" %compile) ((db sqlite-db) (sql :cstring) - (sql-tail (* (* :char))) + (sql-tail (* (* :unsigned-char))) (vm (* sqlite-vm)) (error-message (* errmsg))) :returning :int) @@ -161,8 +163,8 @@ ("sqlite_step" %step) ((vm sqlite-vm) (cols-n (* :int)) - (cols (* (* (* :char)))) - (col-names (* (* (* :char))))) + (cols (* (* (* :unsigned-char)))) + (col-names (* (* (* :unsigned-char))))) :returning :int) (declaim (inline %finalize)) @@ -187,7 +189,7 @@ ("sqlite_get_table" %get-table) ((db sqlite-db) (sql :cstring) - (result (* (* (* :char)))) + (result (* (* (* :unsigned-char)))) (rows-n (* :int)) (cols-n (* :int)) (error-message (* errmsg))) @@ -228,7 +230,7 @@ (defun sqlite-compile (db sql) (with-cstring (sql-native sql) (let ((vm (allocate-foreign-object 'sqlite-vm))) - (with-foreign-object (sql-tail '(* :char)) + (with-foreign-object (sql-tail '(* :unsigned-char)) (let ((result (%compile db sql-native sql-tail vm +null-errmsg-pointer+))) (if (= result SQLITE-OK) vm @@ -239,8 +241,8 @@ (defun sqlite-step (vm) (declare (type sqlite-vm-pointer vm)) (with-foreign-object (cols-n :int) - (let ((cols (allocate-foreign-object '(* (* :char)))) - (col-names (allocate-foreign-object '(* (* :char))))) + (let ((cols (allocate-foreign-object '(* (* :unsigned-char)))) + (col-names (allocate-foreign-object '(* (* :unsigned-char))))) (declare (type sqlite-row-pointer-type cols col-names)) (let ((result (%step (deref-pointer vm 'sqlite-vm) cols-n cols col-names))) @@ -269,7 +271,7 @@ (defun sqlite-get-table (db sql) (declare (type sqlite-db-type db)) (with-cstring (sql-native sql) - (let ((rows (allocate-foreign-object '(* (* :char))))) + (let ((rows (allocate-foreign-object '(* (* :unsigned-char))))) (declare (type sqlite-row-pointer-type rows)) (with-foreign-object (rows-n :int) (with-foreign-object (cols-n :int) @@ -307,7 +309,7 @@ (defun sqlite-aref (a n) (declare (type sqlite-row-pointer-type a)) (convert-from-foreign-string - (deref-array (deref-pointer a 'sqlite-row-pointer) '(:array (* :char)) n))) + (deref-array (deref-pointer a 'sqlite-row-pointer) '(:array (* :unsigned-char)) n))) (declaim (inline sqlite-free-row)) (defun sqlite-free-row (row)