+09 Jun 2005 Kevin Rosenberg <kevin@rosenberg.net>
+ * clsql-mysql.asd: Renamed uffi/mysql interface library from
+ mysql to uffi_mysql
+ * db-mysql/uffi_mysql.c: Renamed from mysql.c
+ * db-mysql/Makefile, db-mysql/mysql-loader.lisp: Rename shared library
+ * db-*/*-loader.lisp: Commit big patch from Edi Weitz to remove
+ absolute pathnames when searching for foreign libraries.
+ * uffi/clsql-uffi-loader: New file from Edi Weitz for support
+ foreign library loading.
+
07 Jun 2005 Kevin Rosenberg <kevin@rosenberg.net>
* Version 3.1.16
* db-mysql/mysql-api.lisp: Commit patch from Espen Wiborn
(error 'operation-error :component c :operation o))))
(defmethod operation-done-p ((o compile-op) (c clsql-mysql-source-file))
- (or (and (probe-file #p"/usr/lib/clsql/mysql.so") t)
+ (or (and (probe-file #p"/usr/lib/clsql/clsql_mysql.so") t)
(let ((lib (make-pathname :defaults (component-pathname c)
:type (uffi:default-foreign-library-type))))
(and (probe-file lib)
(append
(pathname-directory
(parse-namestring (concatenate 'string db2-home "/")))
- (list "lib"))))))
+ (list "lib"))))))
-(defparameter *db2-client-library-path*
- (uffi:find-foreign-library
- "libdb2"
- `(,@(when *load-truename* (list (make-pathname :directory (pathname-directory *load-truename*))))
- ,@(when *db2-lib-path* (list *db2-lib-path*))
- #+64bit "/opt/IBM/db2/V8.1/lib64/"
- "/opt/IBM/db2/V8.1/lib/")
- :drive-letters '("C")))
+(defparameter *db2-library-filenames*
+ (if *db2-lib-path*
+ (list (merge-pathnames "libdb2" *db2-lib-path*)
+ "libdb2")
+ "libdb2"))
(defvar *db2-supporting-libraries* '("c")
"Used only by CMU. List of library flags needed to be passed to ld to
*db2-library-loaded*)
(defmethod clsql-sys:database-type-load-foreign ((database-type (eql :db2)))
- (if (pathnamep *db2-client-library-path*)
- (progn
- (uffi:load-foreign-library *db2-client-library-path*
- :module "clsql-db2"
- :supporting-libraries
- *db2-supporting-libraries*)
- (setq *db2-library-loaded* t))
- (warn "Unable to load db2 client library.")))
+ (clsql-uffi:find-and-load-foreign-library *db2-library-filenames*
+ :module "clsql-db2"
+ :supporting-libraries
+ *db2-supporting-libraries*)
+ (setq *db2-library-loaded* t))
(clsql-sys:database-type-load-foreign :db2)
include ../Makefile.common
-base=uffi_mysql
+base=clsql_mysql
source=$(base).c
object=$(base).o
-shared_lib=uffi_mysql.so
+shared_lib=$(base).so
+
.PHONY: all
all: $(shared_lib)
--- /dev/null
+/****************************************************************************
+ * FILE IDENTIFICATION
+ *
+ * Name: clsql-mysql.c
+ * Purpose: Helper functions for mysql.cl to handle 64-bit parts of API
+ * Programmer: Kevin M. Rosenberg
+ * Date Started: Mar 2002
+ *
+ * $Id$
+ *
+ * This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. 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
+ * (http://opensource.franz.com/preamble.html), also known as the LLGPL.
+ ***************************************************************************/
+
+#ifdef WIN32
+#include <windows.h>
+
+BOOL WINAPI DllEntryPoint(HINSTANCE hinstdll, DWORD fdwReason,
+ LPVOID lpvReserved)
+{
+ return 1;
+}
+
+#define DLLEXPORT __declspec(dllexport)
+
+#else
+#define DLLEXPORT
+#endif
+
+
+#include <mysql.h>
+
+/* Need to assemble a 64-bit integer to send to MySQL */
+DLLEXPORT
+void
+clsql_mysql_data_seek (MYSQL_RES* res, unsigned int offset_high32,
+ unsigned int offset_low32)
+{
+ my_ulonglong offset;
+
+ offset = offset_high32;
+ offset = offset << 32;
+ offset += offset_low32;
+
+ mysql_data_seek (res, offset);
+}
+
+/* The following functions are used to return 64-bit integers to Lisp.
+ They return the 32-bit low part and store in upper 32-bits in a
+ located sent via a pointer */
+
+static const unsigned int bitmask_32bits = 0xFFFFFFFF;
+#define lower_32bits(int64) ((unsigned int) int64 & bitmask_32bits)
+#define upper_32bits(int64) ((unsigned int) (int64 >> 32))
+
+DLLEXPORT
+unsigned int
+clsql_mysql_num_rows (MYSQL_RES* res, unsigned int* pHigh32)
+{
+ my_ulonglong nRows = mysql_num_rows (res);
+ *pHigh32 = upper_32bits(nRows);
+ return lower_32bits(nRows);
+}
+
+DLLEXPORT
+unsigned int
+clsql_mysql_affected_rows (MYSQL* res, unsigned int* pHigh32)
+{
+ my_ulonglong nAffected = mysql_affected_rows (res);
+ *pHigh32 = upper_32bits(nAffected);
+ return lower_32bits(nAffected);
+}
+
+DLLEXPORT
+unsigned int
+clsql_mysql_insert_id (MYSQL* mysql, unsigned int* pHigh32)
+{
+ my_ulonglong insert_id = mysql_insert_id (mysql);
+ *pHigh32 = upper_32bits(insert_id);
+ return lower_32bits(insert_id);
+}
+
+
+/* Accessor functions to hide the differences across MySQL versions */
+
+DLLEXPORT
+short int
+clsql_mysql_field_type (MYSQL_FIELD* field)
+{
+ return field->type;
+}
+
+DLLEXPORT
+char*
+clsql_mysql_field_name (MYSQL_FIELD* field)
+{
+ return field->name;
+}
+
+DLLEXPORT
+unsigned long
+clsql_mysql_field_length (MYSQL_FIELD* field)
+{
+ return field->length;
+}
+
+DLLEXPORT
+unsigned long
+clsql_mysql_field_max_length (MYSQL_FIELD* field)
+{
+ return field->max_length;
+}
+
+
+#if MYSQL_VERSION_ID >= 40102
+#include <stdlib.h>
+
+DLLEXPORT
+MYSQL_BIND*
+allocate_bind (unsigned int n)
+{
+ return (MYSQL_BIND*) malloc (n * sizeof(MYSQL_BIND));
+}
+
+DLLEXPORT
+void
+bind_param (MYSQL_BIND bind[], unsigned int n, unsigned long length, unsigned short is_null,
+ void* buffer, unsigned short buffer_type, unsigned long buffer_length)
+{
+ *bind[n].length = length;
+ *bind[n].is_null = is_null;
+ bind[n].buffer = buffer;
+ bind[n].buffer_type = buffer_type;
+ bind[n].buffer_length = buffer_length;
+}
+
+
+DLLEXPORT
+DLLEXPORT
+unsigned int
+clsql_mysql_stmt_affected_rows (MYSQL_STMT* stmt, unsigned int* pHigh32)
+{
+ my_ulonglong nAffected = mysql_stmt_affected_rows (stmt);
+ *pHigh32 = upper_32bits(nAffected);
+ return lower_32bits(nAffected);
+}
+
+
+#endif
+
+++ /dev/null
-/****************************************************************************
- * FILE IDENTIFICATION
- *
- * Name: clsql-mysql.c
- * Purpose: Helper functions for mysql.cl to handle 64-bit parts of API
- * Programmer: Kevin M. Rosenberg
- * Date Started: Mar 2002
- *
- * $Id$
- *
- * This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. 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
- * (http://opensource.franz.com/preamble.html), also known as the LLGPL.
- ***************************************************************************/
-
-#ifdef WIN32
-#include <windows.h>
-
-BOOL WINAPI DllEntryPoint(HINSTANCE hinstdll, DWORD fdwReason,
- LPVOID lpvReserved)
-{
- return 1;
-}
-
-#define DLLEXPORT __declspec(dllexport)
-
-#else
-#define DLLEXPORT
-#endif
-
-
-#include <mysql.h>
-
-/* Need to assemble a 64-bit integer to send to MySQL */
-DLLEXPORT
-void
-clsql_mysql_data_seek (MYSQL_RES* res, unsigned int offset_high32,
- unsigned int offset_low32)
-{
- my_ulonglong offset;
-
- offset = offset_high32;
- offset = offset << 32;
- offset += offset_low32;
-
- mysql_data_seek (res, offset);
-}
-
-/* The following functions are used to return 64-bit integers to Lisp.
- They return the 32-bit low part and store in upper 32-bits in a
- located sent via a pointer */
-
-static const unsigned int bitmask_32bits = 0xFFFFFFFF;
-#define lower_32bits(int64) ((unsigned int) int64 & bitmask_32bits)
-#define upper_32bits(int64) ((unsigned int) (int64 >> 32))
-
-DLLEXPORT
-unsigned int
-clsql_mysql_num_rows (MYSQL_RES* res, unsigned int* pHigh32)
-{
- my_ulonglong nRows = mysql_num_rows (res);
- *pHigh32 = upper_32bits(nRows);
- return lower_32bits(nRows);
-}
-
-DLLEXPORT
-unsigned int
-clsql_mysql_affected_rows (MYSQL* res, unsigned int* pHigh32)
-{
- my_ulonglong nAffected = mysql_affected_rows (res);
- *pHigh32 = upper_32bits(nAffected);
- return lower_32bits(nAffected);
-}
-
-DLLEXPORT
-unsigned int
-clsql_mysql_insert_id (MYSQL* mysql, unsigned int* pHigh32)
-{
- my_ulonglong insert_id = mysql_insert_id (mysql);
- *pHigh32 = upper_32bits(insert_id);
- return lower_32bits(insert_id);
-}
-
-
-/* Accessor functions to hide the differences across MySQL versions */
-
-DLLEXPORT
-short int
-clsql_mysql_field_type (MYSQL_FIELD* field)
-{
- return field->type;
-}
-
-DLLEXPORT
-char*
-clsql_mysql_field_name (MYSQL_FIELD* field)
-{
- return field->name;
-}
-
-DLLEXPORT
-unsigned long
-clsql_mysql_field_length (MYSQL_FIELD* field)
-{
- return field->length;
-}
-
-DLLEXPORT
-unsigned long
-clsql_mysql_field_max_length (MYSQL_FIELD* field)
-{
- return field->max_length;
-}
-
-
-#if MYSQL_VERSION_ID >= 40102
-#include <stdlib.h>
-
-DLLEXPORT
-MYSQL_BIND*
-allocate_bind (unsigned int n)
-{
- return (MYSQL_BIND*) malloc (n * sizeof(MYSQL_BIND));
-}
-
-DLLEXPORT
-void
-bind_param (MYSQL_BIND bind[], unsigned int n, unsigned long length, unsigned short is_null,
- void* buffer, unsigned short buffer_type, unsigned long buffer_length)
-{
- *bind[n].length = length;
- *bind[n].is_null = is_null;
- bind[n].buffer = buffer;
- bind[n].buffer_type = buffer_type;
- bind[n].buffer_length = buffer_length;
-}
-
-
-DLLEXPORT
-DLLEXPORT
-unsigned int
-clsql_mysql_stmt_affected_rows (MYSQL_STMT* stmt, unsigned int* pHigh32)
-{
- my_ulonglong nAffected = mysql_stmt_affected_rows (stmt);
- *pHigh32 = upper_32bits(nAffected);
- return lower_32bits(nAffected);
-}
-
-
-#endif
-
(in-package #:odbc)
-(defparameter *odbc-library-path*
- (uffi:find-foreign-library
- '("odbc32" "libodbc" "libiodbc")
- `(,(make-pathname :directory (pathname-directory *load-truename*))
- #+64bit "/usr/lib64/"
- "/usr/lib/"
- "/sw/lib/"
- "/usr/local/lib/"
- "/home/kevin/debian/src/clsql/db-odbc/"
- "/windows/system32/"
- "/winnt/system32/"
- "/odbc/lib/opt/")
- :drive-letters '("C")))
+(defparameter *odbc-library-filenames*
+ '("odbc32" "libodbc" "libiodbc"))
(defvar *odbc-supporting-libraries* '("c")
"Used only by CMU. List of library flags needed to be passed to ld to
*odbc-library-loaded*)
(defmethod clsql-sys:database-type-load-foreign ((database-type (eql :odbc)))
- (uffi:load-foreign-library *odbc-library-path*
- :module "odbc")
+ (clsql-uffi:find-and-load-foreign-library *odbc-library-filenames*
+ :module "odbc")
(setq *odbc-library-loaded* t))
(clsql-sys:database-type-load-foreign :odbc)
(parse-namestring (concatenate 'string oracle-home "/"))))
"Pathname of ORACLE_HOME as set in user environment.")
-(defparameter *oracle-client-library-path*
- (uffi:find-foreign-library
- '("libclntsh" "oci")
- `(,@(when *load-truename*
- (list (make-pathname
- :directory (pathname-directory *load-truename*))))
- ,@(when *oracle-home*
- (list
- (make-pathname :defaults *oracle-home*
- :directory
- (append (pathname-directory *oracle-home*)
- (list "lib")))
- (make-pathname :defaults *oracle-home*
- :directory
- (append (pathname-directory *oracle-home*)
- (list "bin")))))
- "/usr/lib/oracle/10.1.0.2/client/lib/")
- :drive-letters '("C")))
+(defparameter *oracle-client-library-filenames*
+ (list* "libclntsh" "oci"
+ (when *oracle-home*
+ (loop for dir-name in '("lib" "bin")
+ nconc (loop for lib-name in '("libclntsh" "oci")
+ collect (make-pathname :defaults lib-name
+ :directory (append (pathname-directory *oracle-home*)
+ (list dir-name))))))))
(defvar *oracle-supporting-libraries* '("c")
"Used only by CMU. List of library flags needed to be passed to ld to
*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.")))
+ (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)
(defmethod clsql-sys:database-type-load-foreign ((database-type
(eql :postgresql)))
- (let ((libpath (uffi:find-foreign-library
- "libpq"
- '("/opt/postgresql/lib/" "/usr/local/lib/"
- #+(or 64bit x86-64) "/usr/lib64/"
- "/usr/lib/" "/postgresql/lib/"
- "/usr/local/pgsql/lib/" "/usr/lib/pgsql/"
- "/opt/pgsql/lib/pgsql" "/sw/lib/pgsql/" "/sw/lib/"
- "/windows/system32/")
- :drive-letters '("C" "D" "E")
- #+(or macosx darwin ccl-5.0) :types
- #+(or macosx darwin ccl-5.0) '("so" "dylib")
- )))
- (if (uffi:load-foreign-library libpath
- :module "postgresql"
- :supporting-libraries
- *postgresql-supporting-libraries*)
- (setq *postgresql-library-loaded* t)
- (warn "Can't load PostgreSQL client library ~A" libpath))))
+ (clsql-uffi:find-and-load-foreign-library "libpq"
+ :module "postgresql"
+ :supporting-libraries *postgresql-supporting-libraries*)
+ (setq *postgresql-library-loaded* t))
(clsql-sys:database-type-load-foreign :postgresql)
*sqlite-library-loaded*)
(defmethod database-type-load-foreign ((database-type (eql :sqlite)))
- (let ((libpath (uffi:find-foreign-library
- '("libsqlite" "sqlite")
- '(#+64bit "/usr/lib64/"
- "/usr/lib/" "/usr/local/lib/" "/bin/")
- :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-uffi:find-and-load-foreign-library '("libsqlite" "sqlite")
+ :module "sqlite"
+ :supporting-libraries *sqlite-supporting-libraries*)
+ (setq *sqlite-library-loaded* t))
(clsql-sys:database-type-load-foreign :sqlite)
*sqlite3-library-loaded*)
(defmethod database-type-load-foreign ((database-type (eql :sqlite3)))
- (let ((libpath (uffi:find-foreign-library
- '("libsqlite3" "sqlite3")
- '(#+64bit "/usr/lib64/"
- "/usr/lib/" "/usr/local/lib/" "/bin/")
- :drive-letters '("C" "D" "E"))))
- (if (uffi:load-foreign-library libpath
- :module "sqlite3"
- :supporting-libraries
- *sqlite3-supporting-libraries*)
- (setq *sqlite3-library-loaded* t)
- (warn "Can't load Sqlite3 library ~A" libpath))))
+ (clsql-uffi:find-and-load-foreign-library '("libsqlite3" "sqlite3")
+ :module "sqlite3"
+ :supporting-libraries *sqlite3-supporting-libraries*)
+ (setq *sqlite3-library-loaded* t))
(clsql-sys:database-type-load-foreign :sqlite3)
+cl-sql (3.1.17-1) unstable; urgency=low
+
+ * New upstream
+
+ -- Kevin M. Rosenberg <kmr@debian.org> Wed, 08 Jun 2005 13:25:06 -0600
+
cl-sql (3.1.16-1) unstable; urgency=low
* New upstream
(in-package #:clsql-uffi)
-(defvar *clsql-uffi-library-filename*
- (uffi:find-foreign-library
- '(#+(or 64bit x86-64) "uffi64" "uffi")
- `(,clsql-uffi-system::*library-file-dir*
- "/usr/lib/clsql/")
- :drive-letters '("C")))
+(defun find-and-load-foreign-library (filenames &key module supporting-libraries (errorp t))
+ (setq filenames (if (listp filenames) filenames (list filenames)))
+ (or (loop for type in (uffi:foreign-library-types)
+ for suffix = (make-pathname :type type)
+ thereis (loop for filename in filenames
+ thereis (handler-case
+ (uffi:load-foreign-library (merge-pathnames filename suffix)
+ :module module
+ :supporting-libraries supporting-libraries)
+ (error (c)
+ (warn "~A" c)
+ nil))))
+ (when errorp
+ (error "Couldn't load foreign librar~@P ~{~S~^, ~}."
+ (length filenames) filenames))))
+
+(defvar *clsql-uffi-library-filenames*
+ (list #+(or 64bit x86-64) (make-pathname :name "uffi64"
+ :directory clsql-uffi-system::*library-file-dir*)
+ #+(or 64bit x86-64) "uffi64"
+ (make-pathname :name "uffi"
+ :directory clsql-uffi-system::*library-file-dir*)
+ "uffi"))
(defvar *clsql-uffi-supporting-libraries* '("c")
"Used only by CMU. List of library flags needed to be passed to ld to
"T if foreign library was able to be loaded successfully")
(defun load-uffi-foreign-library ()
- (unless (probe-file *clsql-uffi-library-filename*)
- (error "Unable to find uffi.so"))
-
- (if (uffi:load-foreign-library *clsql-uffi-library-filename*
- :module "clsql-uffi"
- :supporting-libraries
- *clsql-uffi-supporting-libraries*)
- (setq *uffi-library-loaded* t)
- (error "Unable to load helper library ~A" *clsql-uffi-library-filename*)))
+ (find-and-load-foreign-library *clsql-uffi-library-filenames*
+ :module "clsql-uffi"
+ :supporting-libraries
+ *clsql-uffi-supporting-libraries*)
+ (setq *uffi-library-loaded* t))
(load-uffi-foreign-library)
(defpackage #:clsql-uffi
(:use #:cl #:uffi)
(:export
+ #:find-and-load-foreign-library
#:canonicalize-type-list
#:convert-raw-field
#:atoi