r1518: Initial revision
[uffi.git] / examples / getshells.cl
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 ;;;; Copyright (c) 2002 Kevin M. Rosenberg
11 ;;;;
12 ;;;; $Id: getshells.cl,v 1.1 2002/03/09 19:55:33 kevin Exp $
13 ;;;;
14 ;;;; This file is part of UFFI. 
15 ;;;;
16 ;;;; UFFI is free software; you can redistribute it and/or modify
17 ;;;; it under the terms of the GNU General Public License (version 2) as
18 ;;;; published by the Free Software Foundation.
19 ;;;;
20 ;;;; UFFI is distributed in the hope that it will be useful,
21 ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
22 ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23 ;;;; GNU General Public License for more details.
24 ;;;;
25 ;;;; You should have received a copy of the GNU General Public License
26 ;;;; along with UFFI; if not, write to the Free Software Foundation, Inc.,
27 ;;;; 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
28 ;;;; *************************************************************************
29
30 (in-package :cl-user)
31
32
33 (uffi:def-routine "setusershell"
34     nil
35   :returning :void)
36
37 (uffi:def-routine "endusershell"
38     nil
39   :returning :void)
40
41 (uffi:def-routine "getusershell"
42     nil
43   :returning :c-string)
44
45 (defun getshells ()
46   "Returns list of valid shells"
47   (setusershell)
48   (let (shells)
49     (do ((shell (uffi:convert-from-c-string (getusershell))
50                 (uffi:convert-from-c-string (getusershell))))
51         ((null shell))
52       (push shell shells))
53     (endusershell)
54     (nreverse shells)))
55     
56 (format t "~&Shells: ~S" (getshells))
57