X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=tests%2Fgetenv.cl;h=043e7fca72ed6b93d0704d344f0c0dff05ec1e5f;hb=e9427febae05e5563f723f72487fc11365033d8d;hp=335a70f694011010847e5cbea87951e2e76242c6;hpb=bc5968d54cee0416db7db9ee2c7295489170bccf;p=uffi.git diff --git a/tests/getenv.cl b/tests/getenv.cl index 335a70f..043e7fc 100644 --- a/tests/getenv.cl +++ b/tests/getenv.cl @@ -9,7 +9,7 @@ ;;;; ;;;; Copyright (c) 2002 Kevin M. Rosenberg ;;;; -;;;; $Id: getenv.cl,v 1.2 2002/03/09 21:19:31 kevin Exp $ +;;;; $Id: getenv.cl,v 1.6 2002/03/10 17:42:35 kevin Exp $ ;;;; ;;;; This file is part of UFFI. ;;;; @@ -31,16 +31,19 @@ (uffi:def-function ("getenv" c-getenv) - ((name :c-string)) - :returning :c-string) + ((name :cstring)) + :returning :cstring) -(defun getenv (key) +(defun my-getenv (key) "Returns an environment variable, or NIL if it does not exist" (check-type key string) - (uffi:with-c-string (key-native key) - (let ((value-c-string (c-getenv key-native))) - (uffi:convert-from-c-string value-c-string)))) + (uffi:with-cstring (key-native key) + (uffi:convert-from-cstring (c-getenv key-native)))) -(format t "~&Environment value for USER key: ~A" (getenv "USER")) -(format t "~&Environment value for _FOO_ key: ~A" (getenv "_FOO_")) +#+test-uffi +(progn + (flet ((print-results (str) + (format t "~&(getenv ~S) => ~S" str (my-getenv str)))) + (print-results "USER") + (print-results "_FOO_")))