r1730: *** empty log message ***
[clsql.git] / interfaces / mysql / mysql-loader.cl
index ce8b7ceeb3dec44d87b68e65bc2968f739f2a983..d12faddb751623f8e32e0d69d325ee00d201fbb6 100644 (file)
@@ -7,7 +7,7 @@
 ;;;; Programmers:   Kevin M. Rosenberg
 ;;;; Date Started:  Feb 2002
 ;;;;
 ;;;; Programmers:   Kevin M. Rosenberg
 ;;;; Date Started:  Feb 2002
 ;;;;
-;;;; $Id: mysql-loader.cl,v 1.2 2002/03/24 04:01:26 kevin Exp $
+;;;; $Id: mysql-loader.cl,v 1.4 2002/04/01 05:27:55 kevin Exp $
 ;;;;
 ;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
 ;;;;
 ;;;;
 ;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
 ;;;;
@@ -31,7 +31,7 @@
      #+(or mswindows win32) "CLSQL:interfaces;mysql;clsql-mysql.dll"
      ))
 
      #+(or mswindows win32) "CLSQL:interfaces;mysql;clsql-mysql.dll"
      ))
 
-(defvar *mysql-library-filename* 
+(defvar *mysql-library-filename*
     (cond
      ((probe-file "/opt/mysql/lib/mysql/libmysqlclient.so")
       "/opt/mysql/lib/mysql/libmysqlclient.so")
     (cond
      ((probe-file "/opt/mysql/lib/mysql/libmysqlclient.so")
       "/opt/mysql/lib/mysql/libmysqlclient.so")
       (warn "Can't find MySQL client library to load.")))
   "Location where the MySQL client library is to be found.")
 
       (warn "Can't find MySQL client library to load.")))
   "Location where the MySQL client library is to be found.")
 
+(defvar *mysql-library-candidate-names*
+    '("libmysqlclient" "libmysql"))
+
+(defvar *mysql-library-candidate-directories*
+    '("/opt/mysql/lib/mysql/" "/usr/local/lib/" "/usr/lib/" "/mysql/lib/opt/"))
+
+(defvar *mysql-library-candidate-drive-letters* '("C" "D" "E"))
+
 (defvar *mysql-supporting-libraries* '("c")
   "Used only by CMU. List of library flags needed to be passed to ld to
 load the MySQL client library succesfully.  If this differs at your site,
 (defvar *mysql-supporting-libraries* '("c")
   "Used only by CMU. List of library flags needed to be passed to ld to
 load the MySQL client library succesfully.  If this differs at your site,
@@ -54,23 +62,28 @@ set to the right path before compiling or loading the system.")
 (defvar *mysql-library-loaded* nil
   "T if foreign library was able to be loaded successfully")
 
 (defvar *mysql-library-loaded* nil
   "T if foreign library was able to be loaded successfully")
 
-(defmethod database-type-library-loaded ((database-type (eql :mysql)))
+(defmethod clsql-sys:database-type-library-loaded ((database-type (eql :mysql)))
   *mysql-library-loaded*)
                                      
   *mysql-library-loaded*)
                                      
-(defmethod database-type-load-foreign ((database-type (eql :mysql)))
-  (when
-      (and
-       (uffi:load-foreign-library *mysql-library-filename* 
-                                 :module "mysql" 
-                                 :supporting-libraries 
-                                 *mysql-supporting-libraries*)
-       (uffi:load-foreign-library *clsql-mysql-library-filename* 
-                                 :module "clsql-mysql" 
-                                 :supporting-libraries 
-                                 (append *mysql-supporting-libraries*)))
-    (setq *mysql-library-loaded* t)))
+(defmethod clsql-sys:database-type-load-foreign ((database-type (eql :mysql)))
+  (let ((mysql-path
+        (uffi:find-foreign-library *mysql-library-candidate-names*
+                                   *mysql-library-candidate-directories*
+                                   :drive-letters
+                                   *mysql-library-candidate-drive-letters*)))
+    (when
+       (and
+        (uffi:load-foreign-library mysql-path
+                                   :module "mysql" 
+                                   :supporting-libraries 
+                                   *mysql-supporting-libraries*)
+        (uffi:load-foreign-library *clsql-mysql-library-filename* 
+                                   :module "clsql-mysql" 
+                                   :supporting-libraries 
+                                   (append *mysql-supporting-libraries*)))
+      (setq *mysql-library-loaded* t))))
 
 
 
 
-(database-type-load-foreign :mysql)
+(clsql-sys:database-type-load-foreign :mysql)