projects
/
uffi.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
r1539: *** empty log message ***
[uffi.git]
/
examples
/
getenv.cl
diff --git
a/examples/getenv.cl
b/examples/getenv.cl
index 3a565c282ff5e0fc20fde199a57d19183ba87ab5..043e7fca72ed6b93d0704d344f0c0dff05ec1e5f 100644
(file)
--- a/
examples/getenv.cl
+++ b/
examples/getenv.cl
@@
-9,7
+9,7
@@
;;;;
;;;; Copyright (c) 2002 Kevin M. Rosenberg
;;;;
;;;;
;;;; Copyright (c) 2002 Kevin M. Rosenberg
;;;;
-;;;; $Id: getenv.cl,v 1.
1 2002/03/09 19:55:33
kevin Exp $
+;;;; $Id: getenv.cl,v 1.
6 2002/03/10 17:42:35
kevin Exp $
;;;;
;;;; This file is part of UFFI.
;;;;
;;;;
;;;; This file is part of UFFI.
;;;;
@@
-30,17
+30,20
@@
(in-package :cl-user)
(in-package :cl-user)
-(uffi:def-
routine
("getenv" c-getenv)
- ((name :c
-
string))
- :returning :c
-
string)
+(uffi:def-
function
("getenv" c-getenv)
+ ((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)
"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_")))