From ab96e211bb083d1e1ea4edca83d4f6d47b41c84b Mon Sep 17 00:00:00 2001 From: "Kevin M. Rosenberg" Date: Mon, 1 Apr 2002 04:40:08 +0000 Subject: [PATCH] r1711: *** empty log message *** --- examples/c-test-fns.cl | 8 ++------ src/libraries.cl | 39 ++++++++++++++++++++++++++++++++------- tests/c-test-fns.cl | 8 ++------ 3 files changed, 36 insertions(+), 19 deletions(-) diff --git a/examples/c-test-fns.cl b/examples/c-test-fns.cl index a45dda9..8584b1a 100644 --- a/examples/c-test-fns.cl +++ b/examples/c-test-fns.cl @@ -7,7 +7,7 @@ ;;;; Programmer: Kevin M. Rosenberg ;;;; Date Started: Mar 2002 ;;;; -;;;; $Id: c-test-fns.cl,v 1.3 2002/03/31 23:05:07 kevin Exp $ +;;;; $Id: c-test-fns.cl,v 1.4 2002/04/01 04:40:08 kevin Exp $ ;;;; ;;;; This file, part of UFFI, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; @@ -19,11 +19,7 @@ (in-package :cl-user) (unless (uffi:load-foreign-library - (make-pathname :name "c-test-fns" - :type #+(or linux unix)"so" - #+(or win32 mswindows) "dll" - #+freebsd "a" - :defaults *load-truename*) + (uffi:find-foreign-library "c-test-fns" *load-truename*) :supporting-libraries '("c") :force-load t) (warn "Unable to load c-test-fns library")) diff --git a/src/libraries.cl b/src/libraries.cl index f88a207..7194c6b 100644 --- a/src/libraries.cl +++ b/src/libraries.cl @@ -7,7 +7,7 @@ ;;;; Programmer: Kevin M. Rosenberg ;;;; Date Started: Feb 2002 ;;;; -;;;; $Id: libraries.cl,v 1.7 2002/04/01 00:52:07 kevin Exp $ +;;;; $Id: libraries.cl,v 1.8 2002/04/01 04:40:08 kevin Exp $ ;;;; ;;;; This file, part of UFFI, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; @@ -28,19 +28,44 @@ #+freebsd "a" #+linux "so") -(defun find-foreign-library (name &key directories type) +(defun find-foreign-library (names directories &key type drive-letters) "Looks for a foreign library. directories can be a single string or a list of strings of candidate directories. Use default library type if type is not specified." (unless type (setq type (default-foreign-library-type))) + (unless (listp names) + (setq names (list names))) (unless (listp directories) (setq directories (list directories))) - (dolist (dir directories) - (let ((path (make-pathname :name :type type :directory directory))) - (when (probe-file path) - (return path)))) - nil) + #+(or win32 mswindows) + (unless (listp drive-letters) + (setq drive-letters (list drive-letters))) + #-(or win32 mswindows) + (setq drive-letters '(nil)) + (dolist (drive-letter drive-letters) + (dolist (name names) + (dolist (dir directories) + (let ((path (make-pathname + #+lispworks :host + #+lispworks (when drive-letter drive-letter) + #-lispworks :device + #-lispworks (when drive-letter drive-letter) + :name name + :type type + :directory + (etypecase dir + (pathname + (pathname-directory dir)) + (list + dir) + (string + (pathname-directory + (parse-namestring dir))))))) + (print path) + (when (probe-file path) + (return-from find-foreign-library path)))))) + nil) (defun load-foreign-library (filename &key module supporting-libraries diff --git a/tests/c-test-fns.cl b/tests/c-test-fns.cl index a45dda9..8584b1a 100644 --- a/tests/c-test-fns.cl +++ b/tests/c-test-fns.cl @@ -7,7 +7,7 @@ ;;;; Programmer: Kevin M. Rosenberg ;;;; Date Started: Mar 2002 ;;;; -;;;; $Id: c-test-fns.cl,v 1.3 2002/03/31 23:05:07 kevin Exp $ +;;;; $Id: c-test-fns.cl,v 1.4 2002/04/01 04:40:08 kevin Exp $ ;;;; ;;;; This file, part of UFFI, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; @@ -19,11 +19,7 @@ (in-package :cl-user) (unless (uffi:load-foreign-library - (make-pathname :name "c-test-fns" - :type #+(or linux unix)"so" - #+(or win32 mswindows) "dll" - #+freebsd "a" - :defaults *load-truename*) + (uffi:find-foreign-library "c-test-fns" *load-truename*) :supporting-libraries '("c") :force-load t) (warn "Unable to load c-test-fns library")) -- 2.34.1