r1654: Added atoifl example
[uffi.git] / examples / atoifl.cl
1 ;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*-
2 ;;;; *************************************************************************
3 ;;;; FILE IDENTIFICATION
4 ;;;;
5 ;;;; Name:          atoifl.cl
6 ;;;; Purpose:       UFFI Example file to atoi/atof/atol
7 ;;;; Programmer:    Kevin M. Rosenberg
8 ;;;; Date Started:  Mar 2002
9 ;;;;
10 ;;;; $Id: atoifl.cl,v 1.1 2002/03/25 01:24:35 kevin Exp $
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 (uffi:def-function ("atoi" c-atoi) 
22     ((str :cstring))
23   :returning :int)
24
25 (defun atoi (str)
26   "Returns a int from a string."
27   (uffi:with-cstring (str-cstring str)
28     (c-atoi str-cstring)))
29   
30 #+test-uffi
31 (progn
32   (flet ((print-results (str)
33            (format t "~&(atoi ~S) => ~S" str (atoi str))))
34     (print-results "55")))
35
36