# Programer: Kevin M. Rosenberg
# Date Started: Mar 2002
#
-# CVS Id: $Id: Makefile,v 1.23 2002/09/18 07:43:40 kevin Exp $
+# CVS Id: $Id: Makefile,v 1.24 2002/09/18 07:51:22 kevin Exp $
#
# This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
#
PKG := clsql
DEBPKG := cl-sql
-SUBDIRS := sql clsql-uffi base clsql-mysql clsql-aodbc \
- clsql-postgresql clsql-postgresql-socket
+SUBDIRS := sql uffi base db-mysql db-aodbc \
+ db-postgresql db-postgresql-socket
DOCSUBDIRS:=doc
include Makefile.common
-LIBSUBDIRS=clsql-mysql clsql-uffi
+LIBSUBDIRS=db-mysql uffi
.PHONY: subdirs $(LIBSUBDIRS)
.PHONY: all
;;;; Programmer: Kevin M. Rosenberg
;;;; Date Started: Aug 2002
;;;;
-;;;; $Id: clsql-aodbc.asd,v 1.8 2002/09/17 17:18:34 kevin Exp $
+;;;; $Id: clsql-aodbc.asd,v 1.9 2002/09/18 07:50:01 kevin Exp $
;;;;
;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
;;;;
(defsystem :clsql-aodbc
:components
- ((:module :clsql-aodbc
+ ((:module :db-aodbc
:components
((:file "aodbc-package")
(:file "aodbc-sql" :depends-on ("aodbc-package")))))
:depends-on (:clsql-base))
(defmethod source-file-type ((c cl-source-file)
- (s (eql (find-system 'clsql-aodbc))))
+ (s (eql (find-system :clsql-aodbc))))
"cl")
;;;; Programmer: Kevin M. Rosenberg
;;;; Date Started: Feb 2002
;;;;
-;;;; $Id: clsql-base.asd,v 1.10 2002/09/17 17:16:43 kevin Exp $
+;;;; $Id: clsql-base.asd,v 1.11 2002/09/18 07:50:01 kevin Exp $
;;;;
;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
;;;;
(:file "initialize" :depends-on ("db-interface"))))))
(defmethod source-file-type ((c cl-source-file)
- (s (eql (find-system 'clsql-base))))
+ (s (eql (find-system :clsql-base))))
"cl")
;;;; Programmer: Kevin M. Rosenberg\r
;;;; Date Started: Aug 2002\r
;;;;\r
-;;;; $Id: clsql-mysql.asd,v 1.6 2002/09/17 17:16:43 kevin Exp $\r
+;;;; $Id: clsql-mysql.asd,v 1.7 2002/09/18 07:50:01 kevin Exp $\r
;;;;\r
;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg\r
;;;;\r
\r
(defsystem :clsql-mysql\r
:components\r
- ((:module :mysql\r
+ ((:module :db-mysql\r
:components\r
((:file "mysql-package")\r
(:file "mysql-loader" :depends-on ("mysql-package"))\r
:depends-on (:uffi :clsql-base :clsql-uffi))\r
\r
(defmethod source-file-type ((c cl-source-file)\r
- (s (eql (find-system 'clsql-mysql)))) \r
+ (s (eql (find-system :clsql-mysql)))) \r
"cl")\r
;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
;;;; This is copyrighted software. See interfaces/oracle/* files for terms.
;;;;
-;;;; $Id: clsql-oracle.asd,v 1.6 2002/09/17 17:16:43 kevin Exp $
+;;;; $Id: clsql-oracle.asd,v 1.7 2002/09/18 07:50:01 kevin Exp $
(in-package :asdf)
(defsystem :clsql-oracle
:components
- ((:module :clsql-oracle
+ ((:module :db-oracle
:components
((:file "oracle-package")
(:file "oracle-loader" :depends-on ("oracle-package"))
:depends-on (:clsql-base))
(defmethod source-file-type ((c cl-source-file)
- (s (eql (find-system 'clsql-oracle))))
+ (s (eql (find-system :clsql-oracle))))
"cl")
;;;; Programmer: Kevin M. Rosenberg\r
;;;; Date Started: Aug 2002\r
;;;;\r
-;;;; $Id: clsql-postgresql-socket.asd,v 1.6 2002/09/17 17:16:43 kevin Exp $\r
+;;;; $Id: clsql-postgresql-socket.asd,v 1.7 2002/09/18 07:50:01 kevin Exp $\r
;;;;\r
;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg\r
;;;;\r
\r
(defsystem clsql-postgresql-socket\r
:components\r
- ((:module :clsql-postgresql-socket\r
+ ((:module :db-postgresql-socket\r
:components\r
((:file "postgresql-socket-package")\r
(:file "postgresql-socket-api"\r
:depends-on (:clsql-base :uffi))\r
\r
(defmethod source-file-type ((c cl-source-file)\r
- (s (eql (find-system 'clsql-postgresql-socket)))) \r
+ (s (eql (find-system :clsql-postgresql-socket)))) \r
"cl")\r
\r
;;;; Programmer: Kevin M. Rosenberg\r
;;;; Date Started: Aug 2002\r
;;;;\r
-;;;; $Id: clsql-postgresql.asd,v 1.6 2002/09/17 17:16:43 kevin Exp $\r
+;;;; $Id: clsql-postgresql.asd,v 1.7 2002/09/18 07:50:01 kevin Exp $\r
;;;;\r
;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg\r
;;;;\r
\r
(defsystem :clsql-postgresql\r
:components\r
- ((:module :clsql-postgresql\r
+ ((:module :db-postgresql\r
:components\r
((:file "postgresql-package")\r
(:file "postgresql-loader" :depends-on ("postgresql-package"))\r
:depends-on (:uffi :clsql-base :clsql-uffi))\r
\r
(defmethod source-file-type ((c cl-source-file)\r
- (s (eql (find-system 'clsql-postgresql)))) \r
+ (s (eql (find-system :clsql-postgresql)))) \r
"cl")\r
\r
;;;; Programmer: Kevin M. Rosenberg
;;;; Date Started: Aug 2002
;;;;
-;;;; $Id: clsql-uffi.asd,v 1.8 2002/09/17 17:16:43 kevin Exp $
+;;;; $Id: clsql-uffi.asd,v 1.9 2002/09/18 07:50:01 kevin Exp $
;;;;
;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
;;;;
(defmethod source-file-type ((c cl-source-file)
- (s (eql (find-system 'clsql-uffi))))
+ (s (eql (find-system :clsql-uffi))))
"cl")
+++ /dev/null
-clsql-uffi.so
-clsql-uffi.dll
-clsql-uffi.lib
-.bin
+++ /dev/null
-# -*- Mode: Makefile -*-
-###########################################################################
-# FILE IDENTIFICATION
-#
-# Name: Makefile
-# Purpose: Makefile for the CLSQL UFFI helper package
-# Programer: Kevin M. Rosenberg
-# Date Started: Mar 2002
-#
-# CVS Id: $Id: Makefile,v 1.1 2002/08/01 03:06:27 kevin Exp $
-#
-# 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.
-###########################################################################
-
-
-# These variables are correct for GCC
-CC=gcc
-SHARED_CC_OPT=-fPIC -DPIC
-SHARED_LD_OPT=-shared # For Linux (ALL) and FreeBSD (ACL)
-LD=gcc
-
-# Use these for Sun's C compiler and Solaris (ACL)
-#CC=cc
-#SHARED_CC_OPT=-KPIC
-#SHARED_LD_OPT=-G
-#LD=ld
-
-# Nothing to configure beyond this point
-
-base=clsql-uffi
-source=$(base).c
-object=$(base).o
-shared_lib=$(base).so
-
-.PHONY: all clean distclean
-
-all: $(shared_lib)
-
-$(shared_lib): $(source) Makefile
- $(CC) ${SHARED_CC_OPT} -c $(source) -o $(object)
- $(LD) ${SHARED_LD_OPT} $(object) -o $(shared_lib)
- @rm $(object)
-
-clean:
- @rm -f $(object) $(shared_lib) *~
-
-distclean: clean
-
+++ /dev/null
-# -*- Mode: Makefile -*-
-###########################################################################
-# FILE IDENTIFICATION
-#
-# Name: Makefile.msvc
-# Purpose: Makefile for the CLSQL UFFI helper package (MSVC)
-# Programer: Kevin M. Rosenberg
-# Date Started: Mar 2002
-#
-# CVS Id: $Id: Makefile.msvc,v 1.1 2002/08/01 03:06:27 kevin Exp $
-#
-# 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.
-###########################################################################
-
-
-BASE=clsql-uffi
-
-# Nothing to configure beyond here
-
-SRC=$(BASE).c
-OBJ=$(BASE).obj
-DLL=$(BASE).dll
-
-$(DLL): $(SRC)
- cl /MD /LD -D_MT /DWIN32=1 /D__LCC__=1 $(SRC)
- del $(OBJ) $(BASE).exp
-
-clean:
- del /q $(DLL)
-
-
+++ /dev/null
-;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
-;;;; *************************************************************************
-;;;; FILE IDENTIFICATION
-;;;;
-;;;; Name: clsql-uffi-loader.sql
-;;;; Purpose: library loader using CLSQL UFFI helper library
-;;;; Programmers: Kevin M. Rosenberg
-;;;; Date Started: Mar 2002
-;;;;
-;;;; $Id: clsql-uffi-loader.cl,v 1.2 2002/08/01 21:39:22 kevin Exp $
-;;;;
-;;;; 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.
-;;;; *************************************************************************
-
-(declaim (optimize (debug 3) (speed 3) (safety 1) (compilation-speed 0)))
-(in-package :clsql-uffi)
-
-(defvar *clsql-uffi-library-filename*
- (uffi:find-foreign-library
- "clsql-uffi"
- `(,(directory-namestring
- (translate-logical-pathname
- "cl-library:clsql-uffi;"))
- "/usr/lib/clsql/")
- :drive-letters '("C" "D" "E" "F" "G")))
-
-(defvar *clsql-uffi-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,
-set to the right path before compiling or loading the system.")
-
-(defvar *uffi-library-loaded* nil
- "T if foreign library was able to be loaded successfully")
-
-(defun load-uffi-foreign-library ()
- (if (uffi:load-foreign-library *clsql-uffi-library-filename*
- :module "clsql-uffi"
- :supporting-libraries
- *clsql-uffi-supporting-libraries*)
- (setq *uffi-library-loaded* t)
- (warn "Unable to load helper library ~A" *clsql-uffi-library-filename*)))
-
-(load-uffi-foreign-library)
-
-
-
+++ /dev/null
-;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
-;;;; *************************************************************************
-;;;; FILE IDENTIFICATION
-;;;;
-;;;; Name: clsql-uffi-package.cl
-;;;; Purpose: Package definitions for common UFFI interface routines
-;;;; Programmers: Kevin M. Rosenberg
-;;;; Date Started: Mar 2002
-;;;;
-;;;; $Id: clsql-uffi-package.cl,v 1.1 2002/08/01 03:06:27 kevin Exp $
-;;;;
-;;;; 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.
-;;;; *************************************************************************
-
-(declaim (optimize (debug 3) (speed 3) (safety 1) (compilation-speed 0)))
-(in-package :cl-user)
-
-(defpackage :clsql-uffi
- (:export
- #:canonicalize-type-list
- #:convert-raw-field
- #:atoi
- #:atol
- #:atof
- #:atol64
- #:make-64-bit-integer
- #:split-64-bit-integer)
- (:documentation "Common functions for interfaces using UFFI"))
-
+++ /dev/null
-/****************************************************************************
- * FILE IDENTIFICATION
- *
- * Name: clsql-uffi.c
- * Purpose: Helper functions for common interfaces using UFFI
- * Programmer: Kevin M. Rosenberg
- * Date Started: Mar 2002
- *
- * $Id: clsql-uffi.c,v 1.1 2002/08/01 03:06:27 kevin Exp $
- *
- * 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
-
-
-const unsigned int bitmask_32bits = 0xFFFFFFFF;
-#define lower_32bits(int64) ((unsigned int) int64 & bitmask_32bits)
-#define upper_32bits(int64) ((unsigned int) (int64 >> 32))
-
-/* Reads a 64-bit integer string, returns result as two 32-bit integers */
-
-DLLEXPORT
-unsigned int
-atol64 (const unsigned char* str, int* pHigh32)
-{
-#ifdef WIN32
- __int64 result = 0;
-#else
- long long result = 0;
-#endif
- int minus = 0;
- int first_char = *str;
- if (first_char == '+')
- ++str;
- else if (first_char == '-') {
- minus = 1;
- ++str;
- }
-
- while (*str) {
- int i = *str - '0';
- if (i < 0 || i > 9) /* Non-numeric character -- quit */
- break;
- result = i + (10 * result);
- str++;
- }
- if (minus)
- result = -result;
-
- *pHigh32 = upper_32bits(result);
- return lower_32bits(result);
-}
-
-
-
-
-
+++ /dev/null
-;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
-;;;; *************************************************************************
-;;;; FILE IDENTIFICATION
-;;;;
-;;;; Name: clsql-uffi.cl
-;;;; Purpose: Common functions for interfaces using UFFI
-;;;; Programmers: Kevin M. Rosenberg
-;;;; Date Started: Mar 2002
-;;;;
-;;;; $Id: clsql-uffi.cl,v 1.1 2002/08/01 03:06:27 kevin Exp $
-;;;;
-;;;; 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.
-;;;; *************************************************************************
-
-(declaim (optimize (debug 3) (speed 3) (safety 1) (compilation-speed 0)))
-(in-package :clsql-uffi)
-
-
-(defun canonicalize-type-list (types auto-list)
- "Ensure a field type list meets expectations"
- (let ((length-types (length types))
- (new-types '()))
- (loop for i from 0 below (length auto-list)
- do
- (if (>= i length-types)
- (push t new-types) ;; types is shorted than num-fields
- (push
- (case (nth i types)
- (:int
- (case (nth i auto-list)
- (:int32
- :int32)
- (:int64
- :int64)
- (t
- t)))
- (:double
- (case (nth i auto-list)
- (:double
- :double)
- (t
- t)))
- (:int32
- (if (eq :int32 (nth i auto-list))
- :int32
- t))
- (:int64
- (if (eq :int64 (nth i auto-list))
- :int64
- t))
- (t
- t))
- new-types)))
- (nreverse new-types)))
-
-(uffi:def-function "atoi"
- ((str (* :unsigned-char)))
- :returning :int)
-
-(uffi:def-function "atol"
- ((str (* :unsigned-char)))
- :returning :long)
-
-(uffi:def-function "atof"
- ((str (* :unsigned-char)))
- :returning :double)
-
-(uffi:def-function "atol64"
- ((str (* :unsigned-char))
- (high32 (* :int)))
- :returning :unsigned-int)
-
-(uffi:def-constant +2^32+ 4294967296)
-(uffi:def-constant +2^32-1+ (1- +2^32+))
-
-(defmacro make-64-bit-integer (high32 low32)
- `(+ ,low32 (* ,high32 +2^32+)))
-
-(defmacro split-64-bit-integer (int64)
- `(values (ash ,int64 -32) (logand ,int64 +2^32-1+)))
-
-(defun convert-raw-field (char-ptr types index)
- (let ((type (if (listp types)
- (nth index types)
- types)))
- (case type
- (:double
- (atof char-ptr))
- ((or :int32 :int)
- (atoi char-ptr))
- (:int64
- (uffi:with-foreign-object (high32-ptr :int)
- (let ((low32 (atol64 char-ptr high32-ptr))
- (high32 (uffi:deref-pointer high32-ptr :int)))
- (if (zerop high32)
- low32
- (make-64-bit-integer high32 low32)))))
- (t
- (uffi:convert-from-foreign-string char-ptr)))))
;;;; Programmer: Kevin M. Rosenberg
;;;; Date Started: Feb 2002
;;;;
-;;;; $Id: clsql.asd,v 1.7 2002/09/17 17:16:43 kevin Exp $
+;;;; $Id: clsql.asd,v 1.8 2002/09/18 07:50:01 kevin Exp $
;;;;
;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
;;;;
)
(defmethod source-file-type ((c cl-source-file)
- (s (eql (find-system 'clsql))))
+e (s (eql (find-system :clsql))))
"cl")
## Lisp sources
srcs := sql clsql.asd
srcs-base := $(wildcard base/*.cl)
-srcs-uffi := $(wildcard clsql-uffi/*.cl) $(wildcard clsql-uffi/*.c)
-srcs-uffi-so:= $(wildcard clsql-uffi/*.so)
-srcs-mysql := $(wildcard clsql-mysql/*.cl) $(wildcard clsql-mysql/*.c)
-srcs-mysql-so := $(wildcard clsql-mysql/*.so)
-srcs-pg := $(wildcard clsql-postgresql/*.cl)
-srcs-pg-socket := $(wildcard clsql-postgresql-socket/*.cl)
-srcs-aodbc := $(wildcard clsql-aodbc/*.cl)
+srcs-uffi := $(wildcard uffi/*.cl) $(wildcard uffi/*.c)
+srcs-uffi-so := $(wildcard uffi/*.so)
+srcs-mysql := $(wildcard db-mysql/*.cl) $(wildcard db-mysql/*.c)
+srcs-mysql-so := $(wildcard db-mysql/*.so)
+srcs-pg := $(wildcard db-postgresql/*.cl)
+srcs-pg-socket := $(wildcard db-postgresql-socket/*.cl)
+srcs-aodbc := $(wildcard db-aodbc/*.cl)
clc-base := usr/share/common-lisp
clc-source := $(clc-base)/source
clc-base := $(clc-source)/clsql-base
lispdir-base := $(clc-base)/base
clc-uffi := $(clc-source)/clsql-uffi
-lispdir-uffi := $(clc-uffi)/clsql-uffi
-sodir-uffi := usr/lib/clsql
+lispdir-uffi := $(clc-uffi)/uffi
+sodir-uffi := usr/lib/clsql
clc-mysql := $(clc-source)/clsql-mysql
-lispdir-mysql := $(clc-mysql)/clsql-mysql
+lispdir-mysql := $(clc-mysql)/db-mysql
sodir-mysql := usr/lib/clsql
clc-pg := $(clc-source)/clsql-postgresql
-lispdir-pg := $(clc-pg)/clsql-postgresql
-clc-socket := $(clc-source)/clsql-postgresql-socket
-lispdir-pg-socket := $(clc-pg-socket)/clsql-postgresql-socket
+lispdir-pg := $(clc-pg)/db-postgresql
+clc-socket := $(clc-source)/clsql-postgresql-socket
+lispdir-pg-socket := $(clc-pg-socket)/db-postgresql-socket
clc-aodbc := $(clc-source)/clsql-aodbc
-lispdir-aodbc := $(clc-aodbc)/clsql-aodbc
+lispdir-aodbc := $(clc-aodbc)/db-aodbc
configure: configure-stamp
--- /dev/null
+clsql-uffi.so
+clsql-uffi.dll
+clsql-uffi.lib
+.bin
--- /dev/null
+# -*- Mode: Makefile -*-
+###########################################################################
+# FILE IDENTIFICATION
+#
+# Name: Makefile
+# Purpose: Makefile for the CLSQL UFFI helper package
+# Programer: Kevin M. Rosenberg
+# Date Started: Mar 2002
+#
+# CVS Id: $Id: Makefile,v 1.1 2002/09/18 07:50:01 kevin Exp $
+#
+# 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.
+###########################################################################
+
+
+# These variables are correct for GCC
+CC=gcc
+SHARED_CC_OPT=-fPIC -DPIC
+SHARED_LD_OPT=-shared # For Linux (ALL) and FreeBSD (ACL)
+LD=gcc
+
+# Use these for Sun's C compiler and Solaris (ACL)
+#CC=cc
+#SHARED_CC_OPT=-KPIC
+#SHARED_LD_OPT=-G
+#LD=ld
+
+# Nothing to configure beyond this point
+
+base=clsql-uffi
+source=$(base).c
+object=$(base).o
+shared_lib=$(base).so
+
+.PHONY: all clean distclean
+
+all: $(shared_lib)
+
+$(shared_lib): $(source) Makefile
+ $(CC) ${SHARED_CC_OPT} -c $(source) -o $(object)
+ $(LD) ${SHARED_LD_OPT} $(object) -o $(shared_lib)
+ @rm $(object)
+
+clean:
+ @rm -f $(object) $(shared_lib) *~
+
+distclean: clean
+
--- /dev/null
+# -*- Mode: Makefile -*-
+###########################################################################
+# FILE IDENTIFICATION
+#
+# Name: Makefile.msvc
+# Purpose: Makefile for the CLSQL UFFI helper package (MSVC)
+# Programer: Kevin M. Rosenberg
+# Date Started: Mar 2002
+#
+# CVS Id: $Id: Makefile.msvc,v 1.1 2002/09/18 07:50:01 kevin Exp $
+#
+# 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.
+###########################################################################
+
+
+BASE=clsql-uffi
+
+# Nothing to configure beyond here
+
+SRC=$(BASE).c
+OBJ=$(BASE).obj
+DLL=$(BASE).dll
+
+$(DLL): $(SRC)
+ cl /MD /LD -D_MT /DWIN32=1 /D__LCC__=1 $(SRC)
+ del $(OBJ) $(BASE).exp
+
+clean:
+ del /q $(DLL)
+
+
--- /dev/null
+;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
+;;;; *************************************************************************
+;;;; FILE IDENTIFICATION
+;;;;
+;;;; Name: clsql-uffi-loader.sql
+;;;; Purpose: library loader using CLSQL UFFI helper library
+;;;; Programmers: Kevin M. Rosenberg
+;;;; Date Started: Mar 2002
+;;;;
+;;;; $Id: clsql-uffi-loader.cl,v 1.1 2002/09/18 07:50:01 kevin Exp $
+;;;;
+;;;; 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.
+;;;; *************************************************************************
+
+(declaim (optimize (debug 3) (speed 3) (safety 1) (compilation-speed 0)))
+(in-package :clsql-uffi)
+
+(defvar *clsql-uffi-library-filename*
+ (uffi:find-foreign-library
+ "clsql-uffi"
+ `(,(directory-namestring
+ (translate-logical-pathname
+ "cl-library:clsql-uffi;"))
+ "/usr/lib/clsql/")
+ :drive-letters '("C" "D" "E" "F" "G")))
+
+(defvar *clsql-uffi-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,
+set to the right path before compiling or loading the system.")
+
+(defvar *uffi-library-loaded* nil
+ "T if foreign library was able to be loaded successfully")
+
+(defun load-uffi-foreign-library ()
+ (if (uffi:load-foreign-library *clsql-uffi-library-filename*
+ :module "clsql-uffi"
+ :supporting-libraries
+ *clsql-uffi-supporting-libraries*)
+ (setq *uffi-library-loaded* t)
+ (warn "Unable to load helper library ~A" *clsql-uffi-library-filename*)))
+
+(load-uffi-foreign-library)
+
+
+
--- /dev/null
+;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
+;;;; *************************************************************************
+;;;; FILE IDENTIFICATION
+;;;;
+;;;; Name: clsql-uffi-package.cl
+;;;; Purpose: Package definitions for common UFFI interface routines
+;;;; Programmers: Kevin M. Rosenberg
+;;;; Date Started: Mar 2002
+;;;;
+;;;; $Id: clsql-uffi-package.cl,v 1.1 2002/09/18 07:50:01 kevin Exp $
+;;;;
+;;;; 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.
+;;;; *************************************************************************
+
+(declaim (optimize (debug 3) (speed 3) (safety 1) (compilation-speed 0)))
+(in-package :cl-user)
+
+(defpackage :clsql-uffi
+ (:export
+ #:canonicalize-type-list
+ #:convert-raw-field
+ #:atoi
+ #:atol
+ #:atof
+ #:atol64
+ #:make-64-bit-integer
+ #:split-64-bit-integer)
+ (:documentation "Common functions for interfaces using UFFI"))
+
--- /dev/null
+/****************************************************************************
+ * FILE IDENTIFICATION
+ *
+ * Name: clsql-uffi.c
+ * Purpose: Helper functions for common interfaces using UFFI
+ * Programmer: Kevin M. Rosenberg
+ * Date Started: Mar 2002
+ *
+ * $Id: clsql-uffi.c,v 1.1 2002/09/18 07:50:01 kevin Exp $
+ *
+ * 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
+
+
+const unsigned int bitmask_32bits = 0xFFFFFFFF;
+#define lower_32bits(int64) ((unsigned int) int64 & bitmask_32bits)
+#define upper_32bits(int64) ((unsigned int) (int64 >> 32))
+
+/* Reads a 64-bit integer string, returns result as two 32-bit integers */
+
+DLLEXPORT
+unsigned int
+atol64 (const unsigned char* str, int* pHigh32)
+{
+#ifdef WIN32
+ __int64 result = 0;
+#else
+ long long result = 0;
+#endif
+ int minus = 0;
+ int first_char = *str;
+ if (first_char == '+')
+ ++str;
+ else if (first_char == '-') {
+ minus = 1;
+ ++str;
+ }
+
+ while (*str) {
+ int i = *str - '0';
+ if (i < 0 || i > 9) /* Non-numeric character -- quit */
+ break;
+ result = i + (10 * result);
+ str++;
+ }
+ if (minus)
+ result = -result;
+
+ *pHigh32 = upper_32bits(result);
+ return lower_32bits(result);
+}
+
+
+
+
+
--- /dev/null
+;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
+;;;; *************************************************************************
+;;;; FILE IDENTIFICATION
+;;;;
+;;;; Name: clsql-uffi.cl
+;;;; Purpose: Common functions for interfaces using UFFI
+;;;; Programmers: Kevin M. Rosenberg
+;;;; Date Started: Mar 2002
+;;;;
+;;;; $Id: clsql-uffi.cl,v 1.1 2002/09/18 07:50:01 kevin Exp $
+;;;;
+;;;; 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.
+;;;; *************************************************************************
+
+(declaim (optimize (debug 3) (speed 3) (safety 1) (compilation-speed 0)))
+(in-package :clsql-uffi)
+
+
+(defun canonicalize-type-list (types auto-list)
+ "Ensure a field type list meets expectations"
+ (let ((length-types (length types))
+ (new-types '()))
+ (loop for i from 0 below (length auto-list)
+ do
+ (if (>= i length-types)
+ (push t new-types) ;; types is shorted than num-fields
+ (push
+ (case (nth i types)
+ (:int
+ (case (nth i auto-list)
+ (:int32
+ :int32)
+ (:int64
+ :int64)
+ (t
+ t)))
+ (:double
+ (case (nth i auto-list)
+ (:double
+ :double)
+ (t
+ t)))
+ (:int32
+ (if (eq :int32 (nth i auto-list))
+ :int32
+ t))
+ (:int64
+ (if (eq :int64 (nth i auto-list))
+ :int64
+ t))
+ (t
+ t))
+ new-types)))
+ (nreverse new-types)))
+
+(uffi:def-function "atoi"
+ ((str (* :unsigned-char)))
+ :returning :int)
+
+(uffi:def-function "atol"
+ ((str (* :unsigned-char)))
+ :returning :long)
+
+(uffi:def-function "atof"
+ ((str (* :unsigned-char)))
+ :returning :double)
+
+(uffi:def-function "atol64"
+ ((str (* :unsigned-char))
+ (high32 (* :int)))
+ :returning :unsigned-int)
+
+(uffi:def-constant +2^32+ 4294967296)
+(uffi:def-constant +2^32-1+ (1- +2^32+))
+
+(defmacro make-64-bit-integer (high32 low32)
+ `(+ ,low32 (* ,high32 +2^32+)))
+
+(defmacro split-64-bit-integer (int64)
+ `(values (ash ,int64 -32) (logand ,int64 +2^32-1+)))
+
+(defun convert-raw-field (char-ptr types index)
+ (let ((type (if (listp types)
+ (nth index types)
+ types)))
+ (case type
+ (:double
+ (atof char-ptr))
+ ((or :int32 :int)
+ (atoi char-ptr))
+ (:int64
+ (uffi:with-foreign-object (high32-ptr :int)
+ (let ((low32 (atol64 char-ptr high32-ptr))
+ (high32 (uffi:deref-pointer high32-ptr :int)))
+ (if (zerop high32)
+ low32
+ (make-64-bit-integer high32 low32)))))
+ (t
+ (uffi:convert-from-foreign-string char-ptr)))))