r9336: 12 May 2004 Kevin Rosenberg (kevin@rosenberg.net)
[clsql.git] / db-odbc / odbc-loader.lisp
1 ;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
2 ;;;; *************************************************************************
3 ;;;; FILE IDENTIFICATION
4 ;;;;
5 ;;;; Name:          odbc-loader.sql
6 ;;;; Purpose:       ODBC library loader using UFFI
7 ;;;; Programmers:   Kevin M. Rosenberg
8 ;;;; Date Started:  April 2004
9 ;;;;
10 ;;;; $Id: odbc-loader.lisp 8270 2003-11-25 06:37:14Z kevin $
11 ;;;;
12 ;;;; This file, part of CLSQL, is Copyright (c) 2004 by Kevin M. Rosenberg
13 ;;;;
14 ;;;; CLSQL users are granted the rights to distribute and use this software
15 ;;;; as governed by the terms of the Lisp Lesser GNU Public License
16 ;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL.
17 ;;;; *************************************************************************
18
19 (in-package #:odbc)
20
21 (defparameter *odbc-library-path* 
22   (uffi:find-foreign-library
23    '("odbc32" "libodbc" "libiodbc")
24    `(,(make-pathname :directory (pathname-directory *load-truename*))
25      #+64bit "/usr/lib64/"
26       "/usr/lib/"
27       "/sw/lib/"
28       "/usr/local/lib/"
29       "/home/kevin/debian/src/clsql/db-odbc/"
30       "/windows/system32/"
31       "/odbc/lib/opt/")
32    :drive-letters '("C")))
33   
34 (defvar *odbc-supporting-libraries* '("c")
35   "Used only by CMU. List of library flags needed to be passed to ld to
36 load the Odbc client library succesfully.  If this differs at your site,
37 set to the right path before compiling or loading the system.")
38
39 (defvar *odbc-library-loaded* nil
40   "T if foreign library was able to be loaded successfully")
41
42 (defmethod clsql-sys:database-type-library-loaded ((database-type (eql :odbc)))
43   *odbc-library-loaded*)
44                                       
45 (defmethod clsql-sys:database-type-load-foreign ((database-type (eql :odbc)))
46   (uffi:load-foreign-library *odbc-library-path*
47                              :module "odbc") 
48   (setq *odbc-library-loaded* t))
49
50 (clsql-sys:database-type-load-foreign :odbc)
51
52
53