r2912: rename .cl to .lisp
[uffi.git] / examples / getshells.lisp
diff --git a/examples/getshells.lisp b/examples/getshells.lisp
new file mode 100644 (file)
index 0000000..1b05d10
--- /dev/null
@@ -0,0 +1,47 @@
+;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
+;;;; *************************************************************************
+;;;; FILE IDENTIFICATION
+;;;;
+;;;; Name:          getshells.cl
+;;;; Purpose:       UFFI Example file to get lisp of legal shells
+;;;; Programmer:    Kevin M. Rosenberg
+;;;; Date Started:  Mar 2002
+;;;;
+;;;; $Id: getshells.lisp,v 1.1 2002/09/30 10:02:36 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)
+
+
+(uffi:def-function "setusershell"
+    nil
+  :returning :void)
+
+(uffi:def-function "endusershell"
+    nil
+  :returning :void)
+
+(uffi:def-function "getusershell"
+    nil
+  :returning :cstring)
+
+(defun getshells ()
+  "Returns list of valid shells"
+  (setusershell)
+  (let (shells)
+    (do ((shell (uffi:convert-from-cstring (getusershell))
+                (uffi:convert-from-cstring (getusershell))))
+       ((null shell))
+      (push shell shells))
+    (endusershell)
+    (nreverse shells)))
+
+#+examples-uffi
+(format t "~&Shells: ~S" (getshells))
+