/usr/share/doc/cl-uffi/examples/getenv.lisp is in cl-uffi 2.1.2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | ;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
;;;; *************************************************************************
;;;; FILE IDENTIFICATION
;;;;
;;;; Name: getenv.cl
;;;; Purpose: UFFI Example file to get environment variable
;;;; Programmer: Kevin M. Rosenberg
;;;; Date Started: Feb 2002
;;;;
;;;; This file, part of UFFI, is Copyright (c) 2002-2010 by Kevin M. Rosenberg
;;;;
;;;; *************************************************************************
(in-package :cl-user)
(uffi:def-function ("getenv" c-getenv)
((name :cstring))
:returning :cstring)
(defun my-getenv (key)
"Returns an environment variable, or NIL if it does not exist"
(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))))
(print-results "USER")
(print-results "_FOO_")))
#+test-uffi
(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")
)
|