r1710: *** empty log message ***
[uffi.git] / src / libraries.cl
index ac04d9365a16a5a57ac9ec296e3fe055f7b0de6c..f88a20720be8a86e4c620b62e9adf5eaf418590d 100644 (file)
@@ -7,7 +7,7 @@
 ;;;; Programmer:    Kevin M. Rosenberg
 ;;;; Date Started:  Feb 2002
 ;;;;
-;;;; $Id: libraries.cl,v 1.5 2002/03/21 04:05:15 kevin Exp $
+;;;; $Id: libraries.cl,v 1.7 2002/04/01 00:52:07 kevin Exp $
 ;;;;
 ;;;; This file, part of UFFI, is Copyright (c) 2002 by Kevin M. Rosenberg
 ;;;;
 (defvar *loaded-libraries* nil
   "List of foreign libraries loaded. Used to prevent reloading a library")
 
+(defun default-foreign-library-type ()
+  "Returns string naming default library type for platform"
+  #+(or win32 mswindows) "dll"
+  #+freebsd "a"
+  #+linux "so")
+
+(defun find-foreign-library (name &key directories type)  
+  "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 directories)
+    (setq directories (list directories)))
+  (dolist (dir directories)
+    (let ((path (make-pathname :name :type type :directory directory)))
+      (when (probe-file path)
+       (return path))))
+  nil)
+
+
 (defun load-foreign-library (filename &key module supporting-libraries
                                           force-load)
   #+allegro (declare (ignore module supporting-libraries))