[cffi-devel] patch for uffi-compat

Yaroslav Kavenchuk kavenchuk at tut.by
Sat Nov 5 07:51:45 UTC 2005


uffi 1.5.5 is out

This patch add new function from it

File uff-compat.diff
==========================================
--- uffi-compat.lisp    Fri Nov  4 12:12:12 2005
+++ uffi-compat.lisp    Fri Nov  4 23:47:42 2005
@@ -91,6 +91,7 @@
 
    ;; os
    #:run-shell-command
+   #:getenv
    ))
 
 (in-package #:cffi-uffi-compat)
@@ -503,6 +504,35 @@
 
 ;; Taken from UFFI's src/os.lisp
 ;; modified from function ASDF -- Copyright Dan Barlow and Contributors
+(defun getenv (var)
+  "Return the value of the environment variable."
+  #+allegro (sys::getenv (string var))
+  #+clisp (sys::getenv (string var))
+  #+cmu (cdr (assoc (string var) ext:*environment-list* :test #'equalp
+                    :key #'string))
+  #+gcl (si:getenv (string var))
+  #+lispworks (lw:environment-variable (string var))
+  #+lucid (lcl:environment-variable (string var))
+  #+mcl (ccl::getenv var)
+  #+sbcl (sb-ext:posix-getenv var)
+  #-(or allegro clisp cmu gcl lispworks lucid mcl sbcl)
+  (error 'not-implemented :proc (list 'getenv var)))
+
+(defun (setf getenv) (val var)
+  "Set an environment variable."
+  #+allegro (setf (sys::getenv (string var)) (string val))
+  #+clisp (setf (sys::getenv (string var)) (string val))
+  #+cmu (let ((cell (assoc (string var) ext:*environment-list* :test 
#'equalp
+                           :key #'string)))
+          (if cell
+              (setf (cdr cell) (string val))
+              (push (cons (intern (string var) "KEYWORD") (string val)) 
ext:*environment-list*)))
+  #+gcl (si:setenv (string var) (string val))
+  #+lispworks (setf (lw:environment-variable (string var)) (string val))
+  #+lucid (setf (lcl:environment-variable (string var)) (string val))
+  #-(or allegro clisp cmu gcl lispworks lucid)
+  (error 'not-implemented :proc (list '(setf getenv) var)))
+
 (defun run-shell-command (control-string  &rest args &key output)
   "Interpolate ARGS into CONTROL-STRING as if by FORMAT, and
 synchronously execute the result using a Bourne-compatible shell, with




More information about the cffi-devel mailing list