X-Git-Url: http://git.kpe.io/?p=clsql.git;a=blobdiff_plain;f=db-oracle%2Foracle-loader.lisp;h=f1493d3a1a585fb0d8c2d103d92a590f5d13b4c0;hp=6d91e8dc1847faeb1ec10ea88d9ad01b3cd32250;hb=d2d49ab13c98bc7a1819a0fd3968268a5567bdc3;hpb=319c3f230d40fe8d37203a9a53129ffe6a095c62 diff --git a/db-oracle/oracle-loader.lisp b/db-oracle/oracle-loader.lisp index 6d91e8d..f1493d3 100644 --- a/db-oracle/oracle-loader.lisp +++ b/db-oracle/oracle-loader.lisp @@ -5,8 +5,6 @@ ;;;; Name: oracle-loader.lisp ;;;; Purpose: Foreign library loader for CLSQL Oracle interface ;;;; -;;;; $Id$ -;;;; ;;;; This file is part of CLSQL. ;;;; ;;;; CLSQL users are granted the rights to distribute and use this software @@ -16,22 +14,14 @@ (in-package #:clsql-oracle) -(defparameter *oracle-lib-path* +(defparameter *oracle-home* (let ((oracle-home (getenv "ORACLE_HOME"))) (when oracle-home - (make-pathname :directory - (append - (pathname-directory - (parse-namestring (concatenate 'string oracle-home "/"))) - (list "lib")))))) - -(defparameter *oracle-client-library-path* - (uffi:find-foreign-library - "libclntsh" - `(,@(when *load-truename* (list (make-pathname :directory (pathname-directory *load-truename*)))) - ,@(when *oracle-lib-path* (list *oracle-lib-path*)) - "/usr/lib/oracle/10.1.0.2/client/lib/") - :drive-letters '("C"))) + (parse-namestring (concatenate 'string oracle-home "/")))) + "Pathname of ORACLE_HOME as set in user environment.") + +(defparameter *oracle-client-library-filenames* + (list "libclntsh" "oci")) (defvar *oracle-supporting-libraries* '("c") "Used only by CMU. List of library flags needed to be passed to ld to @@ -45,14 +35,18 @@ set to the right path before compiling or loading the system.") *oracle-library-loaded*) (defmethod clsql-sys:database-type-load-foreign ((database-type (eql :oracle))) - (if (pathnamep *oracle-client-library-path*) - (progn - (uffi:load-foreign-library *oracle-client-library-path* - :module "clsql-oracle" - :supporting-libraries - *oracle-supporting-libraries*) - (setq *oracle-library-loaded* t)) - (warn "Unable to load oracle client library."))) + (when *oracle-home* + (dolist (dir-name '("lib" "bin")) + (dolist (lib-name '("libclntsh" "oci")) + (clsql:push-library-path + (make-pathname :name lib-name + :directory (append (pathname-directory *oracle-home*) + (list dir-name))))))) + + (clsql-uffi:find-and-load-foreign-library *oracle-client-library-filenames* + :module "clsql-oracle" + :supporting-libraries *oracle-supporting-libraries*) + (setq *oracle-library-loaded* t)) (clsql-sys:database-type-load-foreign :oracle)