1 ;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
2 ;;;; *************************************************************************
3 ;;;; FILE IDENTIFICATION
5 ;;;; Name: gethostname.cl
6 ;;;; Purpose: UFFI Example file to get hostname of system
7 ;;;; Programmer: Kevin M. Rosenberg
8 ;;;; Date Started: Mar 2002
10 ;;;; Copyright (c) 2002 Kevin M. Rosenberg
12 ;;;; $Id: gethostname.cl,v 1.4 2002/03/10 11:13:07 kevin Exp $
14 ;;;; This file is part of UFFI.
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.
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.
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 ;;;; *************************************************************************
33 ;;; This example is inspired by the example on the CL-Cookbook web site
35 (uffi:def-function ("gethostname" c-gethostname)
41 "Returns the hostname"
42 (let* ((name (uffi:allocate-foreign-string 256))
43 (result (c-gethostname name 256)))
46 (uffi:convert-from-foreign-string name)
47 (error "gethostname() failed."))
48 (uffi:free-foreign-object name))))
51 (format t "~&Hostname: ~A" (gethostname))