1 ;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*-
2 ;;;; *************************************************************************
3 ;;;; FILE IDENTIFICATION
6 ;;;; Purpose: UFFI Example file to atoi/atof/atol
7 ;;;; Programmer: Kevin M. Rosenberg
8 ;;;; Date Started: Mar 2002
10 ;;;; $Id: atoifl.lisp,v 1.1 2002/09/30 10:02:36 kevin Exp $
12 ;;;; This file, part of UFFI, is Copyright (c) 2002 by Kevin M. Rosenberg
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 ;;;; *************************************************************************
21 (uffi:def-function ("atoi" c-atoi)
25 (uffi:def-function ("atol" c-atol)
29 (uffi:def-function ("atof" c-atof)
34 "Returns a int from a string."
35 (uffi:with-cstring (str-cstring str)
36 (c-atoi str-cstring)))
39 "Returns a double float from a string."
40 (uffi:with-cstring (str-cstring str)
41 (c-atof str-cstring)))
45 (flet ((print-results (str)
46 (format t "~&(atoi ~S) => ~S" str (atoi str))))
47 (print-results "55")))
52 (util.test:test (atoi "123") 123 :test #'eql
53 :fail-info "Error with atoi")
54 (util.test:test (atoi "") 0 :test #'eql
55 :fail-info "Error with atoi")
56 (util.test:test (atof "2.23") 2.23d0 :test #'eql
57 :fail-info "Error with atof")