c28270695a146650cfdc2b9284f223949fd84ddc
[uffi.git] / examples / getshells.lisp
1 ;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
2 ;;;; *************************************************************************
3 ;;;; FILE IDENTIFICATION
4 ;;;;
5 ;;;; Name:          getshells.cl
6 ;;;; Purpose:       UFFI Example file to get lisp of legal shells
7 ;;;; Programmer:    Kevin M. Rosenberg
8 ;;;; Date Started:  Mar 2002
9 ;;;;
10 ;;;; $Id$
11 ;;;;
12 ;;;; This file, part of UFFI, is Copyright (c) 2002 by Kevin M. Rosenberg
13 ;;;;
14 ;;;; UFFI users are granted the rights to distribute and use this software
15 ;;;; as governed by the terms of the Lisp Lesser GNU Public License
16 ;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL.
17 ;;;; *************************************************************************
18
19 (in-package :cl-user)
20
21
22 (uffi:def-function "setusershell"
23     nil
24   :returning :void)
25
26 (uffi:def-function "endusershell"
27     nil
28   :returning :void)
29
30 (uffi:def-function "getusershell"
31     nil
32   :returning :cstring)
33
34 (defun getshells ()
35   "Returns list of valid shells"
36   (setusershell)
37   (let (shells)
38     (do ((shell (uffi:convert-from-cstring (getusershell))
39                 (uffi:convert-from-cstring (getusershell))))
40         ((null shell))
41       (push shell shells))
42     (endusershell)
43     (nreverse shells)))
44
45 #+examples-uffi
46 (format t "~&Shells: ~S" (getshells))
47