;;;; Programmer: "Joe Marshall" <prunesquallor@attbi.com>
;;;; Date Started: Feb 2002
;;;;
-`;;;; $Id: getenv-ccl.lisp,v 1.1 2002/10/01 17:05:29 kevin Exp $
-;;;;
-;;;; This file, part of UFFI, is Copyright (c) 2002 by Kevin M. Rosenberg
-;;;;
-;;;; UFFI users are granted the rights to distribute and use this software
-;;;; as governed by the terms of the Lisp Lesser GNU Public License
-;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL.
;;;; *************************************************************************
(in-package :cl-user)
(ct:defun-dll c-getenv ((lpname LPSTR)
- (lpbuffer LPSTR)
- (nsize LPDWORD))
+ (lpbuffer LPSTR)
+ (nsize LPDWORD))
:library-name "kernel32.dll"
:return-type DWORD
:entry-name "GetEnvironmentVariableA"
(let* ((needed-size (c-getenv cname buffer nsizebuf))
(buffer1 (ct:malloc (1+ needed-size))))
(setf (ct:cref lpdword nsizebuf 0) needed-size)
- (prog1 (if (zerop (c-getenv cname buffer1 nsizebuf))
+ (prog1 (if (zerop (c-getenv cname buffer1 nsizebuf))
nil
(ct:c-string-to-lisp-string buffer1))
(ct:free buffer1)
(t (error "HOST must be a string, list of strings, NIL or :unspecific"))))
;|
-(uffi:def-function ("getenv" c-getenv)
+(uffi:def-function ("getenv" c-getenv)
((name :cstring))
:returning :cstring)
(check-type key string)
(uffi:with-cstring (key-native key)
(uffi:convert-from-cstring (c-getenv key-native))))
-
+
#examples-uffi
(progn
(flet ((print-results (str)
- (format t "~&(getenv ~S) => ~S" str (my-getenv str))))
+ (format t "~&(getenv ~S) => ~S" str (my-getenv str))))
(print-results "USER")
(print-results "_FOO_")))
(progn
(util.test:test (my-getenv "_FOO_") nil :fail-info "Error retrieving non-existent getenv")
(util.test:test (and (stringp (my-getenv "USER"))
- (< 0 (length (my-getenv "USER"))))
- t :fail-info "Error retrieving getenv")
+ (< 0 (length (my-getenv "USER"))))
+ t :fail-info "Error retrieving getenv")
)