X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=db-sqlite%2Fsqlite-loader.lisp;fp=db-sqlite%2Fsqlite-loader.lisp;h=5b1eef981062e58931cf65fbe2b44159bf2afa30;hb=fd3c9c9f21ff40904bf27eb7a797bbd6c2d80630;hp=0000000000000000000000000000000000000000;hpb=4c8a9a8b403c20cdc78fc427ae06e70536666119;p=clsql.git diff --git a/db-sqlite/sqlite-loader.lisp b/db-sqlite/sqlite-loader.lisp new file mode 100644 index 0000000..5b1eef9 --- /dev/null +++ b/db-sqlite/sqlite-loader.lisp @@ -0,0 +1,52 @@ +;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*- +;;;; ************************************************************************* +;;;; FILE IDENTIFICATION +;;;; +;;;; Name: sqlite-loader.lisp +;;;; Purpose: SQLite library loader using UFFI +;;;; Programmer: Aurelio Bignoli +;;;; Date Started: Nov 2003 +;;;; +;;;; $Id: sqlite-loader.lisp,v 1.2 2003/12/03 14:07:31 aurelio Exp $ +;;;; +;;;; This file, part of CLSQL, is Copyright (c) 2003 by Aurelio Bignoli +;;;; +;;;; CLSQL users are granted the rights to distribute and use this software +;;;; as governed by the terms of the Lisp Lesser GNU Public License +;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL. +;;;; ************************************************************************* + +(in-package :clsql-sqlite) + +(defvar *sqlite-supporting-libraries* '("c") + "Used only by CMU. List of library flags needed to be passed to ld +to load the SQLite library succesfully. If this differs at your site, +set to the right path before compiling or loading the system.") + +(defvar *sqlite-library-loaded* #+clisp t + #-clisp nil + "T if foreign library was able to be loaded successfully") + +(defmethod database-type-library-loaded ((database-type (eql :sqlite))) + "T if foreign library was able to be loaded successfully. " + *sqlite-library-loaded*) + +(defmethod database-type-load-foreign ((database-type (eql :sqlite))) + #+clisp + t + #-clisp + (let ((libpath (uffi:find-foreign-library + "libsqlite" + '("/usr/lib/" "/usr/local/lib/") + :drive-letters '("C" "D" "E")))) + (if (uffi:load-foreign-library libpath + :module "sqlite" + :supporting-libraries + *sqlite-supporting-libraries*) + (setq *sqlite-library-loaded* t) + (warn "Can't load SQLite library ~A" libpath)))) + +(clsql-base-sys:database-type-load-foreign :sqlite) + + +