r8104: convert to use of XML Docbook files
authorKevin M. Rosenberg <kevin@rosenberg.net>
Tue, 11 Nov 2003 03:36:01 +0000 (03:36 +0000)
committerKevin M. Rosenberg <kevin@rosenberg.net>
Tue, 11 Nov 2003 03:36:01 +0000 (03:36 +0000)
doc/Makefile
doc/Makefile.sgml [new file with mode: 0644]
doc/appendix.sgml
doc/appendix.xml [new file with mode: 0644]
doc/bookinfo.xml [new file with mode: 0644]
doc/glossary.xml [new file with mode: 0644]
doc/intro.xml [new file with mode: 0644]
doc/notes.xml [new file with mode: 0644]
doc/preface.xml [new file with mode: 0644]
doc/ref.xml [new file with mode: 0644]
doc/uffi.xml

index a87f333c20b1cc867f54c4784a1128a505eace1a..20a9aa6c6deca4dff7d69980addc3254e0124f1e 100644 (file)
 ##############################################################################
 
 
-# System variable to select catalog file
-SYSTEM=debian
-# SYSTEM=redhat
-
-# Nothing to configure beyond this point
-
-CATALOG=catalog.$(SYSTEM)
-
-# Custom DSSSL's
-DSSSL_HTML=../dsssl/html/docbook.dsl
-DSSSL_PRINT=dsssl/print/docbook.dsl
-
 DOCFILE_BASE_DEFAULT=uffi
-DOCFILE_EXT_DEFAULT=sgml
+DOCFILE_EXT_DEFAULT=xml
 
 # Standard docfile processing
 
@@ -42,10 +30,11 @@ DOCFILE_EXT=${DOCFILE_EXT_DEFAULT}
 endif
 
 DOCFILE=${DOCFILE_BASE}.${DOCFILE_EXT}
-TEXFILE=${DOCFILE_BASE}.tex
+FOFILE=${DOCFILE_BASE}.fo
 PDFFILE=${DOCFILE_BASE}.pdf
 PSFILE=${DOCFILE_BASE}.ps
 DVIFILE=${DOCFILE_BASE}.dvi
+TXTFILE=${DOCFILE_BASE}.txt
 TMPFILES=${DOCFILE_BASE}.aux ${DOCFILE_BASE}.out ${DOCFILE_BASE}.log
 DOCFILES=$(shell echo *.sgml)
 
@@ -58,8 +47,6 @@ dist: html pdf
 .PHONY: doc
 doc: html pdf
 
-CHECK=nsgmls -s -C ${CATALOG} || exit 1
-
 .PHONY: check
 check:
        @$(CHECK)
@@ -68,47 +55,44 @@ check:
 html: html.tar.gz
 
 html.tar.gz: $(DOCFILES) Makefile
-       @$(CHECK)
-       @( rm -rf html ; mkdir html; cd html ; jade -t sgml -c ../${CATALOG} -d ${DSSSL_HTML} ../${DOCFILE} > /dev/null; cp book1.html index.html; cd ..; GZIP='-9' tar czf html.tar.gz html)
+       @rm -rf html
+       @xmlto -o html xhtml $(DOCFILE)
+       @GZIP='-9' tar czf html.tar.gz html 
 
-.PHONY: tex
-tex: ${TEXFILE}
+.PHONY: fo
+fo: ${FOFILE}
 
-${TEXFILE}: ${DOCFILES}
-       @$(CHECK)
-       @jade -t tex -c ${CATALOG} -d ${DSSSL_PRINT} ${DOCFILE} > /dev/null
+${FOFILE}: $(DOCFILES) Makefile
+       @xmlto fo $(DOCFILE)
 
 .PHONY: pdf
 pdf: ${PDFFILE}
 
-${PDFFILE}: ${DOCFILES}
-       @jade -t tex -c ${CATALOG} -d ${DSSSL_PRINT} ${DOCFILE} > /dev/null
-       @pdfjadetex -interaction=batchmode '\pdfcompresslevel=9' '\input ${TEXFILE}' > /dev/null
-       @pdfjadetex -interaction=batchmode '\pdfcompresslevel=9' '\input ${TEXFILE}' > /dev/null
-       @pdfjadetex -interaction=batchmode '\pdfcompresslevel=9' '\input ${TEXFILE}' > /dev/null
-       @pdfjadetex -interaction=batchmode '\pdfcompresslevel=9' '\input ${TEXFILE}' > /dev/null
+${PDFFILE}: ${FOFILE}
+       @fop $(FOFILE) -pdf $(PDFFILE) > /dev/null
 
 .PHONY: dvi
 dvi: ${DVIFILE}
 
-${DVIFILE}: ${TEXFILE}
-       @jadetex ${TEXFILE} > /dev/null
-       @jadetex ${TEXFILE} > /dev/null
-       @jadetex ${TEXFILE} > /dev/null
-       @jadetex ${TEXFILE} > /dev/null
-
 .PHONY: ps
 ps: ${PSFILE}
 
-${PSFILE}: ${DVIFILE}
-       @dvips -o ${PSFILE} ${DVIFILE} > /dev/null
+${PSFILE}: ${FOFILE}
+       @fop $(FOFILE) -ps $(PSFILE) > /dev/null
+
+
+.PHONY: txt
+txt: ${TXTFILE}
+
+${TXTFILE}: ${FOFILE}
+       @fop $(FOFILE) -txt $(TXTFILE) > /dev/null
 
 .PHONY: clean
 clean: 
        @rm -f *~ *.bak *.orig \#*\# .\#* texput.log
        @rm -rf html ${PSFILE}
-       @rm -f ${TMPFILES}
-       @rm -f  ${DVIFILE} ${TEXFILE}
+       @rm -f ${TMPFILES} ${FOFILE}
+       @rm -f  ${DVIFILE} ${TXTFILE}
 
 .PHONY: distclean
 distclean: clean
diff --git a/doc/Makefile.sgml b/doc/Makefile.sgml
new file mode 100644 (file)
index 0000000..a87f333
--- /dev/null
@@ -0,0 +1,114 @@
+##############################################################################
+# FILE IDENTIFICATION
+# 
+#  Name:         Makefile
+#  Purpose:      Makefile for the uffi documentation
+#  Programer:    Kevin M. Rosenberg
+#  Date Started: Mar 2002
+#
+#  CVS Id:   $Id$
+#
+# This file, part of UFFI, is Copyright (c) 2002-2003 by Kevin M. Rosenberg
+#
+# UFFI users are granted the rights to distribute and use this software
+# as governed by the terms of the Lisp Lesser GNU Public License
+# (http://opensource.franz.com/preamble.html), also known as the LLGPL.
+##############################################################################
+
+
+# System variable to select catalog file
+SYSTEM=debian
+# SYSTEM=redhat
+
+# Nothing to configure beyond this point
+
+CATALOG=catalog.$(SYSTEM)
+
+# Custom DSSSL's
+DSSSL_HTML=../dsssl/html/docbook.dsl
+DSSSL_PRINT=dsssl/print/docbook.dsl
+
+DOCFILE_BASE_DEFAULT=uffi
+DOCFILE_EXT_DEFAULT=sgml
+
+# Standard docfile processing
+
+ifndef DOCFILE_BASE
+DOCFILE_BASE=${DOCFILE_BASE_DEFAULT}
+endif
+
+ifndef DOCFILE_EXT
+DOCFILE_EXT=${DOCFILE_EXT_DEFAULT}
+endif
+
+DOCFILE=${DOCFILE_BASE}.${DOCFILE_EXT}
+TEXFILE=${DOCFILE_BASE}.tex
+PDFFILE=${DOCFILE_BASE}.pdf
+PSFILE=${DOCFILE_BASE}.ps
+DVIFILE=${DOCFILE_BASE}.dvi
+TMPFILES=${DOCFILE_BASE}.aux ${DOCFILE_BASE}.out ${DOCFILE_BASE}.log
+DOCFILES=$(shell echo *.sgml)
+
+.PHONY: all
+all: html pdf 
+
+.PHONY: dist
+dist: html pdf
+
+.PHONY: doc
+doc: html pdf
+
+CHECK=nsgmls -s -C ${CATALOG} || exit 1
+
+.PHONY: check
+check:
+       @$(CHECK)
+
+.PHONY: html
+html: html.tar.gz
+
+html.tar.gz: $(DOCFILES) Makefile
+       @$(CHECK)
+       @( rm -rf html ; mkdir html; cd html ; jade -t sgml -c ../${CATALOG} -d ${DSSSL_HTML} ../${DOCFILE} > /dev/null; cp book1.html index.html; cd ..; GZIP='-9' tar czf html.tar.gz html)
+
+.PHONY: tex
+tex: ${TEXFILE}
+
+${TEXFILE}: ${DOCFILES}
+       @$(CHECK)
+       @jade -t tex -c ${CATALOG} -d ${DSSSL_PRINT} ${DOCFILE} > /dev/null
+
+.PHONY: pdf
+pdf: ${PDFFILE}
+
+${PDFFILE}: ${DOCFILES}
+       @jade -t tex -c ${CATALOG} -d ${DSSSL_PRINT} ${DOCFILE} > /dev/null
+       @pdfjadetex -interaction=batchmode '\pdfcompresslevel=9' '\input ${TEXFILE}' > /dev/null
+       @pdfjadetex -interaction=batchmode '\pdfcompresslevel=9' '\input ${TEXFILE}' > /dev/null
+       @pdfjadetex -interaction=batchmode '\pdfcompresslevel=9' '\input ${TEXFILE}' > /dev/null
+       @pdfjadetex -interaction=batchmode '\pdfcompresslevel=9' '\input ${TEXFILE}' > /dev/null
+
+.PHONY: dvi
+dvi: ${DVIFILE}
+
+${DVIFILE}: ${TEXFILE}
+       @jadetex ${TEXFILE} > /dev/null
+       @jadetex ${TEXFILE} > /dev/null
+       @jadetex ${TEXFILE} > /dev/null
+       @jadetex ${TEXFILE} > /dev/null
+
+.PHONY: ps
+ps: ${PSFILE}
+
+${PSFILE}: ${DVIFILE}
+       @dvips -o ${PSFILE} ${DVIFILE} > /dev/null
+
+.PHONY: clean
+clean: 
+       @rm -f *~ *.bak *.orig \#*\# .\#* texput.log
+       @rm -rf html ${PSFILE}
+       @rm -f ${TMPFILES}
+       @rm -f  ${DVIFILE} ${TEXFILE}
+
+.PHONY: distclean
+distclean: clean
index cf1b4cd358f594e29b2ae031b82c07b3502e9ca1..2c89396ecfc2d4802c48168d5f4ad3fea0a988dc 100644 (file)
@@ -6,7 +6,7 @@
     <title>Download &uffi;</title>
     <para>
 You need to download the &uffi; package from its web
-<ulink url="http://uffi.med-info.com"><citetitle>home</citetitle></ulink>.
+<ulink url="http://uffi.b9.com"><citetitle>home</citetitle></ulink>.
 You also need to have a copy of &asdf;. If you need a copy of
 &asdf;, it is included in the 
   <ulink
diff --git a/doc/appendix.xml b/doc/appendix.xml
new file mode 100644 (file)
index 0000000..6892ec7
--- /dev/null
@@ -0,0 +1,30 @@
+<?xml version='1.0' ?>   <!-- Mode: Docbook --> 
+
+<appendix>
+  <title>Installation</title>
+  <sect1>
+    <title>Download &uffi;</title>
+    <para>
+You need to download the &uffi; package from its web
+<ulink url="http://uffi.b9.com"><citetitle>home</citetitle></ulink>.
+You also need to have a copy of &asdf;. If you need a copy of
+&asdf;, it is included in the 
+  <ulink
+      url="http://www.sourceforge.net/projects/cclan">
+      <citetitle>CCLAN</citetitle></ulink> package. You can download
+the file <filename>defsystem.lisp</filename> from the CVS 
+<ulink url="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/cclan/asdf/asdf.lisp"><citetitle>tree</citetitle></ulink>.
+    </para>
+  </sect1>
+  <sect1>
+    <title>Installation</title>
+    <para>
+      After downloading and installing &asdf;, simply
+      <function>push</function> the
+      directory containing &uffi; into
+      <varname>asdf:*central-registry*</varname> variable. Whenever you
+want to load the &uffi; package, use the function
+      <computeroutput>(asdf:oos 'asdf:load-op :uffi)</computeroutput>.
+    </para>
+  </sect1>
+</appendix>
diff --git a/doc/bookinfo.xml b/doc/bookinfo.xml
new file mode 100644 (file)
index 0000000..4213f7b
--- /dev/null
@@ -0,0 +1,70 @@
+<?xml version='1.0' ?>   <!-- -*- DocBook -*- -->
+
+  <bookinfo>
+    <title>&uffi; Reference Guide</title>
+    <author>
+      <firstname>Kevin</firstname>
+      <othername>M.</othername>
+      <surname>Rosenberg</surname>
+    <affiliation>
+       <orgname>Heart Hospital of New Mexico</orgname>
+       <address>
+       <email>kevin@rosenberg.net</email>
+        <street>504 Elm Street N.E.</street>
+        <city>Albuquerque</city>
+        <state>New Mexico</state>
+        <postcode>87102</postcode>
+        </address>
+      </affiliation>
+    </author>
+      
+    <printhistory>
+      <simpara>$Id$</simpara>
+      <simpara>File $Date$</simpara>
+    </printhistory>
+    <copyright>
+      <year>2002-2003</year>
+      <holder>Kevin M. Rosenberg</holder>
+    </copyright>
+    <legalnotice>
+      <itemizedlist>
+       <listitem>
+         <para>The &uffi; package was designed and
+           written by Kevin M. Rosenberg.
+         </para>
+       </listitem>
+<listitem>
+<para>
+      Permission is granted to copy, distribute and/or modify this document
+      under the terms of the GNU Free Documentation License, Version 1.1
+      or any later version published by the Free Software Foundation;
+      with no Invariant Sections, with the no
+      Front-Cover Texts, and with no Back-Cover Texts.
+      A copy of the license is included in the &uffi; distribution.
+</para>
+</listitem>
+       <listitem>
+         <para><application>Allegro CL</application>&reg; is a registered
+           trademark of Franz Inc.
+         </para>
+       </listitem>
+       <listitem>
+         <para><application>Lispworks</application>&reg; is a registered
+           trademark of Xanalys Inc.
+         </para>
+       </listitem>
+       <listitem>
+         <para><application>Microsoft
+           Windows</application>&reg; is a registered trademark of
+           Microsoft Inc.
+         </para>
+       </listitem>
+       <listitem>
+         <para>Other brand or
+           product names are the registered trademarks or trademarks of
+           their respective holders.
+         </para>
+       </listitem>
+      </itemizedlist>
+    </legalnotice>
+  </bookinfo>
diff --git a/doc/glossary.xml b/doc/glossary.xml
new file mode 100644 (file)
index 0000000..4f8943e
--- /dev/null
@@ -0,0 +1,16 @@
+<?xml version="1.0" ?>   <!-- -*- Mode: DocBook -*- -->
+
+<glossary>
+  <glossentry id="gloss-ffi">
+    <glossterm>Foreign Function Interface
+      <acronym>FFI</acronym>)
+    </glossterm>
+    <glossdef>
+      <para>
+        An interface to a C-compatible library.
+      </para>
+    </glossdef>
+  </glossentry>
+</glossary>
+
+
diff --git a/doc/intro.xml b/doc/intro.xml
new file mode 100644 (file)
index 0000000..6f3863b
--- /dev/null
@@ -0,0 +1,108 @@
+<?xml version='1.0' ?>   <!-- Mode: Docbook --> 
+
+<chapter>
+  <title>Introduction</title>
+  <sect1>
+    <title>Purpose</title>
+    <para> This reference guide describes
+      &uffi;, a package that provides a cross-implementation
+      interface from Common Lisp to C-language compatible libraries.
+    </para>
+  </sect1>
+
+  <sect1>
+    <title>Background
+    </title>
+    <para>
+      Every Common Lisp implementation has
+      a method for interfacing to C-language compatible
+      libraries. These methods are often termed a 
+      <emphasis>Foreign Function Library Interface</emphasis>
+      (&ffi;). Unfortunately, these methods vary widely
+      amongst
+      implementations, thus preventing the writing of a portable FFI to a 
+particular C-library. 
+    </para>
+    <para>
+      &uffi; gathers a common subset of functionality between Common Lisp
+      implementations. &uffi; wraps this common subset of functionality with
+      it's own syntax and provides macro translation of uffi functions into
+      the specific syntax of supported Common Lisp implementations.
+    </para>
+    <para>
+      Developers who use &uffi; to interface with C libraries will
+      automatically have their code function in each of uffi's supported
+      implementations.
+    </para>
+  </sect1>
+
+  <sect1>
+    <title>Supported Implementations</title> 
+    <para>The primary tested and supported platforms for &uffi; are: 
+    </para>
+    <itemizedlist mark="opencircle">
+      <listitem><para>&acl; v6.2 on Debian GNU/Linux
+FreeBSD 4.5, Solaris v2.8, and Microsoft Windows XP.</para></listitem>
+      <listitem><para>&lw; v4.2 on Debian GNU/Linux and Microsoft Windows XP.</para></listitem>
+      <listitem><para>&cmucl; 18d on Debian GNU/Linux, FreeBSD 4.5, and Solaris 2.8</para></listitem>
+      <listitem><para>&sbcl; 0.7.8 on Debian GNU/Linux</para></listitem>
+      <listitem><para>&scl; 1.1.1 on Debian GNU/Linux</para></listitem>
+      <listitem><para>&openmcl; 0.13 on Debian GNU/Linux for PowerPC</para></listitem>
+    </itemizedlist>
+    <para>Beta code is included with &uffi; for
+    </para>
+    <itemizedlist mark="opencircle">
+      <listitem><para>&openmcl; and &mcl; with MacOSX</para></listitem>
+    </itemizedlist>
+  </sect1>
+
+    <sect1>
+      <title>Design</title>
+      <sect2>
+       <title>Overview</title>
+       <para>
+         &uffi; was designed as a cross-implementation 
+         compatible <emphasis>Foreign Function Interface</emphasis>.
+         Necessarily,
+         only a common subset of functionality can be
+         provided. Likewise, not every optimization for that a specific
+         implementation provides can be supported. Wherever possible,
+         though, implementation-specific optimizations are invoked.
+       </para> 
+      </sect2>
+
+      <sect2>
+       <title>Priorities</title>
+       <para>
+         The design of &uffi; is dictated by the order of these priorities:
+       </para>
+       <itemizedlist>
+         <listitem>
+           <para>
+             Code using &uffi; must operate correctly on all
+             supported implementations.
+           </para>
+         </listitem>
+         <listitem>
+           <para>
+             Take advantage of implementation-specific optimizations. Ideally, 
+             there will not a situation where an implementation-specific
+             &ffi; will be chosen due to lack of optimizations in &uffi;.
+           </para>
+         </listitem>
+         <listitem>
+           <para>Provide a simple interface to developers using
+&uffi;.  This priority is quite a bit lower than the above priorities.
+This lower priority is manifest by programmers having to pass types in
+pointer and array dereferencing, needing to use
+<constant>cstring</constant> wrapper functions, and the use of
+ensure-char-character and ensure-char-integer functions. My hope is
+that the developer inconvenience will be outweighed by the generation
+of optimized code that is cross-implementation compatible.
+           </para>
+         </listitem>
+       </itemizedlist>
+      </sect2>
+    </sect1>
+
+</chapter>
diff --git a/doc/notes.xml b/doc/notes.xml
new file mode 100644 (file)
index 0000000..b4f143e
--- /dev/null
@@ -0,0 +1,89 @@
+<?xml version='1.0' ?>   <!-- Mode: Docbook --> 
+
+<chapter>
+  <title>Programming Notes</title>
+
+  <sect1>
+    <title>Implementation Specific Notes</title> 
+    <para>
+    </para>
+      <sect2>
+       <title>&acl;</title>
+       <para>
+       </para>
+      </sect2>
+      <sect2>
+       <title>&lw;</title>
+       <para>
+       </para>
+      </sect2>
+      <sect2>
+       <title>&cmucl;</title>
+       <para>
+       </para>
+      </sect2>
+  </sect1>
+
+  <sect1>
+    <title>Foreign Object Representation and Access</title>
+    <para> There are two main approaches used to represent foreign
+    objects: an integer that represents an address in memory, and a
+    object that also includes run-time typing. The advantage of
+    run-time typing is the system can dereference pointers and perform
+    array access without those functions requiring a type at the cost
+    of additional overhead to generate and store the run-time
+    typing. The advantage of integer representation, at least for
+    &acl;, is that the compiler can generate inline code to
+    dereference pointers. Further, the overhead of the run-time type
+    information is eliminated. The disadvantage is the program must
+    then supply
+    the type to the functions to dereference objects and array.
+    </para>
+  </sect1>
+
+  <sect1>
+    <title>Optimizing Code Using UFFI</title>
+    <sect2>
+      <title>Background</title>
+      <para> 
+       Two implementions have different techniques to optimize
+       (open-code) foreign objects. &acl; can open-code foreign
+       object
+       access if pointers are integers and the type of object is
+    specified in the access function.  Thus, &uffi; represents objects
+    in &acl; as integers which don't have type information.
+    </para> <para> 
+      &cmucl; works best when keeping objects as typed
+    objects. However, it's compiler can open-code object access when
+    the object type is specified in <function>declare</function>
+    commands and in <varname>:type</varname> specifiers in
+    <function>defstruct</function> and <function>defclass</function>.
+    </para> <para> &lw;, in converse to &acl; and &cmucl; does not do
+    any open coding of object access. &lw;, by default, maintains
+    objects with run-time typing.  </para>
+    </sect2>
+    <sect2>
+      <title>Cross-Implementation Optimization</title>
+      <para>
+       To fully optimize across platforms, both explicit type
+       information must be passed to dereferencing of pointers and
+       arrays. Though this optimization only helps with &acl;, &uffi;
+       is designed to require this type information be passed the
+       dereference functions. Second, declarations of type should be
+       made in functions, structures, and classes where foreign
+       objects will be help. This will optimize access for &lw;
+      </para>
+      <para>
+       Here is an example that should both methods being used for
+       maximum cross-implementation optimization:
+       <programlisting>
+(uffi:def-type the-struct-type-def the-struct-type)
+(let ((a-foreign-struct (allocate-foreign-object 'the-struct-type)))
+  (declare 'the-struct-type-def a-foreign-struct)
+  (get-slot-value a-foreign-struct 'the-struct-type 'field-name))
+       </programlisting>
+      </para>
+    </sect2>
+  </sect1>
+
+</chapter>
diff --git a/doc/preface.xml b/doc/preface.xml
new file mode 100644 (file)
index 0000000..6b8238b
--- /dev/null
@@ -0,0 +1,12 @@
+<?xml version='1.0' ?>   <!-- Mode: Docbook --> 
+
+<preface>
+  <title>Preface</title>
+  <para>This reference guide describes the usage and features
+    of &uffi;.  The first 
+    chapter provides an overview to the design of &uffi;.
+    Following that chapter is the reference section for all user
+    accessible functions of &uffi;. The appendix covers the
+    installation and implementation-specifc features of &uffi;.
+  </para>
+</preface>
diff --git a/doc/ref.xml b/doc/ref.xml
new file mode 100644 (file)
index 0000000..6f817cd
--- /dev/null
@@ -0,0 +1,2461 @@
+<?xml version='1.0' ?>   <!-- Mode: Docbook --> 
+  
+<reference>
+  <title>Declarations</title>
+
+  <partintro>
+    <sect1>
+      <title>Overview</title>
+      <para>Declarations are used to give the compiler optimizing
+       information about foreign types. Currently, only &cmucl;
+       supports declarations. On &acl; and &lw;, these expressions 
+       declare the type generically as &t;
+      </para>
+    </sect1>
+  </partintro>
+
+      <refentry id="def-type">
+       <refnamediv>
+         <refname>def-type</refname>
+       <refpurpose>Defines a Common Lisp type. 
+       </refpurpose>
+       <refclass>Macro</refclass>
+      </refnamediv>
+      <refsynopsisdiv>
+       <title>Syntax</title>
+       <synopsis>
+         <function>def-type</function> <replaceable>name type</replaceable>
+       </synopsis>
+      </refsynopsisdiv>
+      <refsect1>
+       <title>Arguments and Values</title>
+       <variablelist>
+         <varlistentry>
+           <term><parameter>name</parameter></term>
+           <listitem>
+             <para>A symbol naming the type</para>
+           </listitem>
+         </varlistentry>
+         <varlistentry>
+           <term><parameter>type</parameter></term>
+           <listitem>
+             <para>A form that is evaluated that specifies the &uffi; type.
+             </para>
+           </listitem>
+         </varlistentry>
+       </variablelist>
+      </refsect1>
+      <refsect1>
+       <title>Description</title>
+       <para>Defines a Common Lisp type based on a &uffi; type.
+       </para>
+      </refsect1>
+      <refsect1>
+       <title>Examples</title>
+       <programlisting>
+(def-type char-ptr '(* :char))
+...
+(defun foo (ptr)
+  (declare (type char-ptr ptr))
+  ...
+       </programlisting>
+      </refsect1>
+      <refsect1>
+       <title>Side Effects</title>
+       <para>Defines a new &cl; type.</para>
+      </refsect1>
+      <refsect1>
+       <title>Affected by</title>
+       <para>None.</para>
+      </refsect1>
+      <refsect1>
+       <title>Exceptional Situations</title>
+       <para>None.</para>
+      </refsect1>
+    </refentry>
+  </reference>
+
+
+  <reference>
+    <title>Primitive Types</title>
+    <partintro>
+      <title>Overview</title>
+       <para>
+         Primitive types have a single value, these include
+         characters, numbers, and pointers. They are all symbols in
+         the keyword package.
+       </para>
+       <itemizedlist>
+         <listitem>
+           <para><constant>:char</constant> - Signed 8-bits. A
+dereferenced :char pointer returns an character.</para>
+         </listitem>
+         <listitem>
+           <para><constant>:unsigned-char</constant> - Unsigned 8-bits. A dereferenced :unsigned-char
+pointer returns an character.</para>
+         </listitem>
+         <listitem>
+           <para><constant>:byte</constant> - Signed 8-bits. A
+dereferenced :byte pointer returns an integer.</para>
+          </listitem>
+         <listitem>
+           <para><constant>:unsigned-byte</constant> - Unsigned 8-bits. A
+dereferenced :unsigned-byte pointer returns an integer.</para>
+         </listitem>
+         <listitem>
+           <para><constant>:short</constant> - Signed 16-bits.</para>
+         </listitem>
+         <listitem>
+           <para><constant>:unsigned-short</constant> - Unsigned 16-bits.</para>
+         </listitem>
+         <listitem>
+           <para><constant>:int</constant> - Signed 32-bits.</para>
+         </listitem>
+         <listitem>
+           <para><constant>:unsigned-int</constant> - Unsigned 32-bits.</para>
+         </listitem>
+         <listitem>
+           <para><constant>:long</constant> - Signed 32 or 64 bits, depending upon the platform.</para>
+         </listitem>
+         <listitem>
+           <para><constant>:unsigned-long</constant> - Unsigned 32 or 64 bits, depending upon the platform.</para>
+         </listitem>
+         <listitem>
+           <para><constant>:float</constant> - 32-bit floating point.</para>
+         </listitem>
+         <listitem>
+           <para><constant>:double</constant> - 64-bit floating point.</para>
+         </listitem>
+         <listitem>
+           <para><constant>:cstring</constant> - 
+A &null; terminated string used for passing and returning characters strings with a &c; function.
+           </para>
+         </listitem>
+         <listitem>
+           <para><constant>:void</constant> - 
+The absence of a value. Used to indicate that a function does not return a value.</para>
+         </listitem>
+         <listitem>
+           <para><constant>:pointer-void</constant> - 
+Points to a generic object.</para>
+         </listitem>
+         <listitem>
+           <para><constant>*</constant> - Used to declare a pointer to an object</para>
+         </listitem>
+       </itemizedlist>
+      </partintro>
+
+      <refentry id="def-constant">
+       <refnamediv>
+         <refname>def-constant</refname>
+       <refpurpose>Binds a symbol to a constant. 
+       </refpurpose>
+       <refclass>Macro</refclass>
+      </refnamediv>
+      <refsynopsisdiv>
+       <title>Syntax</title>
+       <synopsis>
+         <function>def-constant</function> <replaceable>name value &amp;key export</replaceable>
+       </synopsis>
+      </refsynopsisdiv>
+      <refsect1>
+       <title>Arguments and Values</title>
+       <variablelist>
+         <varlistentry>
+           <term><parameter>name</parameter></term>
+           <listitem>
+             <para>A symbol that will be bound to the value.
+             </para>
+           </listitem>
+         </varlistentry>
+         <varlistentry>
+           <term><parameter>value</parameter></term>
+           <listitem>
+             <para>An evaluated form that is bound the the name.
+             </para>
+           </listitem>
+         </varlistentry>
+         <varlistentry>
+           <term><parameter>export</parameter></term>
+           <listitem>
+             <para>When &t;, the name is exported from the current package. The default is &nil;</para>
+           </listitem>
+         </varlistentry>
+       </variablelist>
+      </refsect1>
+      <refsect1>
+       <title>Description</title>
+       <para>
+         This is a thin wrapper around
+         <function>defconstant</function>. It evaluates at
+           compile-time and optionally exports the symbol from the package.
+       </para>
+      </refsect1>
+      <refsect1>
+       <title>Examples</title>
+       <programlisting>
+(def-constant pi2 (* 2 pi))
+(def-constant exported-pi2 (* 2 pi) :export t)
+       </programlisting>
+      </refsect1>
+      <refsect1>
+       <title>Side Effects</title>
+       <para>Creates a new special variable..</para>
+      </refsect1>
+      <refsect1>
+       <title>Affected by</title>
+       <para>None.</para>
+      </refsect1>
+      <refsect1>
+       <title>Exceptional Situations</title>
+       <para>None.</para>
+      </refsect1>
+    </refentry>
+
+    <refentry id="def-foreign-type">
+       <refnamediv>
+         <refname>def-foreign-type</refname>
+       <refpurpose>Defines a new foreign type. 
+       </refpurpose>
+       <refclass>Macro</refclass>
+      </refnamediv>
+      <refsect1>
+       <title>Syntax</title>
+<synopsis>
+         <function>def-foreign-type</function> <replaceable>name type</replaceable>
+</synopsis>
+      </refsect1>
+      <refsect1>
+       <title>Arguments and Values</title>
+       <variablelist>
+         <varlistentry>
+           <term><parameter>name</parameter></term>
+           <listitem>
+             <para>A symbol naming the new foreign type.
+             </para>
+           </listitem>
+         </varlistentry>
+         <varlistentry>
+           <term><parameter>value</parameter></term>
+           <listitem>
+             <para>A form that is not evaluated that defines the new
+foreign type.
+             </para>
+           </listitem>
+         </varlistentry>
+       </variablelist>
+      </refsect1>
+      <refsect1>
+       <title>Description</title>
+       <para>Defines a new foreign type.
+       </para>
+      </refsect1>
+      <refsect1>
+       <title>Examples</title>
+       <programlisting>
+(def-foreign-type my-generic-pointer :pointer-void)
+(def-foreign-type a-double-float :double-float)
+(def-foreign-type char-ptr (* :char))
+       </programlisting>
+      </refsect1>
+      <refsect1>
+       <title>Side Effects</title>
+       <para>Defines a new foreign type.
+       </para>
+      </refsect1>
+      <refsect1>
+       <title>Affected by</title>
+       <para>None.</para>
+      </refsect1>
+      <refsect1>
+       <title>Exceptional Situations</title>
+       <para>None.</para>
+      </refsect1>
+    </refentry>
+
+    <refentry id="null-char-p">
+       <refnamediv>
+         <refname>null-char-p</refname>
+       <refpurpose>Tests a character for &null; value.
+       </refpurpose>
+       <refclass>Macro</refclass>
+      </refnamediv>
+      <refsect1>
+       <title>Syntax</title>
+<synopsis>
+         <function>null-char-p</function> <replaceable>char</replaceable> => <returnvalue>is-null</returnvalue>
+</synopsis>
+      </refsect1>
+      <refsect1>
+       <title>Arguments and Values</title>
+       <variablelist>
+         <varlistentry>
+           <term><parameter>char</parameter></term>
+           <listitem>
+             <para>A character or integer.
+             </para>
+           </listitem>
+         </varlistentry>
+         <varlistentry>
+           <term><parameter>is-null</parameter></term>
+           <listitem>
+             <para>A boolean flag indicating if char is a &null; value.
+             </para>
+           </listitem>
+         </varlistentry>
+       </variablelist>
+      </refsect1>
+      <refsect1>
+       <title>Description</title>
+       <para>
+         A predicate testing if a character or integer is &null;. This
+abstracts the difference in implementations where some return a 
+<computeroutput>character</computeroutput> and some return a 
+<computeroutput>integer</computeroutput> whence dereferencing a 
+<computeroutput>C</computeroutput> character pointer.
+       </para>
+      </refsect1>
+      <refsect1>
+       <title>Examples</title>
+       <programlisting>
+(def-array-pointer ca :unsigned-char)
+(let ((fs (convert-to-foreign-string "ab")))
+   (values (null-char-p (deref-array fs 'ca 0))
+           (null-char-p (deref-array fs 'ca 2))))
+=> &nil;
+   &t;
+       </programlisting>
+      </refsect1>
+      <refsect1>
+       <title>Side Effects</title>
+       <para>None.
+       </para>
+      </refsect1>
+      <refsect1>
+       <title>Affected by</title>
+       <para>None.</para>
+      </refsect1>
+      <refsect1>
+       <title>Exceptional Situations</title>
+       <para>None.</para>
+      </refsect1>
+    </refentry>
+  </reference>
+
+  <reference>
+    <title>Aggregate Types</title>
+    <partintro>
+      <title>Overview</title>
+      <para>
+       Aggregate types are comprised of one or more primitive types.
+      </para>
+    </partintro>
+
+    <refentry id="def-enum">
+      <refnamediv>
+       <refname>def-enum</refname>
+       <refpurpose>Defines a &c; enumeration.
+       </refpurpose>
+       <refclass>Macro</refclass>
+      </refnamediv>
+      <refsynopsisdiv>
+       <title>Syntax</title>
+       <synopsis>
+         <function>def-enum</function> <replaceable>name fields &amp;key separator-string</replaceable>
+       </synopsis>
+      </refsynopsisdiv>
+      <refsect1>
+       <title>Arguments and Values</title>
+       <variablelist>
+         <varlistentry>
+           <term><parameter>name</parameter></term>
+           <listitem>
+             <para>A symbol that names the enumeration.
+             </para>
+           </listitem>
+         </varlistentry>
+         <varlistentry>
+           <term><parameter>fields</parameter></term>
+           <listitem>
+             <para>A list of field defintions. Each definition can be
+a symbol or a list of two elements. Symbols get assigned a value of the
+current counter which starts at <computeroutput>0</computeroutput> and
+increments by <computeroutput>1</computeroutput> for each subsequent symbol. It the field definition is a list, the first position is the symbol and the second
+position is the value to assign the the symbol. The current counter gets set
+to <computeroutput>1+</computeroutput> this value.
+             </para>
+           </listitem>
+         </varlistentry>
+         <varlistentry>
+           <term><parameter>separator-string</parameter></term>
+           <listitem>
+             <para>A string that governs the creation of constants. The
+default is <computeroutput>"#"</computeroutput>.</para>
+           </listitem>
+         </varlistentry>
+       </variablelist>
+      </refsect1>
+      <refsect1>
+       <title>Description</title>
+       <para>
+         Declares a &c; enumeration. It generates constants with integer values for the elements of the enumeration. The symbols for the these constant
+values are created by the <function>concatenation</function> of the
+enumeration name, separator-string, and field symbol. Also creates
+a foreign type with the name <parameter>name</parameter> of type
+<constant>:int</constant>.
+       </para>
+      </refsect1>
+      <refsect1>
+       <title>Examples</title>
+       <programlisting>
+(def-enum abc (:a :b :c)) 
+;; Creates constants abc#a (1), abc#b (2), abc#c (3) and defines
+;; the foreign type "abc" to be :int
+
+(def-enum efoo (:e1 (:e2 10) :e3) :separator-string "-")
+;; Creates constants efoo-e1 (1), efoo-e2 (10), efoo-e3 (11) and defines
+;; the foreign type efoo to be :int
+       </programlisting>
+      </refsect1>
+      <refsect1>
+       <title>Side Effects</title>
+       <para>Creates a :int foreign type, defines constants.</para>
+      </refsect1>
+      <refsect1>
+       <title>Affected by</title>
+       <para>None.</para>
+      </refsect1>
+      <refsect1>
+       <title>Exceptional Situations</title>
+       <para>None.</para>
+      </refsect1>
+    </refentry>
+
+
+      <refentry id="def-struct">
+       <refnamediv>
+         <refname>def-struct</refname>
+       <refpurpose>Defines a &c; structure.
+       </refpurpose>
+       <refclass>Macro</refclass>
+      </refnamediv>
+      <refsynopsisdiv>
+       <title>Syntax</title>
+       <synopsis>
+         <function>def-struct</function> <replaceable>name &amp;rest fields</replaceable>
+       </synopsis>
+      </refsynopsisdiv>
+      <refsect1>
+       <title>Arguments and Values</title>
+       <variablelist>
+         <varlistentry>
+           <term><parameter>name</parameter></term>
+           <listitem>
+             <para>A symbol that names the structure.
+             </para>
+           </listitem>
+         </varlistentry>
+         <varlistentry>
+           <term><parameter>fields</parameter></term>
+           <listitem>
+             <para>A variable number of field defintions. Each definition is a list consisting of a symbol naming the field followed by its foreign type.
+             </para>
+           </listitem>
+         </varlistentry>
+       </variablelist>
+      </refsect1>
+      <refsect1>
+       <title>Description</title>
+       <para>
+         Declares a structure. A special type is available as a slot
+in the field. It is a pointer that points to an instance of the parent
+structure. It's type is <constant>:pointer-self</constant>.
+
+       </para>
+      </refsect1>
+      <refsect1>
+       <title>Examples</title>
+       <programlisting>
+(def-struct foo (a :unsigned-int) 
+                (b (* :char)) 
+                (c (:array :int 10)) 
+                (next :pointer-self))
+       </programlisting>
+      </refsect1>
+      <refsect1>
+       <title>Side Effects</title>
+       <para>Creates a foreign type.</para>
+      </refsect1>
+      <refsect1>
+       <title>Affected by</title>
+       <para>None.</para>
+      </refsect1>
+      <refsect1>
+       <title>Exceptional Situations</title>
+       <para>None.</para>
+      </refsect1>
+    </refentry>
+
+
+    <refentry id="get-slot-value">
+      <refnamediv>
+       <refname>get-slot-value</refname>
+       <refpurpose>Retrieves a value from a slot of a structure.
+       </refpurpose>
+       <refclass>Macro</refclass>
+      </refnamediv>
+      <refsynopsisdiv>
+       <title>Syntax</title>
+       <synopsis>
+         <function>get-slot-value</function> <replaceable>obj type field</replaceable> => <returnvalue>value</returnvalue>
+       </synopsis>
+      </refsynopsisdiv>
+      <refsect1>
+       <title>Arguments and Values</title>
+       <variablelist>
+         <varlistentry>
+           <term><parameter>obj</parameter></term>
+           <listitem>
+             <para>A pointer to foreign structure.
+             </para>
+           </listitem>
+         </varlistentry>
+         <varlistentry>
+           <term><parameter>type</parameter></term>
+           <listitem>
+             <para>A name of the foreign structure.
+             </para>
+           </listitem>
+         </varlistentry>
+         <varlistentry>
+           <term><parameter>field</parameter></term>
+           <listitem>
+             <para>A name of the desired field in foreign structure.
+             </para>
+           </listitem>
+         </varlistentry>
+         <varlistentry>
+           <term><returnvalue>value</returnvalue></term>
+           <listitem>
+             <para>The value of the field in the structure.
+             </para>
+           </listitem>
+         </varlistentry>
+       </variablelist>
+      </refsect1>
+      <refsect1>
+       <title>Description</title>
+       <para>
+         Accesses a slot value from a structure.
+       </para>
+      </refsect1>
+      <refsect1>
+       <title>Examples</title>
+       <programlisting>
+(get-slot-value foo-ptr 'foo-structure 'field-name)
+       </programlisting>
+      </refsect1>
+      <refsect1>
+       <title>Side Effects</title>
+       <para>None.</para>
+      </refsect1>
+      <refsect1>
+       <title>Affected by</title>
+       <para>None.</para>
+      </refsect1>
+      <refsect1>
+       <title>Exceptional Situations</title>
+       <para>None.</para>
+      </refsect1>
+    </refentry>
+
+    <refentry id="get-slot-pointer">
+      <refnamediv>
+       <refname>get-slot-pointer</refname>
+       <refpurpose>Retrieves a pointer from a slot of a structure.
+       </refpurpose>
+       <refclass>Macro</refclass>
+      </refnamediv>
+      <refsynopsisdiv>
+       <title>Syntax</title>
+       <synopsis>
+         <function>get-slot-pointer</function> <replaceable>obj type field</replaceable> => <returnvalue>pointer</returnvalue>
+       </synopsis>
+      </refsynopsisdiv>
+      <refsect1>
+       <title>Arguments and Values</title>
+       <variablelist>
+         <varlistentry>
+           <term><parameter>obj</parameter></term>
+           <listitem>
+             <para>A pointer to foreign structure.
+             </para>
+           </listitem>
+         </varlistentry>
+         <varlistentry>
+           <term><parameter>type</parameter></term>
+           <listitem>
+             <para>A name of the foreign structure.
+             </para>
+           </listitem>
+         </varlistentry>
+         <varlistentry>
+           <term><parameter>field</parameter></term>
+           <listitem>
+             <para>A name of the desired field in foreign structure.
+             </para>
+           </listitem>
+         </varlistentry>
+         <varlistentry>
+           <term><returnvalue>pointer</returnvalue></term>
+           <listitem>
+             <para>The value of the field in the structure.
+             </para>
+           </listitem>
+         </varlistentry>
+       </variablelist>
+      </refsect1>
+      <refsect1>
+       <title>Description</title>
+       <para>
+         This is similar to <function>get-slot-value</function>. It
+         is used when the value of a slot is a pointer type.
+       </para>
+      </refsect1>
+      <refsect1>
+       <title>Examples</title>
+       <programlisting>
+(get-slot-pointer foo-ptr 'foo-structure 'my-char-ptr)
+       </programlisting>
+      </refsect1>
+      <refsect1>
+       <title>Side Effects</title>
+       <para>None.</para>
+      </refsect1>
+      <refsect1>
+       <title>Affected by</title>
+       <para>None.</para>
+      </refsect1>
+      <refsect1>
+       <title>Exceptional Situations</title>
+       <para>None.</para>
+      </refsect1>
+    </refentry>
+
+
+    <refentry id="def-array-pointer">
+      <refnamediv>
+       <refname>def-array-pointer</refname>
+       <refpurpose>Defines a pointer to a array of type.
+       </refpurpose>
+       <refclass>Macro</refclass>
+      </refnamediv>
+      <refsynopsisdiv>
+       <title>Syntax</title>
+       <synopsis>
+         <function>def-array-pointer</function> <replaceable>name type</replaceable>
+       </synopsis>
+      </refsynopsisdiv>
+      <refsect1>
+       <title>Arguments and Values</title>
+       <variablelist>
+         <varlistentry>
+           <term><parameter>name</parameter></term>
+           <listitem>
+             <para>A name of the new foreign type.
+             </para>
+           </listitem>
+         </varlistentry>
+         <varlistentry>
+           <term><parameter>type</parameter></term>
+           <listitem>
+             <para>The foreign type of the array elements.
+             </para>
+           </listitem>
+         </varlistentry>
+       </variablelist>
+      </refsect1>
+      <refsect1>
+       <title>Description</title>
+       <para>
+         Defines a type tat is a pointer to an array of type.
+       </para>
+      </refsect1>
+      <refsect1>
+       <title>Examples</title>
+       <programlisting>
+(def-array-pointer byte-array-pointer :unsigned-char)
+       </programlisting>
+      </refsect1>
+      <refsect1>
+       <title>Side Effects</title>
+       <para>Defines a new foreign type.</para>
+      </refsect1>
+      <refsect1>
+       <title>Affected by</title>
+       <para>None.</para>
+      </refsect1>
+      <refsect1>
+       <title>Exceptional Situations</title>
+       <para>None.</para>
+      </refsect1>
+    </refentry>
+
+
+    <refentry id="deref-array">
+      <refnamediv>
+       <refname>deref-array</refname>
+       <refpurpose>Deference an array.
+       </refpurpose>
+       <refclass>Macro</refclass>
+      </refnamediv>
+      <refsynopsisdiv>
+       <title>Syntax</title>
+       <synopsis>
+         <function>deref-array</function> <replaceable>array type positon</replaceable> => <returnvalue>value</returnvalue>
+       </synopsis>
+      </refsynopsisdiv>
+      <refsect1>
+       <title>Arguments and Values</title>
+       <variablelist>
+         <varlistentry>
+           <term><parameter>array</parameter></term>
+           <listitem>
+             <para>A foreign array.
+             </para>
+           </listitem>
+         </varlistentry>
+         <varlistentry>
+           <term><parameter>type</parameter></term>
+           <listitem>
+             <para>The foreign type of the array.
+             </para>
+           </listitem>
+         </varlistentry>
+         <varlistentry>
+           <term><parameter>position</parameter></term>
+           <listitem>
+             <para>An integer specifying the position to retrieve from
+the array.
+             </para>
+           </listitem>
+         </varlistentry>
+         <varlistentry>
+           <term><returnvalue>value</returnvalue></term>
+           <listitem>
+             <para>The value stored in the position of the array.
+             </para>
+           </listitem>
+         </varlistentry>
+       </variablelist>
+      </refsect1>
+      <refsect1>
+       <title>Description</title>
+       <para>
+         Dereferences (retrieves) the value of an array element.
+       </para>
+      </refsect1>
+      <refsect1>
+       <title>Examples</title>
+       <programlisting>
+(def-array-pointer ca :char)
+(let ((fs (convert-to-foreign-string "ab")))
+   (values (null-char-p (deref-array fs 'ca 0))
+           (null-char-p (deref-array fs 'ca 2))))
+=> &nil;
+   &t;
+       </programlisting>
+      </refsect1>
+      <refsect1>
+       <title>Notes</title>
+        <para>
+  The TYPE argument is ignored for CL implementations other than
+  AllegroCL. If you want to cast a pointer to another type use
+  WITH-CAST-POINTER together with DEREF-POINTER/DEREF-ARRAY.
+        </para>
+      </refsect1>
+      <refsect1>
+       <title>Side Effects</title>
+       <para>None.</para>
+      </refsect1>
+      <refsect1>
+       <title>Affected by</title>
+       <para>None.</para>
+      </refsect1>
+      <refsect1>
+       <title>Exceptional Situations</title>
+       <para>None.</para>
+      </refsect1>
+    </refentry>
+
+    <refentry id="def-union">
+      <refnamediv>
+       <refname>def-union</refname>
+       <refpurpose>Defines a foreign union type.
+       </refpurpose>
+       <refclass>Macro</refclass>
+      </refnamediv>
+      <refsynopsisdiv>
+       <title>Syntax</title>
+       <synopsis>
+         <function>def-union</function> <replaceable>name &amp;rest fields</replaceable>
+       </synopsis>
+      </refsynopsisdiv>
+      <refsect1>
+       <title>Arguments and Values</title>
+       <variablelist>
+         <varlistentry>
+           <term><parameter>name</parameter></term>
+           <listitem>
+             <para>A name of the new union type.
+             </para>
+           </listitem>
+         </varlistentry>
+         <varlistentry>
+           <term><parameter>fields</parameter></term>
+           <listitem>
+             <para>A list of fields of the union.
+             </para>
+           </listitem>
+         </varlistentry>
+       </variablelist>
+      </refsect1>
+      <refsect1>
+       <title>Description</title>
+       <para>
+         Defines a foreign union type.
+       </para>
+      </refsect1>
+      <refsect1>
+       <title>Examples</title>
+       <programlisting>
+(def-union test-union
+  (a-char :char)
+  (an-int :int))
+
+(let ((u (allocate-foreign-object 'test-union))
+  (setf (get-slot-value u 'test-union 'an-int) (+ 65 (* 66 256)))
+  (prog1 
+    (ensure-char-character (get-slot-value u 'test-union 'a-char))
+    (free-foreign-object u)))
+=> #\A
+       </programlisting>
+      </refsect1>
+      <refsect1>
+       <title>Side Effects</title>
+       <para>Defines a new foreign type.</para>
+      </refsect1>
+      <refsect1>
+       <title>Affected by</title>
+       <para>None.</para>
+      </refsect1>
+      <refsect1>
+       <title>Exceptional Situations</title>
+       <para>None.</para>
+      </refsect1>
+    </refentry>
+
+
+</reference>
+
+<reference>
+    <title>Objects</title>
+<partintro>
+<title>Overview</title>
+    <para>
+      Objects are entities that can allocated, referred to by pointers, and
+can be freed.
+    </para>
+</partintro>
+
+
+    <refentry id="allocate-foreign-object">
+      <refnamediv>
+       <refname>allocate-foreign-object</refname>
+       <refpurpose>Allocates an instance of a foreign object.
+       </refpurpose>
+       <refclass>Macro</refclass>
+      </refnamediv>
+      <refsynopsisdiv>
+       <title>Syntax</title>
+       <synopsis>
+         <function>allocate-foreign-object</function> <replaceable>type &amp;optional size</replaceable> => <returnvalue>ptr</returnvalue>
+       </synopsis>
+      </refsynopsisdiv>
+      <refsect1>
+       <title>Arguments and Values</title>
+       <variablelist>
+         <varlistentry>
+           <term><parameter>type</parameter></term>
+           <listitem>
+             <para>The type of foreign object to allocate. This parameter is evaluated.
+             </para>
+           </listitem>
+         </varlistentry>
+         <varlistentry>
+           <term><parameter>size</parameter></term>
+           <listitem>
+             <para>An optional size parameter that is evaluated. If specified, allocates and returns an
+array of <parameter>type</parameter> that is <parameter>size</parameter> members long. This parameter is evaluated.
+             </para>
+           </listitem>
+         </varlistentry>
+         <varlistentry>
+           <term><returnvalue>ptr</returnvalue></term>
+           <listitem>
+             <para>A pointer to the foreign object.
+             </para>
+           </listitem>
+         </varlistentry>
+       </variablelist>
+      </refsect1>
+      <refsect1>
+       <title>Description</title>
+       <para>
+         Allocates an instance of a foreign object. It returns a pointer to the object.
+       </para>
+      </refsect1>
+      <refsect1>
+       <title>Examples</title>
+       <programlisting>
+(def-struct ab (a :int) (b :double))
+(allocate-foreign-object 'ab)
+=> #&lt;ptr&gt;
+       </programlisting>
+      </refsect1>
+      <refsect1>
+       <title>Side Effects</title>
+       <para>None.</para>
+      </refsect1>
+      <refsect1>
+       <title>Affected by</title>
+       <para>None.</para>
+      </refsect1>
+      <refsect1>
+       <title>Exceptional Situations</title>
+       <para>None.</para>
+      </refsect1>
+    </refentry>
+
+
+    <refentry id="free-foreign-object">
+      <refnamediv>
+       <refname>free-foreign-object</refname>
+       <refpurpose>Frees memory that was allocated for a foreign boject.
+       </refpurpose>
+       <refclass>Macro</refclass>
+      </refnamediv>
+      <refsynopsisdiv>
+       <title>Syntax</title>
+       <synopsis>
+         <function>free-foreign-object</function> <replaceable>ptr</replaceable>
+       </synopsis>
+      </refsynopsisdiv>
+      <refsect1>
+       <title>Arguments and Values</title>
+       <variablelist>
+         <varlistentry>
+           <term><parameter>ptr</parameter></term>
+           <listitem>
+             <para>A pointer to the allocated foreign object to free.
+             </para>
+           </listitem>
+         </varlistentry>
+       </variablelist>
+      </refsect1>
+      <refsect1>
+       <title>Description</title>
+       <para>
+         Frees the memory used by the allocation of a foreign object.
+       </para>
+      </refsect1>
+      <refsect1>
+       <title>Side Effects</title>
+       <para>None.</para>
+      </refsect1>
+      <refsect1>
+       <title>Affected by</title>
+       <para>None.</para>
+      </refsect1>
+      <refsect1>
+       <title>Exceptional Situations</title>
+       <para>None.</para>
+      </refsect1>
+    </refentry>
+
+
+    <refentry id="with-foreign-object">
+      <refnamediv>
+       <refname>with-foreign-object</refname>
+       <refpurpose>Wraps the allocation of a foreign object around a body of code.
+       </refpurpose>
+       <refclass>Macro</refclass>
+      </refnamediv>
+      <refsynopsisdiv>
+       <title>Syntax</title>
+       <synopsis>
+         <function>with-foreign-object</function> <replaceable>(var type) &amp;body body</replaceable> => <returnvalue>form-return</returnvalue>
+       </synopsis>
+      </refsynopsisdiv>
+      <refsect1>
+       <title>Arguments and Values</title>
+       <variablelist>
+         <varlistentry>
+           <term><parameter>var</parameter></term>
+           <listitem>
+             <para>The variable name to bind.
+             </para>
+           </listitem>
+         </varlistentry>
+         <varlistentry>
+           <term><parameter>type</parameter></term>
+           <listitem>
+             <para>The type of foreign object to allocate. This parameter is evaluated.
+             </para>
+           </listitem>
+         </varlistentry>
+         <varlistentry>
+           <term><returnvalue>form-return</returnvalue></term>
+           <listitem>
+             <para>The result of evaluating the <parameter>body</parameter>.
+             </para>
+           </listitem>
+         </varlistentry>
+       </variablelist>
+      </refsect1>
+      <refsect1>
+       <title>Description</title>
+       <para>
+This function wraps the allocation, binding, and destruction of a foreign object.
+On &cmucl; and
+&lw; platforms the object is stack allocated for efficiency. Benchmarks show that &acl; performs
+much better with static allocation.
+       </para>
+      </refsect1>
+      <refsect1>
+       <title>Examples</title>
+       <programlisting>
+(defun gethostname2 ()
+  "Returns the hostname"
+  (uffi:with-foreign-object (name '(:array :unsigned-char 256))
+    (if (zerop (c-gethostname (uffi:char-array-to-pointer name) 256))
+       (uffi:convert-from-foreign-string name)
+       (error "gethostname() failed."))))
+       </programlisting>
+      </refsect1>
+      <refsect1>
+       <title>Side Effects</title>
+       <para>None.</para>
+      </refsect1>
+      <refsect1>
+       <title>Affected by</title>
+       <para>None.</para>
+      </refsect1>
+      <refsect1>
+       <title>Exceptional Situations</title>
+       <para>None.</para>
+      </refsect1>
+    </refentry>
+
+    <refentry id="size-of-foreign-type">
+      <refnamediv>
+       <refname>size-of-foreign-type</refname>
+       <refpurpose>Returns the number of data bytes used by a foreign object type.
+       </refpurpose>
+       <refclass>Macro</refclass>
+      </refnamediv>
+      <refsynopsisdiv>
+       <title>Syntax</title>
+       <synopsis>
+         <function>size-of-foreign-type</function> <replaceable>ftype</replaceable>
+       </synopsis>
+      </refsynopsisdiv>
+      <refsect1>
+       <title>Arguments and Values</title>
+       <variablelist>
+         <varlistentry>
+           <term><parameter>ftype</parameter></term>
+           <listitem>
+             <para>A foreign type specifier. This parameter is evaluated.
+             </para>
+           </listitem>
+         </varlistentry>
+       </variablelist>
+      </refsect1>
+      <refsect1>
+       <title>Description</title>
+       <para>
+         Returns the number of data bytes used by a foreign object type. This does not include any Lisp storage overhead.
+       </para>
+      </refsect1>
+      <refsect1>
+       <title>Examples</title>
+       <para>
+<programlisting>
+(size-of-foreign-object :unsigned-byte)
+=> 1
+(size-of-foreign-object 'my-100-byte-vector-type)
+=> 100
+</programlisting>
+        </para>
+      </refsect1>
+      <refsect1>
+       <title>Side Effects</title>
+       <para>None.</para>
+      </refsect1>      <refsect1>
+       <title>Affected by</title>
+       <para>None.</para>
+      </refsect1>
+      <refsect1>
+       <title>Exceptional Situations</title>
+       <para>None.</para>
+      </refsect1>
+    </refentry>
+
+    <refentry id="pointer-address">
+      <refnamediv>
+       <refname>pointer-address</refname>
+       <refpurpose>Returns the address of a pointer.
+       </refpurpose>
+       <refclass>Macro</refclass>
+      </refnamediv>
+      <refsynopsisdiv>
+       <title>Syntax</title>
+       <synopsis>
+         <function>pointer-address</function> <replaceable>ptr</replaceable> => <returnvalue>address</returnvalue>
+       </synopsis>
+      </refsynopsisdiv>
+      <refsect1>
+       <title>Arguments and Values</title>
+       <variablelist>
+         <varlistentry>
+           <term><parameter>ptr</parameter></term>
+           <listitem>
+             <para>A pointer to a foreign object.
+             </para>
+           </listitem>
+         </varlistentry>
+         <varlistentry>
+           <term><parameter>address</parameter></term>
+           <listitem>
+             <para>An integer representing the pointer's address.
+             </para>
+           </listitem>
+         </varlistentry>
+       </variablelist>
+      </refsect1>
+      <refsect1>
+       <title>Description</title>
+       <para>
+         Returns the address as an integer of a pointer.
+       </para>
+      </refsect1>
+      <refsect1>
+       <title>Side Effects</title>
+       <para>None.</para>
+      </refsect1>
+      <refsect1>
+       <title>Affected by</title>
+       <para>None.</para>
+      </refsect1>
+      <refsect1>
+       <title>Exceptional Situations</title>
+       <para>None.</para>
+      </refsect1>
+    </refentry>
+
+
+    <refentry id="deref-pointer">
+      <refnamediv>
+       <refname>deref-pointer</refname>
+       <refpurpose>Deferences a pointer.
+       </refpurpose>
+       <refclass>Macro</refclass>
+      </refnamediv>
+      <refsynopsisdiv>
+       <title>Syntax</title>
+       <synopsis>
+         <function>deref-pointer</function> <replaceable>ptr type</replaceable> => <returnvalue>value</returnvalue>
+       </synopsis>
+      </refsynopsisdiv>
+      <refsect1>
+       <title>Arguments and Values</title>
+       <variablelist>
+         <varlistentry>
+           <term><parameter>ptr</parameter></term>
+           <listitem>
+             <para>A pointer to a foreign object.
+             </para>
+           </listitem>
+         </varlistentry>
+         <varlistentry>
+           <term><parameter>type</parameter></term>
+           <listitem>
+             <para>A foreign type of the object being pointed to.
+             </para>
+           </listitem>
+         </varlistentry>
+         <varlistentry>
+           <term><returnvalue>value</returnvalue></term>
+           <listitem>
+             <para>The value of the object where the pointer points.
+             </para>
+           </listitem>
+         </varlistentry>
+       </variablelist>
+      </refsect1>
+      <refsect1>
+       <title>Description</title>
+       <para>
+         Returns the object to which a pointer points.
+       </para>
+      </refsect1>
+      <refsect1>
+       <title>Examples</title>
+       <para>
+<programlisting>
+(let ((intp (allocate-foreign-object :int)))
+  (setf (deref-pointer intp :int) 10)
+  (prog1
+    (deref-pointer intp :int)
+    (free-foreign-object intp)))
+=> 10
+</programlisting>
+       </para>
+      </refsect1>
+      <refsect1>
+       <title>Notes</title>
+        <para>
+  The TYPE argument is ignored for CL implementations other than
+  AllegroCL. If you want to cast a pointer to another type use
+  WITH-CAST-POINTER together with DEREF-POINTER/DEREF-ARRAY.
+        </para>
+      </refsect1>
+      <refsect1>
+       <title>Side Effects</title>
+       <para>None.</para>
+      </refsect1>
+      <refsect1>
+       <title>Affected by</title>
+       <para>None.</para>
+      </refsect1>
+      <refsect1>
+       <title>Exceptional Situations</title>
+       <para>None.</para>
+      </refsect1>
+    </refentry>
+
+    <refentry id="ensure-char-character">
+      <refnamediv>
+       <refname>ensure-char-character</refname>
+       <refpurpose>Ensures that a dereferenced <constant>:char</constant> pointer is
+a character.
+       </refpurpose>
+       <refclass>Macro</refclass>
+      </refnamediv>
+      <refsynopsisdiv>
+       <title>Syntax</title>
+       <synopsis>
+         <function>ensure-char-character</function> <replaceable>object</replaceable> => <returnvalue>char</returnvalue>
+       </synopsis>
+      </refsynopsisdiv>
+      <refsect1>
+       <title>Arguments and Values</title>
+       <variablelist>
+         <varlistentry>
+           <term><parameter>object</parameter></term>
+           <listitem>
+             <para>Either a character or a integer specifying a character code.
+             </para>
+           </listitem>
+         </varlistentry>
+         <varlistentry>
+           <term><returnvalue>char</returnvalue></term>
+           <listitem>
+             <para>A character.
+             </para>
+           </listitem>
+         </varlistentry>
+       </variablelist>
+      </refsect1>
+      <refsect1>
+       <title>Description</title>
+       <para>
+         Ensures that an objects obtained by dereferencing  
+<constant>:char</constant> and <constant>:unsigned-char</constant>
+pointers are a lisp character.
+       </para>
+      </refsect1>
+      <refsect1>
+       <title>Examples</title>
+       <para>
+<programlisting>
+(let ((fs (convert-to-foreign-string "a")))
+  (prog1 
+    (ensure-char-character (deref-pointer fs :char))
+    (free-foreign-object fs)))
+=> #\a
+</programlisting>
+       </para>
+      </refsect1>
+      <refsect1>
+       <title>Side Effects</title>
+       <para>None.</para>
+      </refsect1>
+      <refsect1>
+       <title>Affected by</title>
+       <para>None.</para>
+      </refsect1>
+      <refsect1>
+       <title>Exceptional Situations</title>
+       <para>Depending upon the implementation and what &uffi; expects, this
+macro may signal an error if the object is not a character or
+integer.</para>
+      </refsect1>
+    </refentry>
+
+    <refentry id="ensure-char-integer">
+      <refnamediv>
+       <refname>ensure-char-integer</refname>
+       <refpurpose>Ensures that a dereferenced <constant>:char</constant> pointer is
+an integer.
+       </refpurpose>
+       <refclass>Macro</refclass>
+      </refnamediv>
+      <refsynopsisdiv>
+       <title>Syntax</title>
+       <synopsis>
+         <function>ensure-char-integer</function> <replaceable>object</replaceable> => <returnvalue>int</returnvalue>
+       </synopsis>
+      </refsynopsisdiv>
+      <refsect1>
+       <title>Arguments and Values</title>
+       <variablelist>
+         <varlistentry>
+           <term><parameter>object</parameter></term>
+           <listitem>
+             <para>Either a character or a integer specifying a character code.
+             </para>
+           </listitem>
+         </varlistentry>
+         <varlistentry>
+           <term><returnvalue>int</returnvalue></term>
+           <listitem>
+             <para>An integer.
+             </para>
+           </listitem>
+         </varlistentry>
+       </variablelist>
+      </refsect1>
+      <refsect1>
+       <title>Description</title>
+       <para>
+         Ensures that an object obtained by dereferencing a 
+<constant>:char</constant> pointer is an integer.
+       </para>
+      </refsect1>
+      <refsect1>
+       <title>Examples</title>
+       <para>
+<programlisting>
+(let ((fs (convert-to-foreign-string "a")))
+  (prog1 
+    (ensure-char-integer (deref-pointer fs :char))
+    (free-foreign-object fs)))
+=> 96
+</programlisting>
+       </para>
+      </refsect1>
+      <refsect1>
+       <title>Side Effects</title>
+       <para>None.</para>
+      </refsect1>
+      <refsect1>
+       <title>Affected by</title>
+       <para>None.</para>
+      </refsect1>
+      <refsect1>
+       <title>Exceptional Situations</title>
+       <para>Depending upon the implementation and what &uffi; expects, this
+macro may signal an error if the object is not a character or
+integer.</para>
+      </refsect1>
+    </refentry>
+
+    <refentry id="make-null-pointer">
+      <refnamediv>
+       <refname>make-null-pointer</refname>
+       <refpurpose>Create a &null; pointer.
+       </refpurpose>
+       <refclass>Macro</refclass>
+      </refnamediv>
+      <refsynopsisdiv>
+       <title>Syntax</title>
+       <synopsis>
+         <function>make-null-pointer</function> <replaceable>type</replaceable> => <returnvalue>ptr</returnvalue>
+       </synopsis>
+      </refsynopsisdiv>
+      <refsect1>
+       <title>Arguments and Values</title>
+       <variablelist>
+         <varlistentry>
+           <term><parameter>type</parameter></term>
+           <listitem>
+             <para>A type of object to which the pointer refers.
+             </para>
+           </listitem>
+         </varlistentry>
+         <varlistentry>
+           <term><parameter>ptr</parameter></term>
+           <listitem>
+             <para>The &null; pointer of type <parameter>type</parameter>.
+             </para>
+           </listitem>
+         </varlistentry>
+       </variablelist>
+      </refsect1>
+      <refsect1>
+       <title>Description</title>
+       <para>
+         Creates a &null; pointer of a specified type.
+       </para>
+      </refsect1>
+      <refsect1>
+       <title>Side Effects</title>
+       <para>None.</para>
+      </refsect1>
+      <refsect1>
+       <title>Affected by</title>
+       <para>None.</para>
+      </refsect1>
+      <refsect1>
+       <title>Exceptional Situations</title>
+       <para>None.</para>
+      </refsect1>
+    </refentry>
+
+
+    <refentry id="null-pointer-p">
+      <refnamediv>
+       <refname>null-pointer-p</refname>
+       <refpurpose>Tests a pointer for &null; value.
+       </refpurpose>
+       <refclass>Macro</refclass>
+      </refnamediv>
+      <refsynopsisdiv>
+       <title>Syntax</title>
+       <synopsis>
+         <function>null-pointer-p</function> <replaceable>ptr</replaceable> => <returnvalue>is-null</returnvalue>
+       </synopsis>
+      </refsynopsisdiv>
+      <refsect1>
+       <title>Arguments and Values</title>
+       <variablelist>
+         <varlistentry>
+           <term><parameter>ptr</parameter></term>
+           <listitem>
+             <para>A foreign object pointer.
+             </para>
+           </listitem>
+         </varlistentry>
+         <varlistentry>
+           <term><returnvalue>is-null</returnvalue></term>
+           <listitem>
+             <para>The boolean flag.
+             </para>
+           </listitem>
+         </varlistentry>
+       </variablelist>
+      </refsect1>
+      <refsect1>
+       <title>Description</title>
+       <para>
+         A predicate testing if a pointer is has a &null; value.
+       </para>
+      </refsect1>
+      <refsect1>
+       <title>Side Effects</title>
+       <para>None.</para>
+      </refsect1>
+      <refsect1>
+       <title>Affected by</title>
+       <para>None.</para>
+      </refsect1>
+      <refsect1>
+       <title>Exceptional Situations</title>
+       <para>None.</para>
+      </refsect1>
+    </refentry>
+
+
+    <refentry id="null-cstring-pointer">
+      <refnamediv>
+       <refname>+null-cstring-pointer+</refname>
+       <refpurpose>A constant &null; cstring pointer.
+       </refpurpose>
+       <refclass>Constant</refclass>
+      </refnamediv>
+      <refsect1>
+       <title>Description</title>
+       <para>
+         A &null; cstring pointer. This can be used for testing
+if a cstring returned by a function is &null;.
+       </para>
+      </refsect1>
+    </refentry>
+
+    <refentry id="with-cast-pointer">
+      <refnamediv>
+       <refname>with-cast-pointer</refname>
+       <refpurpose>Wraps a body of code with a pointer cast to a new type.
+       </refpurpose>
+       <refclass>Macro</refclass>
+      </refnamediv>
+      <refsynopsisdiv>
+       <title>Syntax</title>
+       <synopsis>
+         <function>with-cast-pointer</function> (<replaceable>binding-name ptr type) &amp; body body</replaceable> => <returnvalue>value</returnvalue>
+       </synopsis>
+      </refsynopsisdiv>
+      <refsect1>
+       <title>Arguments and Values</title>
+       <variablelist>
+         <varlistentry>
+           <term><parameter>ptr</parameter></term>
+           <listitem>
+             <para>A pointer to a foreign object.
+             </para>
+           </listitem>
+         </varlistentry>
+         <varlistentry>
+           <term><parameter>type</parameter></term>
+           <listitem>
+             <para>A foreign type of the object being pointed to.
+             </para>
+           </listitem>
+         </varlistentry>
+         <varlistentry>
+           <term><returnvalue>value</returnvalue></term>
+           <listitem>
+             <para>The value of the object where the pointer points.
+             </para>
+           </listitem>
+         </varlistentry>
+       </variablelist>
+      </refsect1>
+      <refsect1>
+       <title>Description</title>
+       <para>
+  Executes BODY with POINTER cast to be a pointer to type TYPE. If
+  BINDING-NAME is provided the cast pointer will be bound to this
+  name during the execution of BODY. If BINDING-NAME is not provided
+  POINTER must be a name bound to the pointer which should be
+  cast. This name will be bound to the cast pointer during the
+  execution of BODY.
+
+  This is a no-op in AllegroCL but will wrap BODY in a LET form if
+  BINDING-NAME is provided.
+
+  This macro is meant to be used in conjunction with DEREF-POINTER or
+  DEREF-ARRAY. In Allegro CL the "cast" will actually take place in
+  DEREF-POINTER or DEREF-ARRAY.
+       </para>
+      </refsect1>
+      <refsect1>
+       <title>Examples</title>
+<programlisting>
+(with-foreign-object (size :int)
+   ;; FOO is a foreign function returning a :POINTER-VOID
+   (let ((memory (foo size)))
+      (when (mumble)
+         ;; at this point we know for some reason that MEMORY points
+         ;; to an array of unsigned bytes
+         (with-cast-pointer (memory :unsigned-byte)
+           (dotimes (i (deref-pointer size :int))
+            (do-something-with
+              (deref-array memory '(:array :unsigned-byte) i)))))))
+</programlisting>
+      </refsect1>
+      <refsect1>
+       <title>Side Effects</title>
+       <para>None.</para>
+      </refsect1>
+      <refsect1>
+       <title>Affected by</title>
+       <para>None.</para>
+      </refsect1>
+      <refsect1>
+       <title>Exceptional Situations</title>
+       <para>None.</para>
+      </refsect1>
+    </refentry>
+
+    <refentry id="def-foreign-var">
+      <refnamediv>
+       <refname>def-foreign-var</refname>
+       <refpurpose>
+Defines a symbol macro to access a variable in foreign code
+       </refpurpose>
+       <refclass>Macro</refclass>
+      </refnamediv>
+      <refsynopsisdiv>
+       <title>Syntax</title>
+       <synopsis>
+         <function>def-foreign-var</function> <replaceable>name type module</replaceable>
+       </synopsis>
+      </refsynopsisdiv>
+      <refsect1>
+       <title>Arguments and Values</title>
+       <variablelist>
+         <varlistentry>
+           <term><parameter>name</parameter></term>
+           <listitem>
+             <para>     
+A string or list specificying the symbol macro's name. If it is a
+     string, that names the foreign variable. A Lisp name is created
+     by translating #\_ to #\- and by converting to upper-case in
+     case-insensitive Lisp implementations. If it is a list, the first
+     item is a string specifying the foreign variable name and the
+     second it is a symbol stating the Lisp name.
+             </para>
+           </listitem>
+         </varlistentry>
+         <varlistentry>
+           <term><parameter>type</parameter></term>
+           <listitem>
+             <para>A foreign type of the foreign variable.
+             </para>
+           </listitem>
+         </varlistentry>
+         <varlistentry>
+           <term><returnvalue>module</returnvalue></term>
+           <listitem>
+             <para>
+     A string specifying the module (or library) the foreign variable
+     resides in. (Required by Lispworks)
+             </para>
+           </listitem>
+         </varlistentry>
+       </variablelist>
+      </refsect1>
+      <refsect1>
+       <title>Description</title>
+       <para>
+Defines a symbol macro which can be used to access (get and set) the
+value of a variable in foreign code.
+       </para>
+      </refsect1>
+      <refsect1>
+       <title>Examples</title>
+       <refsect2>
+       <title>C code</title>
+<programlisting>
+  int baz = 3;
+
+  typedef struct {
+    int x;
+    double y;
+  } foo_struct;
+
+  foo_struct the_struct = { 42, 3.2 };
+
+  int foo () {
+    return baz;
+  }
+</programlisting>
+</refsect2>
+<refsect2>
+<title>Lisp code</title>
+<programlisting>
+  (uffi:def-struct foo-struct
+    (x :int)
+    (y :double))
+
+  (uffi:def-function ("foo" foo)
+      ()
+    :returning :int
+    :module "foo")
+
+  (uffi:def-foreign-var ("baz" *baz*) :int "foo")
+  (uffi:def-foreign-var ("the_struct" *the-struct*) foo-struct "foo")
+
+
+*baz*
+  => 3
+
+(incf *baz*)
+  => 4
+
+(foo)
+  => 4
+</programlisting>
+</refsect2>
+      </refsect1>
+      <refsect1>
+       <title>Side Effects</title>
+       <para>None.</para>
+      </refsect1>
+      <refsect1>
+       <title>Affected by</title>
+       <para>None.</para>
+      </refsect1>
+      <refsect1>
+       <title>Exceptional Situations</title>
+       <para>None.</para>
+      </refsect1>
+    </refentry>
+
+</reference>
+
+    <reference>
+      <title>Strings</title>
+<partintro>
+<title>Overview</title>
+<para>
+
+         &uffi; has functions to two types of
+<varname>C</varname>-compatible
+         strings: <emphasis>cstring</emphasis> and
+<emphasis>foreign</emphasis> strings.
+
+cstrings are used <emphasis>only</emphasis> as parameters to and from
+functions. In some implementations a cstring is not a foreign type but
+rather the Lisp string itself. On other platforms a cstring is a newly
+allocated foreign vector for storing characters. The following is an
+example of using cstrings to both send and return a value.  
+</para>
+
+<programlisting>
+(uffi:def-function ("getenv" c-getenv) 
+    ((name :cstring))
+  :returning :cstring)
+
+(defun my-getenv (key)
+  "Returns an environment variable, or NIL if it does not exist"
+  (check-type key string)
+  (uffi:with-cstring (key-native key)
+    (uffi:convert-from-cstring (c-getenv key-native))))
+</programlisting>
+
+<para> In contrast, foreign strings are always a foreign vector of
+characters which have memory allocated. Thus, if you need to allocate
+memory to hold the return value of a string, you must use a foreign
+string and not a cstring.  The following is an example of using a foreign
+string for a return value.  </para>
+
+<programlisting>
+(uffi:def-function ("gethostname" c-gethostname)
+    ((name (* :unsigned-char))
+     (len :int))
+  :returning :int)
+
+(defun gethostname ()
+  "Returns the hostname"
+  (let* ((name (uffi:allocate-foreign-string 256))
+         (result-code (c-gethostname name 256))
+         (hostname (when (zerop result-code)
+                     (uffi:convert-from-foreign-string name))))
+    (uffi:free-foreign-object name)
+    (unless (zerop result-code)
+      (error "gethostname() failed."))))
+</programlisting>
+
+<para>  Foreign functions that return pointers to freshly allocated
+strings should in general not return cstrings, but foreign strings.
+(There is no portable way to release such cstrings from Lisp.)  The
+following is an example of handling such a function.  </para>
+
+<programlisting>
+(uffi:def-function ("readline" c-readline)
+    ((prompt :cstring))
+  :returning (* :char))
+
+(defun readline (prompt)
+  "Reads a string from console with line-editing."
+  (with-cstring (c-prompt prompt)
+      (let* ((c-str (c-readline c-prompt))
+             (str (convert-from-foreign-string c-str)))
+        (uffi:free-foreign-object c-str)
+        str)))
+</programlisting>
+
+</partintro>
+
+    <refentry id="convert-from-cstring">
+      <refnamediv>
+       <refname>convert-from-cstring</refname>
+       <refpurpose>Converts a cstring to a Lisp string.
+       </refpurpose>
+       <refclass>Macro</refclass>
+      </refnamediv>
+      <refsynopsisdiv>
+       <title>Syntax</title>
+       <synopsis>
+         <function>convert-from-cstring</function> <replaceable>cstring</replaceable> => <returnvalue>string</returnvalue>
+       </synopsis>
+      </refsynopsisdiv>
+      <refsect1>
+       <title>Arguments and Values</title>
+       <variablelist>
+         <varlistentry>
+           <term><parameter>cstring</parameter></term>
+           <listitem>
+             <para>A cstring.
+             </para>
+           </listitem>
+         </varlistentry>
+         <varlistentry>
+           <term><returnvalue>string</returnvalue></term>
+           <listitem>
+             <para>A Lisp string.
+             </para>
+           </listitem>
+         </varlistentry>
+       </variablelist>
+      </refsect1>
+      <refsect1>
+       <title>Description</title>
+       <para>
+         Converts a Lisp string to a <constant>cstring</constant>. This is
+most often used when processing the results of a foreign function
+that returns a cstring.
+       </para>
+      </refsect1>
+      <refsect1>
+       <title>Side Effects</title>
+       <para>None.</para>
+      </refsect1>
+      <refsect1>
+       <title>Affected by</title>
+       <para>None.</para>
+      </refsect1>
+      <refsect1>
+       <title>Exceptional Situations</title>
+       <para>None.</para>
+      </refsect1>
+    </refentry>
+
+
+    <refentry id="convert-to-cstring">
+      <refnamediv>
+       <refname>convert-to-cstring</refname>
+       <refpurpose>Converts a Lisp string to a cstring.
+       </refpurpose>
+       <refclass>Macro</refclass>
+      </refnamediv>
+      <refsynopsisdiv>
+       <title>Syntax</title>
+       <synopsis>
+         <function>convert-to-cstring</function> <replaceable>string</replaceable> => <returnvalue>cstring</returnvalue>
+       </synopsis>
+      </refsynopsisdiv>
+      <refsect1>
+       <title>Arguments and Values</title>
+       <variablelist>
+         <varlistentry>
+           <term><parameter>string</parameter></term>
+           <listitem>
+             <para>A Lisp string.
+             </para>
+           </listitem>
+         </varlistentry>
+         <varlistentry>
+           <term><returnvalue>cstring</returnvalue></term>
+           <listitem>
+             <para>A cstring.
+             </para>
+           </listitem>
+         </varlistentry>
+       </variablelist>
+      </refsect1>
+      <refsect1>
+       <title>Description</title>
+       <para>
+         Converts a Lisp string to a
+         <varname>cstring</varname>. The
+         <varname>cstring</varname> should be freed with
+         <function>free-cstring</function>.
+       </para>
+      </refsect1>
+      <refsect1>
+       <title>Side Effects</title>
+       <para>On some implementations, this function allocates memory.</para>
+      </refsect1>
+      <refsect1>
+       <title>Affected by</title>
+       <para>None.</para>
+      </refsect1>
+      <refsect1>
+       <title>Exceptional Situations</title>
+       <para>None.</para>
+      </refsect1>
+    </refentry>
+
+
+    <refentry id="free-cstring">
+      <refnamediv>
+       <refname>free-cstring</refname>
+       <refpurpose>Free memory used by cstring.
+       </refpurpose>
+       <refclass>Macro</refclass>
+      </refnamediv>
+      <refsynopsisdiv>
+       <title>Syntax</title>
+       <synopsis>
+         <function>free-cstring</function> <replaceable>cstring</replaceable>
+       </synopsis>
+      </refsynopsisdiv>
+      <refsect1>
+       <title>Arguments and Values</title>
+       <variablelist>
+         <varlistentry>
+           <term><parameter>cstring</parameter></term>
+           <listitem>
+             <para>A cstring.
+             </para>
+           </listitem>
+         </varlistentry>
+       </variablelist>
+      </refsect1>
+      <refsect1>
+       <title>Description</title>
+       <para>
+         Frees any memory possibly allocated by
+         <function>convert-to-cstring</function>. On some implementions, a cstring is just the Lisp string itself.
+       </para>
+      </refsect1>
+      <refsect1>
+       <title>Side Effects</title>
+       <para>None.</para>
+      </refsect1>
+      <refsect1>
+       <title>Affected by</title>
+       <para>None.</para>
+      </refsect1>
+      <refsect1>
+       <title>Exceptional Situations</title>
+       <para>None.</para>
+      </refsect1>
+    </refentry>
+
+
+    <refentry id="with-cstring">
+      <refnamediv>
+       <refname>with-cstring</refname>
+       <refpurpose>Binds a newly created cstring.
+       </refpurpose>
+       <refclass>Macro</refclass>
+      </refnamediv>
+      <refsynopsisdiv>
+       <title>Syntax</title>
+       <synopsis>
+         <function>with-cstring</function> <replaceable>(cstring string) {body}</replaceable>
+       </synopsis>
+      </refsynopsisdiv>
+      <refsect1>
+       <title>Arguments and Values</title>
+       <variablelist>
+         <varlistentry>
+           <term><parameter>cstring</parameter></term>
+           <listitem>
+             <para>A symbol naming the cstring to be created.
+             </para>
+           </listitem>
+         </varlistentry>
+         <varlistentry>
+           <term><parameter>string</parameter></term>
+           <listitem>
+             <para>A Lisp string that will be translated to a cstring.
+             </para>
+           </listitem>
+         </varlistentry>
+         <varlistentry>
+           <term><parameter>body</parameter></term>
+           <listitem>
+             <para>The body of where the cstring will be bound.
+             </para>
+           </listitem>
+         </varlistentry>
+       </variablelist>
+      </refsect1>
+      <refsect1>
+       <title>Description</title>
+       <para>
+         Binds a symbol to a cstring created from conversion of a string. Automatically frees the <varname>cstring</varname>.
+       </para>
+      </refsect1>
+      <refsect1>
+       <title>Examples</title>
+       <para>
+           <programlisting>
+(def-function ("getenv" c-getenv) 
+   ((name :cstring))
+   :returning :cstring)
+
+(defun getenv (key)
+  "Returns an environment variable, or NIL if it does not exist"
+  (check-type key string)
+  (with-cstring (key-cstring key)
+    (convert-from-cstring (c-getenv key-cstring))))
+           </programlisting>
+         </para>
+       </refsect1>
+      <refsect1>
+       <title>Side Effects</title>
+       <para>None.</para>
+      </refsect1>
+      <refsect1>
+       <title>Affected by</title>
+       <para>None.</para>
+      </refsect1>
+      <refsect1>
+       <title>Exceptional Situations</title>
+       <para>None.</para>
+      </refsect1>
+    </refentry>
+
+
+    <refentry id="convert-from-foreign-string">
+      <refnamediv>
+       <refname>convert-from-foreign-string</refname>
+       <refpurpose>Converts a foreign string into a Lisp string.
+       </refpurpose>
+       <refclass>Macro</refclass>
+      </refnamediv>
+      <refsynopsisdiv>
+       <title>Syntax</title>
+       <synopsis>
+         <function>convert-from-foreign-string</function> <replaceable>foreign-string &amp;key length null-terminated-p</replaceable> => <returnvalue>string</returnvalue>
+       </synopsis>
+      </refsynopsisdiv>
+      <refsect1>
+       <title>Arguments and Values</title>
+       <variablelist>
+         <varlistentry>
+           <term><parameter>foreign-string</parameter></term>
+           <listitem>
+             <para>A foreign string.
+             </para>
+           </listitem>
+         </varlistentry>
+         <varlistentry>
+           <term><parameter>length</parameter></term>
+           <listitem>
+             <para>The length of the foreign string to
+convert. The default is the length of the string until a &null;
+character is reached.
+             </para>
+           </listitem>
+         </varlistentry>
+         <varlistentry>
+           <term><parameter>null-terminated-p</parameter></term>
+           <listitem>
+             <para>A boolean flag with a default value of &t; When true,
+the string is converted until the first &null; character is reached.
+             </para>
+           </listitem>
+         </varlistentry>
+         <varlistentry>
+           <term><returnvalue>string</returnvalue></term>
+           <listitem>
+             <para>A Lisp string.
+             </para>
+           </listitem>
+         </varlistentry>
+       </variablelist>
+      </refsect1>
+      <refsect1>
+       <title>Description</title>
+       <para>
+         Returns a Lisp string from a foreign string. 
+Can translated ASCII and binary strings.
+       </para>
+      </refsect1>
+      <refsect1>
+       <title>Side Effects</title>
+       <para>None.</para>
+      </refsect1>
+      <refsect1>
+       <title>Affected by</title>
+       <para>None.</para>
+      </refsect1>
+      <refsect1>
+       <title>Exceptional Situations</title>
+       <para>None.</para>
+      </refsect1>
+    </refentry>
+
+
+    <refentry id="convert-to-foreign-string">
+      <refnamediv>
+       <refname>convert-to-foreign-string</refname>
+       <refpurpose>Converts a Lisp string to a foreign string.
+       </refpurpose>
+       <refclass>Macro</refclass>
+      </refnamediv>
+      <refsynopsisdiv>
+       <title>Syntax</title>
+       <synopsis>
+         <function>convert-to-foreign-string</function> <replaceable>string</replaceable> => <returnvalue>foreign-string</returnvalue>
+       </synopsis>
+      </refsynopsisdiv>
+      <refsect1>
+       <title>Arguments and Values</title>
+       <variablelist>
+         <varlistentry>
+           <term><parameter>string</parameter></term>
+           <listitem>
+             <para>A Lisp string.
+             </para>
+           </listitem>
+         </varlistentry>
+         <varlistentry>
+           <term><returnvalue>foreign-string</returnvalue></term>
+           <listitem>
+             <para>A foreign string.
+             </para>
+           </listitem>
+         </varlistentry>
+       </variablelist>
+      </refsect1>
+      <refsect1>
+       <title>Description</title>
+       <para>
+         Converts a Lisp string to a foreign string. Memory should be
+         freed with <function>free-foreign-object</function>.
+       </para>
+      </refsect1>
+      <refsect1>
+       <title>Side Effects</title>
+       <para>None.</para>
+      </refsect1>
+      <refsect1>
+       <title>Affected by</title>
+       <para>None.</para>
+      </refsect1>
+      <refsect1>
+       <title>Exceptional Situations</title>
+       <para>None.</para>
+      </refsect1>
+    </refentry>
+
+
+
+    <refentry id="allocate-foreign-string">
+      <refnamediv>
+       <refname>allocate-foreign-string</refname>
+       <refpurpose>Allocates space for a foreign string.
+       </refpurpose>
+       <refclass>Macro</refclass>
+      </refnamediv>
+      <refsynopsisdiv>
+       <title>Syntax</title>
+       <synopsis>
+         <function>allocate-foreign-string</function> <replaceable>size &amp;key unsigned</replaceable> => <returnvalue>foreign-string</returnvalue>
+       </synopsis>
+      </refsynopsisdiv>
+      <refsect1>
+       <title>Arguments and Values</title>
+       <variablelist>
+         <varlistentry>
+           <term><parameter>size</parameter></term>
+           <listitem>
+             <para>The size of the space to be allocated in bytes.
+             </para>
+           </listitem>
+         </varlistentry>
+         <varlistentry>
+           <term><parameter>unsigned</parameter></term>
+           <listitem>
+             <para>A boolean flag with a default value of &t;. When true,
+marks the pointer as an <constant>:unsigned-char</constant>.
+             </para>
+           </listitem>
+         </varlistentry>
+         <varlistentry>
+           <term><returnvalue>foreign-string</returnvalue></term>
+           <listitem>
+             <para>A foreign string which has undefined contents.
+             </para>
+           </listitem>
+         </varlistentry>
+       </variablelist>
+      </refsect1>
+      <refsect1>
+       <title>Description</title>
+       <para>
+         Allocates space for a foreign string. Memory should
+         be freed with <function>free-foreign-object</function>.
+       </para>
+      </refsect1>
+      <refsect1>
+       <title>Side Effects</title>
+       <para>None.</para>
+      </refsect1>
+      <refsect1>
+       <title>Affected by</title>
+       <para>None.</para>
+      </refsect1>
+      <refsect1>
+       <title>Exceptional Situations</title>
+       <para>None.</para>
+      </refsect1>
+    </refentry>
+
+  </reference>
+
+  <reference>
+      <title>Functions &amp; Libraries</title>
+
+      <refentry id="def-function">
+       <refnamediv>
+         <refname>def-function</refname>
+       <refpurpose>Declares a function. 
+       </refpurpose>
+       <refclass>Macro</refclass>
+      </refnamediv>
+      <refsynopsisdiv>
+       <title>Syntax</title>
+       <synopsis>
+         <function>def-function</function> <replaceable>name args &amp;key module returning</replaceable>
+       </synopsis>
+      </refsynopsisdiv>
+      <refsect1>
+       <title>Arguments and Values</title>
+       <variablelist>
+         <varlistentry>
+           <term><parameter>name</parameter></term>
+           <listitem>
+             <para>A string or list specificying the function name. If it is a string, that names the foreign function. A Lisp name is created by translating #\_ to #\- and by converting to upper-case in case-insensitive Lisp implementations. If it is a list, the first item is a string specifying the foreign function name and the second it is a symbol stating the Lisp name.
+             </para>
+           </listitem>
+         </varlistentry>
+         <varlistentry>
+           <term><parameter>args</parameter></term>
+           <listitem>
+             <para>A list of argument declarations. If &nil;, indicates that the function does not take any arguments.
+             </para>
+           </listitem>
+         </varlistentry>
+         <varlistentry>
+           <term><parameter>module</parameter></term>
+           <listitem>
+             <para>A string specifying which module (or library) that the foreign function resides. (Required by Lispworks)</para>
+           </listitem>
+         </varlistentry>
+         <varlistentry>
+           <term><returnvalue>returning</returnvalue></term>
+           <listitem>
+             <para>A declaration specifying the result type of the
+foreign function. If <constant>:void</constant> indicates module does not return any value.
+             </para>
+           </listitem>
+         </varlistentry>
+       </variablelist>
+      </refsect1>
+      <refsect1>
+       <title>Description</title>
+       <para>Declares a foreign function.
+       </para>
+      </refsect1>
+      <refsect1>
+       <title>Examples</title>
+       <programlisting>
+(def-function "gethostname" 
+  ((name (* :unsigned-char))
+   (len :int))
+  :returning :int)
+       </programlisting>
+      </refsect1>
+      <refsect1>
+       <title>Side Effects</title>
+       <para>None.</para>
+      </refsect1>
+      <refsect1>
+       <title>Affected by</title>
+       <para>None.</para>
+      </refsect1>
+      <refsect1>
+       <title>Exceptional Situations</title>
+       <para>None.</para>
+      </refsect1>
+    </refentry>
+
+      <refentry id="load-foreign-library">
+       <refnamediv>
+         <refname>load-foreign-library</refname>
+       <refpurpose>Loads a foreign library. 
+       </refpurpose>
+       <refclass>Function</refclass>
+      </refnamediv>
+      <refsect1>
+       <title>Syntax</title>
+<synopsis>
+         <function>load-foreign-library</function> <replaceable>filename &amp;key module supporting-libraries force-load</replaceable> => <returnvalue>success</returnvalue>
+</synopsis>
+      </refsect1>
+      <refsect1>
+       <title>Arguments and Values</title>
+       <variablelist>
+         <varlistentry>
+           <term><parameter>filename</parameter></term>
+           <listitem>
+             <para>A string or pathname specifying the library location
+in the filesystem. At least one implementation (&lw;) can not
+accept a logical pathname.
+             </para>
+           </listitem>
+         </varlistentry>
+         <varlistentry>
+           <term><parameter>module</parameter></term>
+           <listitem>
+             <para>A string designating the name of the module to apply
+to functions in this library. (Required for Lispworks)
+             </para>
+           </listitem>
+         </varlistentry>
+         <varlistentry>
+           <term><parameter>supporting-libraries</parameter></term>
+           <listitem>
+             <para>A list of strings naming the libraries required to
+link the foreign library. (Required by CMUCL)
+             </para>
+           </listitem>
+         </varlistentry>
+         <varlistentry>
+           <term><parameter>force-load</parameter></term>
+           <listitem>
+             <para>Forces the loading of the library if it has been previously loaded. 
+             </para>
+           </listitem>
+         </varlistentry>
+         <varlistentry>
+           <term><returnvalue>success</returnvalue></term>
+           <listitem>
+             <para>A boolean flag, &t; if the library was able to be
+loaded successfully or if the library has been previously loaded,
+otherwise &nil;.
+             </para>
+           </listitem>
+         </varlistentry>
+       </variablelist>
+      </refsect1>
+      <refsect1>
+       <title>Description</title>
+       <para>Loads a foreign library. Applies a module name to functions
+within the library. Ensures that a library is only loaded once during
+a session. A library can be reloaded by using the <symbol>:force-load</symbol> key.
+       </para>
+      </refsect1>
+      <refsect1>
+       <title>Examples</title>
+       <programlisting>
+  (load-foreign-library #p"/usr/lib/libmysqlclient.so" 
+                        :module "mysql" 
+                        :supporting-libraries '("c"))
+    => T
+       </programlisting>
+      </refsect1>
+      <refsect1>
+       <title>Side Effects</title>
+       <para>Loads the foreign code into the Lisp system.
+       </para>
+      </refsect1>
+      <refsect1>
+       <title>Affected by</title>
+       <para>Ability to load the file.</para>
+      </refsect1>
+      <refsect1>
+       <title>Exceptional Situations</title>
+       <para>None.</para>
+      </refsect1>
+    </refentry>
+
+      <refentry id="find-foreign-library">
+       <refnamediv>
+         <refname>find-foreign-library</refname>
+       <refpurpose>Finds a foreign library file.
+       </refpurpose>
+       <refclass>Function</refclass>
+      </refnamediv>
+      <refsect1>
+       <title>Syntax</title>
+<synopsis>
+         <function>find-foreign-library</function> <replaceable>names directories &amp; drive-letters types</replaceable> => <returnvalue>path</returnvalue>
+</synopsis>
+      </refsect1>
+      <refsect1>
+       <title>Arguments and Values</title>
+       <variablelist>
+         <varlistentry>
+           <term><parameter>names</parameter></term>
+           <listitem>
+             <para>A string or list of strings containing the base name of the library file.
+             </para>
+           </listitem>
+         </varlistentry>
+         <varlistentry>
+           <term><parameter>directories</parameter></term>
+           <listitem>
+             <para>A string or list of strings containing the directory the library file.
+             </para>
+           </listitem>
+         </varlistentry>
+         <varlistentry>
+           <term><parameter>drive-letters</parameter></term>
+           <listitem>
+             <para>A string or list of strings containing the drive letters for the library file.
+             </para>
+           </listitem>
+         </varlistentry>
+         <varlistentry>
+           <term><parameter>types</parameter></term>
+           <listitem>
+             <para>A string or list of strings containing the file type of the library file. Default
+is &nil;. If &nil;, will use a default type based on the currently running implementation.
+             </para>
+           </listitem>
+         </varlistentry>
+         <varlistentry>
+           <term><returnvalue>path</returnvalue></term>
+           <listitem>
+             <para>A path containing the path found, or &nil; if the library file was not found.
+             </para>
+           </listitem>
+         </varlistentry>
+       </variablelist>
+      </refsect1>
+      <refsect1>
+       <title>Description</title>
+       <para>Finds a foreign library by searching through a number of possible locations. Returns
+the path of the first found file.
+       </para>
+      </refsect1>
+      <refsect1>
+       <title>Examples</title>
+       <programlisting>
+(find-foreign-library '("libmysqlclient" "libmysql")
+    '("/opt/mysql/lib/mysql/" "/usr/local/lib/" "/usr/lib/" "/mysql/lib/opt/")
+    :types '("so" "dll")
+    :drive-letters '("C" "D" "E"))
+=> #P"D:\\mysql\\lib\\opt\\libmysql.dll"
+       </programlisting>
+      </refsect1>
+      <refsect1>
+       <title>Side Effects</title>
+       <para>None.
+       </para>
+      </refsect1>
+      <refsect1>
+       <title>Affected by</title>
+       <para>None.</para>
+      </refsect1>
+      <refsect1>
+       <title>Exceptional Situations</title>
+       <para>None.</para>
+      </refsect1>
+    </refentry>
+
+</reference>
+
+
index 569dc3e1464eb3f72582638ebb96eab5e2f5fde0..7ffcc06db4c0b09d3f4afa7b8723b102583a9571 100644 (file)
@@ -1,6 +1,6 @@
-<?xml version='1.0'?>
+<?xml version='1.0' ?>   <!-- Mode: Docbook --> 
 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
-               "docbook/dtd/xml/4.2/docbookx.dtd" [
+               "file:///usr/share/sgml/docbook/dtd/xml/4.2/docbookx.dtd" [
 <!ENTITY uffi "<application><emphasis>UFFI</emphasis></application>">
 <!ENTITY ffi "<acronym>FFI</acronym>">
 <!ENTITY cmucl "<application>CMUCL</application>">
 <!ENTITY c "<computeroutput>C</computeroutput>">
 <!ENTITY defsystem "<application>defsystem</application>">
 <!ENTITY asdf "<application>ASDF</application>">
-<!ENTITY bookinfo SYSTEM "bookinfo.sgml">
-<!ENTITY preface SYSTEM "preface.sgml">
-<!ENTITY intro SYSTEM "intro.sgml">
-<!ENTITY notes SYSTEM "notes.sgml">
-<!ENTITY ref SYSTEM "ref.sgml">
-<!ENTITY appendix SYSTEM "appendix.sgml">
-<!ENTITY glossary SYSTEM "glossary.sgml">
+<!ENTITY bookinfo SYSTEM "bookinfo.xml">
+<!ENTITY preface SYSTEM "preface.xml">
+<!ENTITY intro SYSTEM "intro.xml">
+<!ENTITY notes SYSTEM "notes.xml">
+<!ENTITY ref SYSTEM "ref.xml">
+<!ENTITY appendix SYSTEM "appendix.xml">
+<!ENTITY glossary SYSTEM "glossary.xml">
 ]>
 
-<book>
-
-  <bookinfo>
-    <title>&uffi; Reference Guide</title>
-    <author>
-      <firstname>Kevin</firstname>
-      <othername>M.</othername>
-      <surname>Rosenberg</surname>
-    <affiliation>
-       <orgname>Heart Hospital of New Mexico</orgname>
-       <address>
-       <email>kevin@rosenberg.net</email>
-        <street>504 Elm Street N.E.</street>
-        <city>Albuquerque</city>
-        <state>New Mexico</state>
-        <postcode>87102</postcode>
-        </address>
-      </affiliation>
-    </author>
-      
-    <printhistory>
-      <simpara>$Id: bookinfo.sgml 7990 2003-10-12 21:26:56Z kevin $</simpara>
-      <simpara>File $Date: 2003-10-12 15:26:56 -0600 (Sun, 12 Oct 2003) $</simpara>
-    </printhistory>
-    <copyright>
-      <year>2002-2003</year>
-      <holder>Kevin M. Rosenberg</holder>
-    </copyright>
-    <legalnotice>
-      <itemizedlist>
-       <listitem>
-         <para>The &uffi; package was designed and
-           written by Kevin M. Rosenberg.
-         </para>
-       </listitem>
-<listitem>
-<para>
-      Permission is granted to copy, distribute and/or modify this document
-      under the terms of the GNU Free Documentation License, Version 1.1
-      or any later version published by the Free Software Foundation;
-      with no Invariant Sections, with the no
-      Front-Cover Texts, and with no Back-Cover Texts.
-      A copy of the license is included in the &uffi; distribution.
-</para>
-</listitem>
-       <listitem>
-         <para><application>Allegro CL</application>&reg; is a registered
-           trademark of Franz Inc.
-         </para>
-       </listitem>
-       <listitem>
-         <para><application>Lispworks</application>&reg; is a registered
-           trademark of Xanalys Inc.
-         </para>
-       </listitem>
-       <listitem>
-         <para><application>Microsoft
-           Windows</application>&reg; is a registered trademark of
-           Microsoft Inc.
-         </para>
-       </listitem>
-       <listitem>
-         <para>Other brand or
-           product names are the registered trademarks or trademarks of
-           their respective holders.
-         </para>
-       </listitem>
-      </itemizedlist>
-    </legalnotice>
-  </bookinfo>
-
-<preface>
-  <title>Preface</title>
-  <para>This reference guide describes the usage and features
-    of &uffi;.  The first 
-    chapter provides an overview to the design of &uffi;.
-    Following that chapter is the reference section for all user
-    accessible functions of &uffi;. The appendix covers the
-    installation and implementation-specifc features of &uffi;.
-  </para>
-</preface>
-
-
-<chapter>
-  <title>Introduction</title>
-  <sect1>
-    <title>Purpose</title>
-    <para> This reference guide describes
-      &uffi;, a package that provides a cross-implementation
-      interface from Common Lisp to C-language compatible libraries.
-    </para>
-  </sect1>
-
-  <sect1>
-    <title>Background
-    </title>
-    <para>
-      Every Common Lisp implementation has
-      a method for interfacing to C-language compatible
-      libraries. These methods are often termed a 
-      <emphasis>Foreign Function Library Interface</emphasis>
-      (&ffi;). Unfortunately, these methods vary widely
-      amongst
-      implementations, thus preventing the writing of a portable FFI to a 
-particular C-library. 
-    </para>
-    <para>
-      &uffi; gathers a common subset of functionality between Common Lisp
-      implementations. &uffi; wraps this common subset of functionality with
-      it's own syntax and provides macro translation of uffi functions into
-      the specific syntax of supported Common Lisp implementations.
-    </para>
-    <para>
-      Developers who use &uffi; to interface with C libraries will
-      automatically have their code function in each of uffi's supported
-      implementations.
-    </para>
-  </sect1>
-
-  <sect1>
-    <title>Supported Implementations</title> 
-    <para>The primary tested and supported platforms for &uffi; are: 
-    </para>
-    <itemizedlist mark="opencircle">
-      <listitem><para>&acl; v6.2 on Debian GNU/Linux
-FreeBSD 4.5, Solaris v2.8, and Microsoft Windows XP.</para></listitem>
-      <listitem><para>&lw; v4.2 on Debian GNU/Linux and Microsoft Windows XP.</para></listitem>
-      <listitem><para>&cmucl; 18d on Debian GNU/Linux, FreeBSD 4.5, and Solaris 2.8</para></listitem>
-      <listitem><para>&sbcl; 0.7.8 on Debian GNU/Linux</para></listitem>
-      <listitem><para>&scl; 1.1.1 on Debian GNU/Linux</para></listitem>
-      <listitem><para>&openmcl; 0.13 on Debian GNU/Linux for PowerPC</para></listitem>
-    </itemizedlist>
-    <para>Beta code is included with &uffi; for
-    </para>
-    <itemizedlist mark="opencircle">
-      <listitem><para>&openmcl; and &mcl; with MacOSX</para></listitem>
-    </itemizedlist>
-  </sect1>
-
-    <sect1>
-      <title>Design</title>
-      <sect2>
-       <title>Overview</title>
-       <para>
-         &uffi; was designed as a cross-implementation 
-         compatible <emphasis>Foreign Function Interface</emphasis>.
-         Necessarily,
-         only a common subset of functionality can be
-         provided. Likewise, not every optimization for that a specific
-         implementation provides can be supported. Wherever possible,
-         though, implementation-specific optimizations are invoked.
-       </para> 
-      </sect2>
-
-      <sect2>
-       <title>Priorities</title>
-       <para>
-         The design of &uffi; is dictated by the order of these priorities:
-       </para>
-       <itemizedlist>
-         <listitem>
-           <para>
-             Code using &uffi; must operate correctly on all
-             supported implementations.
-           </para>
-         </listitem>
-         <listitem>
-           <para>
-             Take advantage of implementation-specific optimizations. Ideally, 
-             there will not a situation where an implementation-specific
-             &ffi; will be chosen due to lack of optimizations in &uffi;.
-           </para>
-         </listitem>
-         <listitem>
-           <para>Provide a simple interface to developers using
-&uffi;.  This priority is quite a bit lower than the above priorities.
-This lower priority is manifest by programmers having to pass types in
-pointer and array dereferencing, needing to use
-<constant>cstring</constant> wrapper functions, and the use of
-ensure-char-character and ensure-char-integer functions. My hope is
-that the developer inconvenience will be outweighed by the generation
-of optimized code that is cross-implementation compatible.
-           </para>
-         </listitem>
-       </itemizedlist>
-      </sect2>
-    </sect1>
-
-</chapter>
-
-
-<chapter>
-  <title>Programming Notes</title>
-
-  <sect1>
-    <title>Implementation Specific Notes</title> 
-    <para>
-    </para>
-      <sect2>
-       <title>&acl;</title>
-       <para>
-       </para>
-      </sect2>
-      <sect2>
-       <title>&lw;</title>
-       <para>
-       </para>
-      </sect2>
-      <sect2>
-       <title>&cmucl;</title>
-       <para>
-       </para>
-      </sect2>
-  </sect1>
-
-  <sect1>
-    <title>Foreign Object Representation and Access</title>
-    <para> There are two main approaches used to represent foreign
-    objects: an integer that represents an address in memory, and a
-    object that also includes run-time typing. The advantage of
-    run-time typing is the system can dereference pointers and perform
-    array access without those functions requiring a type at the cost
-    of additional overhead to generate and store the run-time
-    typing. The advantage of integer representation, at least for
-    &acl;, is that the compiler can generate inline code to
-    dereference pointers. Further, the overhead of the run-time type
-    information is eliminated. The disadvantage is the program must
-    then supply
-    the type to the functions to dereference objects and array.
-    </para>
-  </sect1>
-
-  <sect1>
-    <title>Optimizing Code Using UFFI</title>
-    <sect2>
-      <title>Background</title>
-      <para> 
-       Two implementions have different techniques to optimize
-       (open-code) foreign objects. &acl; can open-code foreign
-       object
-       access if pointers are integers and the type of object is
-    specified in the access function.  Thus, &uffi; represents objects
-    in &acl; as integers which don't have type information.
-    </para> <para> 
-      &cmucl; works best when keeping objects as typed
-    objects. However, it's compiler can open-code object access when
-    the object type is specified in <function>declare</function>
-    commands and in <varname>:type</varname> specifiers in
-    <function>defstruct</function> and <function>defclass</function>.
-    </para> <para> &lw;, in converse to &acl; and &cmucl; does not do
-    any open coding of object access. &lw;, by default, maintains
-    objects with run-time typing.  </para>
-    </sect2>
-    <sect2>
-      <title>Cross-Implementation Optimization</title>
-      <para>
-       To fully optimize across platforms, both explicit type
-       information must be passed to dereferencing of pointers and
-       arrays. Though this optimization only helps with &acl;, &uffi;
-       is designed to require this type information be passed the
-       dereference functions. Second, declarations of type should be
-       made in functions, structures, and classes where foreign
-       objects will be help. This will optimize access for &lw;
-      </para>
-      <para>
-       Here is an example that should both methods being used for
-       maximum cross-implementation optimization:
-       <programlisting>
-(uffi:def-type the-struct-type-def the-struct-type)
-(let ((a-foreign-struct (allocate-foreign-object 'the-struct-type)))
-  (declare 'the-struct-type-def a-foreign-struct)
-  (get-slot-value a-foreign-struct 'the-struct-type 'field-name))
-       </programlisting>
-      </para>
-    </sect2>
-  </sect1>
-
-</chapter>
-
-  
-<reference>
-  <title>Declarations</title>
-
-  <partintro>
-    <sect1>
-      <title>Overview</title>
-      <para>Declarations are used to give the compiler optimizing
-       information about foreign types. Currently, only &cmucl;
-       supports declarations. On &acl; and &lw;, these expressions 
-       declare the type generically as &t;
-      </para>
-    </sect1>
-  </partintro>
-
-      <refentry id="def-type">
-       <refnamediv>
-         <refname>def-type</refname>
-       <refpurpose>Defines a Common Lisp type. 
-       </refpurpose>
-       <refclass>Macro</refclass>
-      </refnamediv>
-      <refsynopsisdiv>
-       <title>Syntax</title>
-       <synopsis>
-         <function>def-type</function> <replaceable>name type</replaceable>
-       </synopsis>
-      </refsynopsisdiv>
-      <refsect1>
-       <title>Arguments and Values</title>
-       <variablelist>
-         <varlistentry>
-           <term><parameter>name</parameter></term>
-           <listitem>
-             <para>A symbol naming the type</para>
-           </listitem>
-         </varlistentry>
-         <varlistentry>
-           <term><parameter>type</parameter></term>
-           <listitem>
-             <para>A form that is evaluated that specifies the &uffi; type.
-             </para>
-           </listitem>
-         </varlistentry>
-       </variablelist>
-      </refsect1>
-      <refsect1>
-       <title>Description</title>
-       <para>Defines a Common Lisp type based on a &uffi; type.
-       </para>
-      </refsect1>
-      <refsect1>
-       <title>Examples</title>
-       <programlisting>
-(def-type char-ptr '(* :char))
-...
-(defun foo (ptr)
-  (declare (type char-ptr ptr))
-  ...
-       </programlisting>
-      </refsect1>
-      <refsect1>
-       <title>Side Effects</title>
-       <para>Defines a new &cl; type.</para>
-      </refsect1>
-      <refsect1>
-       <title>Affected by</title>
-       <para>None.</para>
-      </refsect1>
-      <refsect1>
-       <title>Exceptional Situations</title>
-       <para>None.</para>
-      </refsect1>
-    </refentry>
-  </reference>
-
-
-  <reference>
-    <title>Primitive Types</title>
-    <partintro>
-      <title>Overview</title>
-       <para>
-         Primitive types have a single value, these include
-         characters, numbers, and pointers. They are all symbols in
-         the keyword package.
-       </para>
-       <itemizedlist>
-         <listitem>
-           <para><constant>:char</constant> - Signed 8-bits. A
-dereferenced :char pointer returns an character.</para>
-         </listitem>
-         <listitem>
-           <para><constant>:unsigned-char</constant> - Unsigned 8-bits. A dereferenced :unsigned-char
-pointer returns an character.</para>
-         </listitem>
-         <listitem>
-           <para><constant>:byte</constant> - Signed 8-bits. A
-dereferenced :byte pointer returns an integer.</para>
-          </listitem>
-         <listitem>
-           <para><constant>:unsigned-byte</constant> - Unsigned 8-bits. A
-dereferenced :unsigned-byte pointer returns an integer.</para>
-         </listitem>
-         <listitem>
-           <para><constant>:short</constant> - Signed 16-bits.</para>
-         </listitem>
-         <listitem>
-           <para><constant>:unsigned-short</constant> - Unsigned 16-bits.</para>
-         </listitem>
-         <listitem>
-           <para><constant>:int</constant> - Signed 32-bits.</para>
-         </listitem>
-         <listitem>
-           <para><constant>:unsigned-int</constant> - Unsigned 32-bits.</para>
-         </listitem>
-         <listitem>
-           <para><constant>:long</constant> - Signed 32 or 64 bits, depending upon the platform.</para>
-         </listitem>
-         <listitem>
-           <para><constant>:unsigned-long</constant> - Unsigned 32 or 64 bits, depending upon the platform.</para>
-         </listitem>
-         <listitem>
-           <para><constant>:float</constant> - 32-bit floating point.</para>
-         </listitem>
-         <listitem>
-           <para><constant>:double</constant> - 64-bit floating point.</para>
-         </listitem>
-         <listitem>
-           <para><constant>:cstring</constant> - 
-A &null; terminated string used for passing and returning characters strings with a &c; function.
-           </para>
-         </listitem>
-         <listitem>
-           <para><constant>:void</constant> - 
-The absence of a value. Used to indicate that a function does not return a value.</para>
-         </listitem>
-         <listitem>
-           <para><constant>:pointer-void</constant> - 
-Points to a generic object.</para>
-         </listitem>
-         <listitem>
-           <para><constant>*</constant> - Used to declare a pointer to an object</para>
-         </listitem>
-       </itemizedlist>
-      </partintro>
-
-      <refentry id="def-constant">
-       <refnamediv>
-         <refname>def-constant</refname>
-       <refpurpose>Binds a symbol to a constant. 
-       </refpurpose>
-       <refclass>Macro</refclass>
-      </refnamediv>
-      <refsynopsisdiv>
-       <title>Syntax</title>
-       <synopsis>
-         <function>def-constant</function> <replaceable>name value &amp;key export</replaceable>
-       </synopsis>
-      </refsynopsisdiv>
-      <refsect1>
-       <title>Arguments and Values</title>
-       <variablelist>
-         <varlistentry>
-           <term><parameter>name</parameter></term>
-           <listitem>
-             <para>A symbol that will be bound to the value.
-             </para>
-           </listitem>
-         </varlistentry>
-         <varlistentry>
-           <term><parameter>value</parameter></term>
-           <listitem>
-             <para>An evaluated form that is bound the the name.
-             </para>
-           </listitem>
-         </varlistentry>
-         <varlistentry>
-           <term><parameter>export</parameter></term>
-           <listitem>
-             <para>When &t;, the name is exported from the current package. The default is &nil;</para>
-           </listitem>
-         </varlistentry>
-       </variablelist>
-      </refsect1>
-      <refsect1>
-       <title>Description</title>
-       <para>
-         This is a thin wrapper around
-         <function>defconstant</function>. It evaluates at
-           compile-time and optionally exports the symbol from the package.
-       </para>
-      </refsect1>
-      <refsect1>
-       <title>Examples</title>
-       <programlisting>
-(def-constant pi2 (* 2 pi))
-(def-constant exported-pi2 (* 2 pi) :export t)
-       </programlisting>
-      </refsect1>
-      <refsect1>
-       <title>Side Effects</title>
-       <para>Creates a new special variable..</para>
-      </refsect1>
-      <refsect1>
-       <title>Affected by</title>
-       <para>None.</para>
-      </refsect1>
-      <refsect1>
-       <title>Exceptional Situations</title>
-       <para>None.</para>
-      </refsect1>
-    </refentry>
-
-    <refentry id="def-foreign-type">
-       <refnamediv>
-         <refname>def-foreign-type</refname>
-       <refpurpose>Defines a new foreign type. 
-       </refpurpose>
-       <refclass>Macro</refclass>
-      </refnamediv>
-      <refsect1>
-       <title>Syntax</title>
-<synopsis>
-         <function>def-foreign-type</function> <replaceable>name type</replaceable>
-</synopsis>
-      </refsect1>
-      <refsect1>
-       <title>Arguments and Values</title>
-       <variablelist>
-         <varlistentry>
-           <term><parameter>name</parameter></term>
-           <listitem>
-             <para>A symbol naming the new foreign type.
-             </para>
-           </listitem>
-         </varlistentry>
-         <varlistentry>
-           <term><parameter>value</parameter></term>
-           <listitem>
-             <para>A form that is not evaluated that defines the new
-foreign type.
-             </para>
-           </listitem>
-         </varlistentry>
-       </variablelist>
-      </refsect1>
-      <refsect1>
-       <title>Description</title>
-       <para>Defines a new foreign type.
-       </para>
-      </refsect1>
-      <refsect1>
-       <title>Examples</title>
-       <programlisting>
-(def-foreign-type my-generic-pointer :pointer-void)
-(def-foreign-type a-double-float :double-float)
-(def-foreign-type char-ptr (* :char))
-       </programlisting>
-      </refsect1>
-      <refsect1>
-       <title>Side Effects</title>
-       <para>Defines a new foreign type.
-       </para>
-      </refsect1>
-      <refsect1>
-       <title>Affected by</title>
-       <para>None.</para>
-      </refsect1>
-      <refsect1>
-       <title>Exceptional Situations</title>
-       <para>None.</para>
-      </refsect1>
-    </refentry>
-
-    <refentry id="null-char-p">
-       <refnamediv>
-         <refname>null-char-p</refname>
-       <refpurpose>Tests a character for &null; value.
-       </refpurpose>
-       <refclass>Macro</refclass>
-      </refnamediv>
-      <refsect1>
-       <title>Syntax</title>
-<synopsis>
-         <function>null-char-p</function> <replaceable>char</replaceable> => <returnvalue>is-null</returnvalue>
-</synopsis>
-      </refsect1>
-      <refsect1>
-       <title>Arguments and Values</title>
-       <variablelist>
-         <varlistentry>
-           <term><parameter>char</parameter></term>
-           <listitem>
-             <para>A character or integer.
-             </para>
-           </listitem>
-         </varlistentry>
-         <varlistentry>
-           <term><parameter>is-null</parameter></term>
-           <listitem>
-             <para>A boolean flag indicating if char is a &null; value.
-             </para>
-           </listitem>
-         </varlistentry>
-       </variablelist>
-      </refsect1>
-      <refsect1>
-       <title>Description</title>
-       <para>
-         A predicate testing if a character or integer is &null;. This
-abstracts the difference in implementations where some return a 
-<computeroutput>character</computeroutput> and some return a 
-<computeroutput>integer</computeroutput> whence dereferencing a 
-<computeroutput>C</computeroutput> character pointer.
-       </para>
-      </refsect1>
-      <refsect1>
-       <title>Examples</title>
-       <programlisting>
-(def-array-pointer ca :unsigned-char)
-(let ((fs (convert-to-foreign-string "ab")))
-   (values (null-char-p (deref-array fs 'ca 0))
-           (null-char-p (deref-array fs 'ca 2))))
-=> &nil;
-   &t;
-       </programlisting>
-      </refsect1>
-      <refsect1>
-       <title>Side Effects</title>
-       <para>None.
-       </para>
-      </refsect1>
-      <refsect1>
-       <title>Affected by</title>
-       <para>None.</para>
-      </refsect1>
-      <refsect1>
-       <title>Exceptional Situations</title>
-       <para>None.</para>
-      </refsect1>
-    </refentry>
-  </reference>
-
-  <reference>
-    <title>Aggregate Types</title>
-    <partintro>
-      <title>Overview</title>
-      <para>
-       Aggregate types are comprised of one or more primitive types.
-      </para>
-    </partintro>
-
-    <refentry id="def-enum">
-      <refnamediv>
-       <refname>def-enum</refname>
-       <refpurpose>Defines a &c; enumeration.
-       </refpurpose>
-       <refclass>Macro</refclass>
-      </refnamediv>
-      <refsynopsisdiv>
-       <title>Syntax</title>
-       <synopsis>
-         <function>def-enum</function> <replaceable>name fields &amp;key separator-string</replaceable>
-       </synopsis>
-      </refsynopsisdiv>
-      <refsect1>
-       <title>Arguments and Values</title>
-       <variablelist>
-         <varlistentry>
-           <term><parameter>name</parameter></term>
-           <listitem>
-             <para>A symbol that names the enumeration.
-             </para>
-           </listitem>
-         </varlistentry>
-         <varlistentry>
-           <term><parameter>fields</parameter></term>
-           <listitem>
-             <para>A list of field defintions. Each definition can be
-a symbol or a list of two elements. Symbols get assigned a value of the
-current counter which starts at <computeroutput>0</computeroutput> and
-increments by <computeroutput>1</computeroutput> for each subsequent symbol. It the field definition is a list, the first position is the symbol and the second
-position is the value to assign the the symbol. The current counter gets set
-to <computeroutput>1+</computeroutput> this value.
-             </para>
-           </listitem>
-         </varlistentry>
-         <varlistentry>
-           <term><parameter>separator-string</parameter></term>
-           <listitem>
-             <para>A string that governs the creation of constants. The
-default is <computeroutput>"#"</computeroutput>.</para>
-           </listitem>
-         </varlistentry>
-       </variablelist>
-      </refsect1>
-      <refsect1>
-       <title>Description</title>
-       <para>
-         Declares a &c; enumeration. It generates constants with integer values for the elements of the enumeration. The symbols for the these constant
-values are created by the <function>concatenation</function> of the
-enumeration name, separator-string, and field symbol. Also creates
-a foreign type with the name <parameter>name</parameter> of type
-<constant>:int</constant>.
-       </para>
-      </refsect1>
-      <refsect1>
-       <title>Examples</title>
-       <programlisting>
-(def-enum abc (:a :b :c)) 
-;; Creates constants abc#a (1), abc#b (2), abc#c (3) and defines
-;; the foreign type "abc" to be :int
-
-(def-enum efoo (:e1 (:e2 10) :e3) :separator-string "-")
-;; Creates constants efoo-e1 (1), efoo-e2 (10), efoo-e3 (11) and defines
-;; the foreign type efoo to be :int
-       </programlisting>
-      </refsect1>
-      <refsect1>
-       <title>Side Effects</title>
-       <para>Creates a :int foreign type, defines constants.</para>
-      </refsect1>
-      <refsect1>
-       <title>Affected by</title>
-       <para>None.</para>
-      </refsect1>
-      <refsect1>
-       <title>Exceptional Situations</title>
-       <para>None.</para>
-      </refsect1>
-    </refentry>
-
-
-      <refentry id="def-struct">
-       <refnamediv>
-         <refname>def-struct</refname>
-       <refpurpose>Defines a &c; structure.
-       </refpurpose>
-       <refclass>Macro</refclass>
-      </refnamediv>
-      <refsynopsisdiv>
-       <title>Syntax</title>
-       <synopsis>
-         <function>def-struct</function> <replaceable>name &amp;rest fields</replaceable>
-       </synopsis>
-      </refsynopsisdiv>
-      <refsect1>
-       <title>Arguments and Values</title>
-       <variablelist>
-         <varlistentry>
-           <term><parameter>name</parameter></term>
-           <listitem>
-             <para>A symbol that names the structure.
-             </para>
-           </listitem>
-         </varlistentry>
-         <varlistentry>
-           <term><parameter>fields</parameter></term>
-           <listitem>
-             <para>A variable number of field defintions. Each definition is a list consisting of a symbol naming the field followed by its foreign type.
-             </para>
-           </listitem>
-         </varlistentry>
-       </variablelist>
-      </refsect1>
-      <refsect1>
-       <title>Description</title>
-       <para>
-         Declares a structure. A special type is available as a slot
-in the field. It is a pointer that points to an instance of the parent
-structure. It's type is <constant>:pointer-self</constant>.
-
-       </para>
-      </refsect1>
-      <refsect1>
-       <title>Examples</title>
-       <programlisting>
-(def-struct foo (a :unsigned-int) 
-                (b (* :char)) 
-                (c (:array :int 10)) 
-                (next :pointer-self))
-       </programlisting>
-      </refsect1>
-      <refsect1>
-       <title>Side Effects</title>
-       <para>Creates a foreign type.</para>
-      </refsect1>
-      <refsect1>
-       <title>Affected by</title>
-       <para>None.</para>
-      </refsect1>
-      <refsect1>
-       <title>Exceptional Situations</title>
-       <para>None.</para>
-      </refsect1>
-    </refentry>
-
-
-    <refentry id="get-slot-value">
-      <refnamediv>
-       <refname>get-slot-value</refname>
-       <refpurpose>Retrieves a value from a slot of a structure.
-       </refpurpose>
-       <refclass>Macro</refclass>
-      </refnamediv>
-      <refsynopsisdiv>
-       <title>Syntax</title>
-       <synopsis>
-         <function>get-slot-value</function> <replaceable>obj type field</replaceable> => <returnvalue>value</returnvalue>
-       </synopsis>
-      </refsynopsisdiv>
-      <refsect1>
-       <title>Arguments and Values</title>
-       <variablelist>
-         <varlistentry>
-           <term><parameter>obj</parameter></term>
-           <listitem>
-             <para>A pointer to foreign structure.
-             </para>
-           </listitem>
-         </varlistentry>
-         <varlistentry>
-           <term><parameter>type</parameter></term>
-           <listitem>
-             <para>A name of the foreign structure.
-             </para>
-           </listitem>
-         </varlistentry>
-         <varlistentry>
-           <term><parameter>field</parameter></term>
-           <listitem>
-             <para>A name of the desired field in foreign structure.
-             </para>
-           </listitem>
-         </varlistentry>
-         <varlistentry>
-           <term><returnvalue>value</returnvalue></term>
-           <listitem>
-             <para>The value of the field in the structure.
-             </para>
-           </listitem>
-         </varlistentry>
-       </variablelist>
-      </refsect1>
-      <refsect1>
-       <title>Description</title>
-       <para>
-         Accesses a slot value from a structure.
-       </para>
-      </refsect1>
-      <refsect1>
-       <title>Examples</title>
-       <programlisting>
-(get-slot-value foo-ptr 'foo-structure 'field-name)
-       </programlisting>
-      </refsect1>
-      <refsect1>
-       <title>Side Effects</title>
-       <para>None.</para>
-      </refsect1>
-      <refsect1>
-       <title>Affected by</title>
-       <para>None.</para>
-      </refsect1>
-      <refsect1>
-       <title>Exceptional Situations</title>
-       <para>None.</para>
-      </refsect1>
-    </refentry>
-
-    <refentry id="get-slot-pointer">
-      <refnamediv>
-       <refname>get-slot-pointer</refname>
-       <refpurpose>Retrieves a pointer from a slot of a structure.
-       </refpurpose>
-       <refclass>Macro</refclass>
-      </refnamediv>
-      <refsynopsisdiv>
-       <title>Syntax</title>
-       <synopsis>
-         <function>get-slot-pointer</function> <replaceable>obj type field</replaceable> => <returnvalue>pointer</returnvalue>
-       </synopsis>
-      </refsynopsisdiv>
-      <refsect1>
-       <title>Arguments and Values</title>
-       <variablelist>
-         <varlistentry>
-           <term><parameter>obj</parameter></term>
-           <listitem>
-             <para>A pointer to foreign structure.
-             </para>
-           </listitem>
-         </varlistentry>
-         <varlistentry>
-           <term><parameter>type</parameter></term>
-           <listitem>
-             <para>A name of the foreign structure.
-             </para>
-           </listitem>
-         </varlistentry>
-         <varlistentry>
-           <term><parameter>field</parameter></term>
-           <listitem>
-             <para>A name of the desired field in foreign structure.
-             </para>
-           </listitem>
-         </varlistentry>
-         <varlistentry>
-           <term><returnvalue>pointer</returnvalue></term>
-           <listitem>
-             <para>The value of the field in the structure.
-             </para>
-           </listitem>
-         </varlistentry>
-       </variablelist>
-      </refsect1>
-      <refsect1>
-       <title>Description</title>
-       <para>
-         This is similar to <function>get-slot-value</function>. It
-         is used when the value of a slot is a pointer type.
-       </para>
-      </refsect1>
-      <refsect1>
-       <title>Examples</title>
-       <programlisting>
-(get-slot-pointer foo-ptr 'foo-structure 'my-char-ptr)
-       </programlisting>
-      </refsect1>
-      <refsect1>
-       <title>Side Effects</title>
-       <para>None.</para>
-      </refsect1>
-      <refsect1>
-       <title>Affected by</title>
-       <para>None.</para>
-      </refsect1>
-      <refsect1>
-       <title>Exceptional Situations</title>
-       <para>None.</para>
-      </refsect1>
-    </refentry>
-
-
-    <refentry id="def-array-pointer">
-      <refnamediv>
-       <refname>def-array-pointer</refname>
-       <refpurpose>Defines a pointer to a array of type.
-       </refpurpose>
-       <refclass>Macro</refclass>
-      </refnamediv>
-      <refsynopsisdiv>
-       <title>Syntax</title>
-       <synopsis>
-         <function>def-array-pointer</function> <replaceable>name type</replaceable>
-       </synopsis>
-      </refsynopsisdiv>
-      <refsect1>
-       <title>Arguments and Values</title>
-       <variablelist>
-         <varlistentry>
-           <term><parameter>name</parameter></term>
-           <listitem>
-             <para>A name of the new foreign type.
-             </para>
-           </listitem>
-         </varlistentry>
-         <varlistentry>
-           <term><parameter>type</parameter></term>
-           <listitem>
-             <para>The foreign type of the array elements.
-             </para>
-           </listitem>
-         </varlistentry>
-       </variablelist>
-      </refsect1>
-      <refsect1>
-       <title>Description</title>
-       <para>
-         Defines a type tat is a pointer to an array of type.
-       </para>
-      </refsect1>
-      <refsect1>
-       <title>Examples</title>
-       <programlisting>
-(def-array-pointer byte-array-pointer :unsigned-char)
-       </programlisting>
-      </refsect1>
-      <refsect1>
-       <title>Side Effects</title>
-       <para>Defines a new foreign type.</para>
-      </refsect1>
-      <refsect1>
-       <title>Affected by</title>
-       <para>None.</para>
-      </refsect1>
-      <refsect1>
-       <title>Exceptional Situations</title>
-       <para>None.</para>
-      </refsect1>
-    </refentry>
-
-
-    <refentry id="deref-array">
-      <refnamediv>
-       <refname>deref-array</refname>
-       <refpurpose>Deference an array.
-       </refpurpose>
-       <refclass>Macro</refclass>
-      </refnamediv>
-      <refsynopsisdiv>
-       <title>Syntax</title>
-       <synopsis>
-         <function>deref-array</function> <replaceable>array type positon</replaceable> => <returnvalue>value</returnvalue>
-       </synopsis>
-      </refsynopsisdiv>
-      <refsect1>
-       <title>Arguments and Values</title>
-       <variablelist>
-         <varlistentry>
-           <term><parameter>array</parameter></term>
-           <listitem>
-             <para>A foreign array.
-             </para>
-           </listitem>
-         </varlistentry>
-         <varlistentry>
-           <term><parameter>type</parameter></term>
-           <listitem>
-             <para>The foreign type of the array.
-             </para>
-           </listitem>
-         </varlistentry>
-         <varlistentry>
-           <term><parameter>position</parameter></term>
-           <listitem>
-             <para>An integer specifying the position to retrieve from
-the array.
-             </para>
-           </listitem>
-         </varlistentry>
-         <varlistentry>
-           <term><returnvalue>value</returnvalue></term>
-           <listitem>
-             <para>The value stored in the position of the array.
-             </para>
-           </listitem>
-         </varlistentry>
-       </variablelist>
-      </refsect1>
-      <refsect1>
-       <title>Description</title>
-       <para>
-         Dereferences (retrieves) the value of an array element.
-       </para>
-      </refsect1>
-      <refsect1>
-       <title>Examples</title>
-       <programlisting>
-(def-array-pointer ca :char)
-(let ((fs (convert-to-foreign-string "ab")))
-   (values (null-char-p (deref-array fs 'ca 0))
-           (null-char-p (deref-array fs 'ca 2))))
-=> &nil;
-   &t;
-       </programlisting>
-      </refsect1>
-      <refsect1>
-       <title>Notes</title>
-        <para>
-  The TYPE argument is ignored for CL implementations other than
-  AllegroCL. If you want to cast a pointer to another type use
-  WITH-CAST-POINTER together with DEREF-POINTER/DEREF-ARRAY.
-        </para>
-      </refsect1>
-      <refsect1>
-       <title>Side Effects</title>
-       <para>None.</para>
-      </refsect1>
-      <refsect1>
-       <title>Affected by</title>
-       <para>None.</para>
-      </refsect1>
-      <refsect1>
-       <title>Exceptional Situations</title>
-       <para>None.</para>
-      </refsect1>
-    </refentry>
-
-    <refentry id="def-union">
-      <refnamediv>
-       <refname>def-union</refname>
-       <refpurpose>Defines a foreign union type.
-       </refpurpose>
-       <refclass>Macro</refclass>
-      </refnamediv>
-      <refsynopsisdiv>
-       <title>Syntax</title>
-       <synopsis>
-         <function>def-union</function> <replaceable>name &amp;rest fields</replaceable>
-       </synopsis>
-      </refsynopsisdiv>
-      <refsect1>
-       <title>Arguments and Values</title>
-       <variablelist>
-         <varlistentry>
-           <term><parameter>name</parameter></term>
-           <listitem>
-             <para>A name of the new union type.
-             </para>
-           </listitem>
-         </varlistentry>
-         <varlistentry>
-           <term><parameter>fields</parameter></term>
-           <listitem>
-             <para>A list of fields of the union.
-             </para>
-           </listitem>
-         </varlistentry>
-       </variablelist>
-      </refsect1>
-      <refsect1>
-       <title>Description</title>
-       <para>
-         Defines a foreign union type.
-       </para>
-      </refsect1>
-      <refsect1>
-       <title>Examples</title>
-       <programlisting>
-(def-union test-union
-  (a-char :char)
-  (an-int :int))
-
-(let ((u (allocate-foreign-object 'test-union))
-  (setf (get-slot-value u 'test-union 'an-int) (+ 65 (* 66 256)))
-  (prog1 
-    (ensure-char-character (get-slot-value u 'test-union 'a-char))
-    (free-foreign-object u)))
-=> #\A
-       </programlisting>
-      </refsect1>
-      <refsect1>
-       <title>Side Effects</title>
-       <para>Defines a new foreign type.</para>
-      </refsect1>
-      <refsect1>
-       <title>Affected by</title>
-       <para>None.</para>
-      </refsect1>
-      <refsect1>
-       <title>Exceptional Situations</title>
-       <para>None.</para>
-      </refsect1>
-    </refentry>
-
-
-</reference>
-
-<reference>
-    <title>Objects</title>
-<partintro>
-<title>Overview</title>
-    <para>
-      Objects are entities that can allocated, referred to by pointers, and
-can be freed.
-    </para>
-</partintro>
-
-
-    <refentry id="allocate-foreign-object">
-      <refnamediv>
-       <refname>allocate-foreign-object</refname>
-       <refpurpose>Allocates an instance of a foreign object.
-       </refpurpose>
-       <refclass>Macro</refclass>
-      </refnamediv>
-      <refsynopsisdiv>
-       <title>Syntax</title>
-       <synopsis>
-         <function>allocate-foreign-object</function> <replaceable>type &amp;optional size</replaceable> => <returnvalue>ptr</returnvalue>
-       </synopsis>
-      </refsynopsisdiv>
-      <refsect1>
-       <title>Arguments and Values</title>
-       <variablelist>
-         <varlistentry>
-           <term><parameter>type</parameter></term>
-           <listitem>
-             <para>The type of foreign object to allocate. This parameter is evaluated.
-             </para>
-           </listitem>
-         </varlistentry>
-         <varlistentry>
-           <term><parameter>size</parameter></term>
-           <listitem>
-             <para>An optional size parameter that is evaluated. If specified, allocates and returns an
-array of <parameter>type</parameter> that is <parameter>size</parameter> members long. This parameter is evaluated.
-             </para>
-           </listitem>
-         </varlistentry>
-         <varlistentry>
-           <term><returnvalue>ptr</returnvalue></term>
-           <listitem>
-             <para>A pointer to the foreign object.
-             </para>
-           </listitem>
-         </varlistentry>
-       </variablelist>
-      </refsect1>
-      <refsect1>
-       <title>Description</title>
-       <para>
-         Allocates an instance of a foreign object. It returns a pointer to the object.
-       </para>
-      </refsect1>
-      <refsect1>
-       <title>Examples</title>
-       <programlisting>
-(def-struct ab (a :int) (b :double))
-(allocate-foreign-object 'ab)
-=> #&lt;ptr&gt;
-       </programlisting>
-      </refsect1>
-      <refsect1>
-       <title>Side Effects</title>
-       <para>None.</para>
-      </refsect1>
-      <refsect1>
-       <title>Affected by</title>
-       <para>None.</para>
-      </refsect1>
-      <refsect1>
-       <title>Exceptional Situations</title>
-       <para>None.</para>
-      </refsect1>
-    </refentry>
-
-
-    <refentry id="free-foreign-object">
-      <refnamediv>
-       <refname>free-foreign-object</refname>
-       <refpurpose>Frees memory that was allocated for a foreign boject.
-       </refpurpose>
-       <refclass>Macro</refclass>
-      </refnamediv>
-      <refsynopsisdiv>
-       <title>Syntax</title>
-       <synopsis>
-         <function>free-foreign-object</function> <replaceable>ptr</replaceable>
-       </synopsis>
-      </refsynopsisdiv>
-      <refsect1>
-       <title>Arguments and Values</title>
-       <variablelist>
-         <varlistentry>
-           <term><parameter>ptr</parameter></term>
-           <listitem>
-             <para>A pointer to the allocated foreign object to free.
-             </para>
-           </listitem>
-         </varlistentry>
-       </variablelist>
-      </refsect1>
-      <refsect1>
-       <title>Description</title>
-       <para>
-         Frees the memory used by the allocation of a foreign object.
-       </para>
-      </refsect1>
-      <refsect1>
-       <title>Side Effects</title>
-       <para>None.</para>
-      </refsect1>
-      <refsect1>
-       <title>Affected by</title>
-       <para>None.</para>
-      </refsect1>
-      <refsect1>
-       <title>Exceptional Situations</title>
-       <para>None.</para>
-      </refsect1>
-    </refentry>
-
-
-    <refentry id="with-foreign-object">
-      <refnamediv>
-       <refname>with-foreign-object</refname>
-       <refpurpose>Wraps the allocation of a foreign object around a body of code.
-       </refpurpose>
-       <refclass>Macro</refclass>
-      </refnamediv>
-      <refsynopsisdiv>
-       <title>Syntax</title>
-       <synopsis>
-         <function>with-foreign-object</function> <replaceable>(var type) &amp;body body</replaceable> => <returnvalue>form-return</returnvalue>
-       </synopsis>
-      </refsynopsisdiv>
-      <refsect1>
-       <title>Arguments and Values</title>
-       <variablelist>
-         <varlistentry>
-           <term><parameter>var</parameter></term>
-           <listitem>
-             <para>The variable name to bind.
-             </para>
-           </listitem>
-         </varlistentry>
-         <varlistentry>
-           <term><parameter>type</parameter></term>
-           <listitem>
-             <para>The type of foreign object to allocate. This parameter is evaluated.
-             </para>
-           </listitem>
-         </varlistentry>
-         <varlistentry>
-           <term><returnvalue>form-return</returnvalue></term>
-           <listitem>
-             <para>The result of evaluating the <parameter>body</parameter>.
-             </para>
-           </listitem>
-         </varlistentry>
-       </variablelist>
-      </refsect1>
-      <refsect1>
-       <title>Description</title>
-       <para>
-This function wraps the allocation, binding, and destruction of a foreign object.
-On &cmucl; and
-&lw; platforms the object is stack allocated for efficiency. Benchmarks show that &acl; performs
-much better with static allocation.
-       </para>
-      </refsect1>
-      <refsect1>
-       <title>Examples</title>
-       <programlisting>
-(defun gethostname2 ()
-  "Returns the hostname"
-  (uffi:with-foreign-object (name '(:array :unsigned-char 256))
-    (if (zerop (c-gethostname (uffi:char-array-to-pointer name) 256))
-       (uffi:convert-from-foreign-string name)
-       (error "gethostname() failed."))))
-       </programlisting>
-      </refsect1>
-      <refsect1>
-       <title>Side Effects</title>
-       <para>None.</para>
-      </refsect1>
-      <refsect1>
-       <title>Affected by</title>
-       <para>None.</para>
-      </refsect1>
-      <refsect1>
-       <title>Exceptional Situations</title>
-       <para>None.</para>
-      </refsect1>
-    </refentry>
-
-    <refentry id="size-of-foreign-type">
-      <refnamediv>
-       <refname>size-of-foreign-type</refname>
-       <refpurpose>Returns the number of data bytes used by a foreign object type.
-       </refpurpose>
-       <refclass>Macro</refclass>
-      </refnamediv>
-      <refsynopsisdiv>
-       <title>Syntax</title>
-       <synopsis>
-         <function>size-of-foreign-type</function> <replaceable>ftype</replaceable>
-       </synopsis>
-      </refsynopsisdiv>
-      <refsect1>
-       <title>Arguments and Values</title>
-       <variablelist>
-         <varlistentry>
-           <term><parameter>ftype</parameter></term>
-           <listitem>
-             <para>A foreign type specifier. This parameter is evaluated.
-             </para>
-           </listitem>
-         </varlistentry>
-       </variablelist>
-      </refsect1>
-      <refsect1>
-       <title>Description</title>
-       <para>
-         Returns the number of data bytes used by a foreign object type. This does not include any Lisp storage overhead.
-       </para>
-      </refsect1>
-      <refsect1>
-       <title>Examples</title>
-       <para>
-<programlisting>
-(size-of-foreign-object :unsigned-byte)
-=> 1
-(size-of-foreign-object 'my-100-byte-vector-type)
-=> 100
-</programlisting>
-        </para>
-      </refsect1>
-      <refsect1>
-       <title>Side Effects</title>
-       <para>None.</para>
-      </refsect1>      <refsect1>
-       <title>Affected by</title>
-       <para>None.</para>
-      </refsect1>
-      <refsect1>
-       <title>Exceptional Situations</title>
-       <para>None.</para>
-      </refsect1>
-    </refentry>
-
-    <refentry id="pointer-address">
-      <refnamediv>
-       <refname>pointer-address</refname>
-       <refpurpose>Returns the address of a pointer.
-       </refpurpose>
-       <refclass>Macro</refclass>
-      </refnamediv>
-      <refsynopsisdiv>
-       <title>Syntax</title>
-       <synopsis>
-         <function>pointer-address</function> <replaceable>ptr</replaceable> => <returnvalue>address</returnvalue>
-       </synopsis>
-      </refsynopsisdiv>
-      <refsect1>
-       <title>Arguments and Values</title>
-       <variablelist>
-         <varlistentry>
-           <term><parameter>ptr</parameter></term>
-           <listitem>
-             <para>A pointer to a foreign object.
-             </para>
-           </listitem>
-         </varlistentry>
-         <varlistentry>
-           <term><parameter>address</parameter></term>
-           <listitem>
-             <para>An integer representing the pointer's address.
-             </para>
-           </listitem>
-         </varlistentry>
-       </variablelist>
-      </refsect1>
-      <refsect1>
-       <title>Description</title>
-       <para>
-         Returns the address as an integer of a pointer.
-       </para>
-      </refsect1>
-      <refsect1>
-       <title>Side Effects</title>
-       <para>None.</para>
-      </refsect1>
-      <refsect1>
-       <title>Affected by</title>
-       <para>None.</para>
-      </refsect1>
-      <refsect1>
-       <title>Exceptional Situations</title>
-       <para>None.</para>
-      </refsect1>
-    </refentry>
-
-
-    <refentry id="deref-pointer">
-      <refnamediv>
-       <refname>deref-pointer</refname>
-       <refpurpose>Deferences a pointer.
-       </refpurpose>
-       <refclass>Macro</refclass>
-      </refnamediv>
-      <refsynopsisdiv>
-       <title>Syntax</title>
-       <synopsis>
-         <function>deref-pointer</function> <replaceable>ptr type</replaceable> => <returnvalue>value</returnvalue>
-       </synopsis>
-      </refsynopsisdiv>
-      <refsect1>
-       <title>Arguments and Values</title>
-       <variablelist>
-         <varlistentry>
-           <term><parameter>ptr</parameter></term>
-           <listitem>
-             <para>A pointer to a foreign object.
-             </para>
-           </listitem>
-         </varlistentry>
-         <varlistentry>
-           <term><parameter>type</parameter></term>
-           <listitem>
-             <para>A foreign type of the object being pointed to.
-             </para>
-           </listitem>
-         </varlistentry>
-         <varlistentry>
-           <term><returnvalue>value</returnvalue></term>
-           <listitem>
-             <para>The value of the object where the pointer points.
-             </para>
-           </listitem>
-         </varlistentry>
-       </variablelist>
-      </refsect1>
-      <refsect1>
-       <title>Description</title>
-       <para>
-         Returns the object to which a pointer points.
-       </para>
-      </refsect1>
-      <refsect1>
-       <title>Examples</title>
-       <para>
-<programlisting>
-(let ((intp (allocate-foreign-object :int)))
-  (setf (deref-pointer intp :int) 10)
-  (prog1
-    (deref-pointer intp :int)
-    (free-foreign-object intp)))
-=> 10
-</programlisting>
-       </para>
-      </refsect1>
-      <refsect1>
-       <title>Notes</title>
-        <para>
-  The TYPE argument is ignored for CL implementations other than
-  AllegroCL. If you want to cast a pointer to another type use
-  WITH-CAST-POINTER together with DEREF-POINTER/DEREF-ARRAY.
-        </para>
-      </refsect1>
-      <refsect1>
-       <title>Side Effects</title>
-       <para>None.</para>
-      </refsect1>
-      <refsect1>
-       <title>Affected by</title>
-       <para>None.</para>
-      </refsect1>
-      <refsect1>
-       <title>Exceptional Situations</title>
-       <para>None.</para>
-      </refsect1>
-    </refentry>
-
-    <refentry id="ensure-char-character">
-      <refnamediv>
-       <refname>ensure-char-character</refname>
-       <refpurpose>Ensures that a dereferenced <constant>:char</constant> pointer is
-a character.
-       </refpurpose>
-       <refclass>Macro</refclass>
-      </refnamediv>
-      <refsynopsisdiv>
-       <title>Syntax</title>
-       <synopsis>
-         <function>ensure-char-character</function> <replaceable>object</replaceable> => <returnvalue>char</returnvalue>
-       </synopsis>
-      </refsynopsisdiv>
-      <refsect1>
-       <title>Arguments and Values</title>
-       <variablelist>
-         <varlistentry>
-           <term><parameter>object</parameter></term>
-           <listitem>
-             <para>Either a character or a integer specifying a character code.
-             </para>
-           </listitem>
-         </varlistentry>
-         <varlistentry>
-           <term><returnvalue>char</returnvalue></term>
-           <listitem>
-             <para>A character.
-             </para>
-           </listitem>
-         </varlistentry>
-       </variablelist>
-      </refsect1>
-      <refsect1>
-       <title>Description</title>
-       <para>
-         Ensures that an objects obtained by dereferencing  
-<constant>:char</constant> and <constant>:unsigned-char</constant>
-pointers are a lisp character.
-       </para>
-      </refsect1>
-      <refsect1>
-       <title>Examples</title>
-       <para>
-<programlisting>
-(let ((fs (convert-to-foreign-string "a")))
-  (prog1 
-    (ensure-char-character (deref-pointer fs :char))
-    (free-foreign-object fs)))
-=> #\a
-</programlisting>
-       </para>
-      </refsect1>
-      <refsect1>
-       <title>Side Effects</title>
-       <para>None.</para>
-      </refsect1>
-      <refsect1>
-       <title>Affected by</title>
-       <para>None.</para>
-      </refsect1>
-      <refsect1>
-       <title>Exceptional Situations</title>
-       <para>Depending upon the implementation and what &uffi; expects, this
-macro may signal an error if the object is not a character or
-integer.</para>
-      </refsect1>
-    </refentry>
-
-    <refentry id="ensure-char-integer">
-      <refnamediv>
-       <refname>ensure-char-integer</refname>
-       <refpurpose>Ensures that a dereferenced <constant>:char</constant> pointer is
-an integer.
-       </refpurpose>
-       <refclass>Macro</refclass>
-      </refnamediv>
-      <refsynopsisdiv>
-       <title>Syntax</title>
-       <synopsis>
-         <function>ensure-char-integer</function> <replaceable>object</replaceable> => <returnvalue>int</returnvalue>
-       </synopsis>
-      </refsynopsisdiv>
-      <refsect1>
-       <title>Arguments and Values</title>
-       <variablelist>
-         <varlistentry>
-           <term><parameter>object</parameter></term>
-           <listitem>
-             <para>Either a character or a integer specifying a character code.
-             </para>
-           </listitem>
-         </varlistentry>
-         <varlistentry>
-           <term><returnvalue>int</returnvalue></term>
-           <listitem>
-             <para>An integer.
-             </para>
-           </listitem>
-         </varlistentry>
-       </variablelist>
-      </refsect1>
-      <refsect1>
-       <title>Description</title>
-       <para>
-         Ensures that an object obtained by dereferencing a 
-<constant>:char</constant> pointer is an integer.
-       </para>
-      </refsect1>
-      <refsect1>
-       <title>Examples</title>
-       <para>
-<programlisting>
-(let ((fs (convert-to-foreign-string "a")))
-  (prog1 
-    (ensure-char-integer (deref-pointer fs :char))
-    (free-foreign-object fs)))
-=> 96
-</programlisting>
-       </para>
-      </refsect1>
-      <refsect1>
-       <title>Side Effects</title>
-       <para>None.</para>
-      </refsect1>
-      <refsect1>
-       <title>Affected by</title>
-       <para>None.</para>
-      </refsect1>
-      <refsect1>
-       <title>Exceptional Situations</title>
-       <para>Depending upon the implementation and what &uffi; expects, this
-macro may signal an error if the object is not a character or
-integer.</para>
-      </refsect1>
-    </refentry>
-
-    <refentry id="make-null-pointer">
-      <refnamediv>
-       <refname>make-null-pointer</refname>
-       <refpurpose>Create a &null; pointer.
-       </refpurpose>
-       <refclass>Macro</refclass>
-      </refnamediv>
-      <refsynopsisdiv>
-       <title>Syntax</title>
-       <synopsis>
-         <function>make-null-pointer</function> <replaceable>type</replaceable> => <returnvalue>ptr</returnvalue>
-       </synopsis>
-      </refsynopsisdiv>
-      <refsect1>
-       <title>Arguments and Values</title>
-       <variablelist>
-         <varlistentry>
-           <term><parameter>type</parameter></term>
-           <listitem>
-             <para>A type of object to which the pointer refers.
-             </para>
-           </listitem>
-         </varlistentry>
-         <varlistentry>
-           <term><parameter>ptr</parameter></term>
-           <listitem>
-             <para>The &null; pointer of type <parameter>type</parameter>.
-             </para>
-           </listitem>
-         </varlistentry>
-       </variablelist>
-      </refsect1>
-      <refsect1>
-       <title>Description</title>
-       <para>
-         Creates a &null; pointer of a specified type.
-       </para>
-      </refsect1>
-      <refsect1>
-       <title>Side Effects</title>
-       <para>None.</para>
-      </refsect1>
-      <refsect1>
-       <title>Affected by</title>
-       <para>None.</para>
-      </refsect1>
-      <refsect1>
-       <title>Exceptional Situations</title>
-       <para>None.</para>
-      </refsect1>
-    </refentry>
-
-
-    <refentry id="null-pointer-p">
-      <refnamediv>
-       <refname>null-pointer-p</refname>
-       <refpurpose>Tests a pointer for &null; value.
-       </refpurpose>
-       <refclass>Macro</refclass>
-      </refnamediv>
-      <refsynopsisdiv>
-       <title>Syntax</title>
-       <synopsis>
-         <function>null-pointer-p</function> <replaceable>ptr</replaceable> => <returnvalue>is-null</returnvalue>
-       </synopsis>
-      </refsynopsisdiv>
-      <refsect1>
-       <title>Arguments and Values</title>
-       <variablelist>
-         <varlistentry>
-           <term><parameter>ptr</parameter></term>
-           <listitem>
-             <para>A foreign object pointer.
-             </para>
-           </listitem>
-         </varlistentry>
-         <varlistentry>
-           <term><returnvalue>is-null</returnvalue></term>
-           <listitem>
-             <para>The boolean flag.
-             </para>
-           </listitem>
-         </varlistentry>
-       </variablelist>
-      </refsect1>
-      <refsect1>
-       <title>Description</title>
-       <para>
-         A predicate testing if a pointer is has a &null; value.
-       </para>
-      </refsect1>
-      <refsect1>
-       <title>Side Effects</title>
-       <para>None.</para>
-      </refsect1>
-      <refsect1>
-       <title>Affected by</title>
-       <para>None.</para>
-      </refsect1>
-      <refsect1>
-       <title>Exceptional Situations</title>
-       <para>None.</para>
-      </refsect1>
-    </refentry>
-
-
-    <refentry id="null-cstring-pointer">
-      <refnamediv>
-       <refname>+null-cstring-pointer+</refname>
-       <refpurpose>A constant &null; cstring pointer.
-       </refpurpose>
-       <refclass>Constant</refclass>
-      </refnamediv>
-      <refsect1>
-       <title>Description</title>
-       <para>
-         A &null; cstring pointer. This can be used for testing
-if a cstring returned by a function is &null;.
-       </para>
-      </refsect1>
-    </refentry>
-
-    <refentry id="with-cast-pointer">
-      <refnamediv>
-       <refname>with-cast-pointer</refname>
-       <refpurpose>Wraps a body of code with a pointer cast to a new type.
-       </refpurpose>
-       <refclass>Macro</refclass>
-      </refnamediv>
-      <refsynopsisdiv>
-       <title>Syntax</title>
-       <synopsis>
-         <function>with-cast-pointer</function> (<replaceable>binding-name ptr type) &amp; body body</replaceable> => <returnvalue>value</returnvalue>
-       </synopsis>
-      </refsynopsisdiv>
-      <refsect1>
-       <title>Arguments and Values</title>
-       <variablelist>
-         <varlistentry>
-           <term><parameter>ptr</parameter></term>
-           <listitem>
-             <para>A pointer to a foreign object.
-             </para>
-           </listitem>
-         </varlistentry>
-         <varlistentry>
-           <term><parameter>type</parameter></term>
-           <listitem>
-             <para>A foreign type of the object being pointed to.
-             </para>
-           </listitem>
-         </varlistentry>
-         <varlistentry>
-           <term><returnvalue>value</returnvalue></term>
-           <listitem>
-             <para>The value of the object where the pointer points.
-             </para>
-           </listitem>
-         </varlistentry>
-       </variablelist>
-      </refsect1>
-      <refsect1>
-       <title>Description</title>
-       <para>
-  Executes BODY with POINTER cast to be a pointer to type TYPE. If
-  BINDING-NAME is provided the cast pointer will be bound to this
-  name during the execution of BODY. If BINDING-NAME is not provided
-  POINTER must be a name bound to the pointer which should be
-  cast. This name will be bound to the cast pointer during the
-  execution of BODY.
-
-  This is a no-op in AllegroCL but will wrap BODY in a LET form if
-  BINDING-NAME is provided.
-
-  This macro is meant to be used in conjunction with DEREF-POINTER or
-  DEREF-ARRAY. In Allegro CL the "cast" will actually take place in
-  DEREF-POINTER or DEREF-ARRAY.
-       </para>
-      </refsect1>
-      <refsect1>
-       <title>Examples</title>
-<programlisting>
-(with-foreign-object (size :int)
-   ;; FOO is a foreign function returning a :POINTER-VOID
-   (let ((memory (foo size)))
-      (when (mumble)
-         ;; at this point we know for some reason that MEMORY points
-         ;; to an array of unsigned bytes
-         (with-cast-pointer (memory :unsigned-byte)
-           (dotimes (i (deref-pointer size :int))
-            (do-something-with
-              (deref-array memory '(:array :unsigned-byte) i)))))))
-</programlisting>
-      </refsect1>
-      <refsect1>
-       <title>Side Effects</title>
-       <para>None.</para>
-      </refsect1>
-      <refsect1>
-       <title>Affected by</title>
-       <para>None.</para>
-      </refsect1>
-      <refsect1>
-       <title>Exceptional Situations</title>
-       <para>None.</para>
-      </refsect1>
-    </refentry>
-
-    <refentry id="def-foreign-var">
-      <refnamediv>
-       <refname>def-foreign-var</refname>
-       <refpurpose>
-Defines a symbol macro to access a variable in foreign code
-       </refpurpose>
-       <refclass>Macro</refclass>
-      </refnamediv>
-      <refsynopsisdiv>
-       <title>Syntax</title>
-       <synopsis>
-         <function>def-foreign-var</function> <replaceable>name type module</replaceable>
-       </synopsis>
-      </refsynopsisdiv>
-      <refsect1>
-       <title>Arguments and Values</title>
-       <variablelist>
-         <varlistentry>
-           <term><parameter>name</parameter></term>
-           <listitem>
-             <para>     
-A string or list specificying the symbol macro's name. If it is a
-     string, that names the foreign variable. A Lisp name is created
-     by translating #\_ to #\- and by converting to upper-case in
-     case-insensitive Lisp implementations. If it is a list, the first
-     item is a string specifying the foreign variable name and the
-     second it is a symbol stating the Lisp name.
-             </para>
-           </listitem>
-         </varlistentry>
-         <varlistentry>
-           <term><parameter>type</parameter></term>
-           <listitem>
-             <para>A foreign type of the foreign variable.
-             </para>
-           </listitem>
-         </varlistentry>
-         <varlistentry>
-           <term><returnvalue>module</returnvalue></term>
-           <listitem>
-             <para>
-     A string specifying the module (or library) the foreign variable
-     resides in. (Required by Lispworks)
-             </para>
-           </listitem>
-         </varlistentry>
-       </variablelist>
-      </refsect1>
-      <refsect1>
-       <title>Description</title>
-       <para>
-Defines a symbol macro which can be used to access (get and set) the
-value of a variable in foreign code.
-       </para>
-      </refsect1>
-      <refsect1>
-       <title>Examples</title>
-       <refsect2>
-       <title>C code</title>
-<programlisting>
-  int baz = 3;
-
-  typedef struct {
-    int x;
-    double y;
-  } foo_struct;
-
-  foo_struct the_struct = { 42, 3.2 };
-
-  int foo () {
-    return baz;
-  }
-</programlisting>
-</refsect2>
-<refsect2>
-<title>Lisp code</title>
-<programlisting>
-  (uffi:def-struct foo-struct
-    (x :int)
-    (y :double))
-
-  (uffi:def-function ("foo" foo)
-      ()
-    :returning :int
-    :module "foo")
-
-  (uffi:def-foreign-var ("baz" *baz*) :int "foo")
-  (uffi:def-foreign-var ("the_struct" *the-struct*) foo-struct "foo")
-
-
-*baz*
-  => 3
-
-(incf *baz*)
-  => 4
-
-(foo)
-  => 4
-</programlisting>
-</refsect2>
-      </refsect1>
-      <refsect1>
-       <title>Side Effects</title>
-       <para>None.</para>
-      </refsect1>
-      <refsect1>
-       <title>Affected by</title>
-       <para>None.</para>
-      </refsect1>
-      <refsect1>
-       <title>Exceptional Situations</title>
-       <para>None.</para>
-      </refsect1>
-    </refentry>
-
-</reference>
-
-    <reference>
-      <title>Strings</title>
-<partintro>
-<title>Overview</title>
-<para>
-
-         &uffi; has functions to two types of
-<varname>C</varname>-compatible
-         strings: <emphasis>cstring</emphasis> and
-<emphasis>foreign</emphasis> strings.
-
-cstrings are used <emphasis>only</emphasis> as parameters to and from
-functions. In some implementations a cstring is not a foreign type but
-rather the Lisp string itself. On other platforms a cstring is a newly
-allocated foreign vector for storing characters. The following is an
-example of using cstrings to both send and return a value.  
-</para>
-
-<programlisting>
-(uffi:def-function ("getenv" c-getenv) 
-    ((name :cstring))
-  :returning :cstring)
-
-(defun my-getenv (key)
-  "Returns an environment variable, or NIL if it does not exist"
-  (check-type key string)
-  (uffi:with-cstring (key-native key)
-    (uffi:convert-from-cstring (c-getenv key-native))))
-</programlisting>
-
-<para> In contrast, foreign strings are always a foreign vector of
-characters which have memory allocated. Thus, if you need to allocate
-memory to hold the return value of a string, you must use a foreign
-string and not a cstring.  The following is an example of using a foreign
-string for a return value.  </para>
-
-<programlisting>
-(uffi:def-function ("gethostname" c-gethostname)
-    ((name (* :unsigned-char))
-     (len :int))
-  :returning :int)
-
-(defun gethostname ()
-  "Returns the hostname"
-  (let* ((name (uffi:allocate-foreign-string 256))
-         (result-code (c-gethostname name 256))
-         (hostname (when (zerop result-code)
-                     (uffi:convert-from-foreign-string name))))
-    (uffi:free-foreign-object name)
-    (unless (zerop result-code)
-      (error "gethostname() failed."))))
-</programlisting>
-
-<para>  Foreign functions that return pointers to freshly allocated
-strings should in general not return cstrings, but foreign strings.
-(There is no portable way to release such cstrings from Lisp.)  The
-following is an example of handling such a function.  </para>
-
-<programlisting>
-(uffi:def-function ("readline" c-readline)
-    ((prompt :cstring))
-  :returning (* :char))
-
-(defun readline (prompt)
-  "Reads a string from console with line-editing."
-  (with-cstring (c-prompt prompt)
-      (let* ((c-str (c-readline c-prompt))
-             (str (convert-from-foreign-string c-str)))
-        (uffi:free-foreign-object c-str)
-        str)))
-</programlisting>
-
-</partintro>
-
-    <refentry id="convert-from-cstring">
-      <refnamediv>
-       <refname>convert-from-cstring</refname>
-       <refpurpose>Converts a cstring to a Lisp string.
-       </refpurpose>
-       <refclass>Macro</refclass>
-      </refnamediv>
-      <refsynopsisdiv>
-       <title>Syntax</title>
-       <synopsis>
-         <function>convert-from-cstring</function> <replaceable>cstring</replaceable> => <returnvalue>string</returnvalue>
-       </synopsis>
-      </refsynopsisdiv>
-      <refsect1>
-       <title>Arguments and Values</title>
-       <variablelist>
-         <varlistentry>
-           <term><parameter>cstring</parameter></term>
-           <listitem>
-             <para>A cstring.
-             </para>
-           </listitem>
-         </varlistentry>
-         <varlistentry>
-           <term><returnvalue>string</returnvalue></term>
-           <listitem>
-             <para>A Lisp string.
-             </para>
-           </listitem>
-         </varlistentry>
-       </variablelist>
-      </refsect1>
-      <refsect1>
-       <title>Description</title>
-       <para>
-         Converts a Lisp string to a <constant>cstring</constant>. This is
-most often used when processing the results of a foreign function
-that returns a cstring.
-       </para>
-      </refsect1>
-      <refsect1>
-       <title>Side Effects</title>
-       <para>None.</para>
-      </refsect1>
-      <refsect1>
-       <title>Affected by</title>
-       <para>None.</para>
-      </refsect1>
-      <refsect1>
-       <title>Exceptional Situations</title>
-       <para>None.</para>
-      </refsect1>
-    </refentry>
-
-
-    <refentry id="convert-to-cstring">
-      <refnamediv>
-       <refname>convert-to-cstring</refname>
-       <refpurpose>Converts a Lisp string to a cstring.
-       </refpurpose>
-       <refclass>Macro</refclass>
-      </refnamediv>
-      <refsynopsisdiv>
-       <title>Syntax</title>
-       <synopsis>
-         <function>convert-to-cstring</function> <replaceable>string</replaceable> => <returnvalue>cstring</returnvalue>
-       </synopsis>
-      </refsynopsisdiv>
-      <refsect1>
-       <title>Arguments and Values</title>
-       <variablelist>
-         <varlistentry>
-           <term><parameter>string</parameter></term>
-           <listitem>
-             <para>A Lisp string.
-             </para>
-           </listitem>
-         </varlistentry>
-         <varlistentry>
-           <term><returnvalue>cstring</returnvalue></term>
-           <listitem>
-             <para>A cstring.
-             </para>
-           </listitem>
-         </varlistentry>
-       </variablelist>
-      </refsect1>
-      <refsect1>
-       <title>Description</title>
-       <para>
-         Converts a Lisp string to a
-         <varname>cstring</varname>. The
-         <varname>cstring</varname> should be freed with
-         <function>free-cstring</function>.
-       </para>
-      </refsect1>
-      <refsect1>
-       <title>Side Effects</title>
-       <para>On some implementations, this function allocates memory.</para>
-      </refsect1>
-      <refsect1>
-       <title>Affected by</title>
-       <para>None.</para>
-      </refsect1>
-      <refsect1>
-       <title>Exceptional Situations</title>
-       <para>None.</para>
-      </refsect1>
-    </refentry>
-
-
-    <refentry id="free-cstring">
-      <refnamediv>
-       <refname>free-cstring</refname>
-       <refpurpose>Free memory used by cstring.
-       </refpurpose>
-       <refclass>Macro</refclass>
-      </refnamediv>
-      <refsynopsisdiv>
-       <title>Syntax</title>
-       <synopsis>
-         <function>free-cstring</function> <replaceable>cstring</replaceable>
-       </synopsis>
-      </refsynopsisdiv>
-      <refsect1>
-       <title>Arguments and Values</title>
-       <variablelist>
-         <varlistentry>
-           <term><parameter>cstring</parameter></term>
-           <listitem>
-             <para>A cstring.
-             </para>
-           </listitem>
-         </varlistentry>
-       </variablelist>
-      </refsect1>
-      <refsect1>
-       <title>Description</title>
-       <para>
-         Frees any memory possibly allocated by
-         <function>convert-to-cstring</function>. On some implementions, a cstring is just the Lisp string itself.
-       </para>
-      </refsect1>
-      <refsect1>
-       <title>Side Effects</title>
-       <para>None.</para>
-      </refsect1>
-      <refsect1>
-       <title>Affected by</title>
-       <para>None.</para>
-      </refsect1>
-      <refsect1>
-       <title>Exceptional Situations</title>
-       <para>None.</para>
-      </refsect1>
-    </refentry>
-
-
-    <refentry id="with-cstring">
-      <refnamediv>
-       <refname>with-cstring</refname>
-       <refpurpose>Binds a newly created cstring.
-       </refpurpose>
-       <refclass>Macro</refclass>
-      </refnamediv>
-      <refsynopsisdiv>
-       <title>Syntax</title>
-       <synopsis>
-         <function>with-cstring</function> <replaceable>(cstring string) {body}</replaceable>
-       </synopsis>
-      </refsynopsisdiv>
-      <refsect1>
-       <title>Arguments and Values</title>
-       <variablelist>
-         <varlistentry>
-           <term><parameter>cstring</parameter></term>
-           <listitem>
-             <para>A symbol naming the cstring to be created.
-             </para>
-           </listitem>
-         </varlistentry>
-         <varlistentry>
-           <term><parameter>string</parameter></term>
-           <listitem>
-             <para>A Lisp string that will be translated to a cstring.
-             </para>
-           </listitem>
-         </varlistentry>
-         <varlistentry>
-           <term><parameter>body</parameter></term>
-           <listitem>
-             <para>The body of where the cstring will be bound.
-             </para>
-           </listitem>
-         </varlistentry>
-       </variablelist>
-      </refsect1>
-      <refsect1>
-       <title>Description</title>
-       <para>
-         Binds a symbol to a cstring created from conversion of a string. Automatically frees the <varname>cstring</varname>.
-       </para>
-      </refsect1>
-      <refsect1>
-       <title>Examples</title>
-       <para>
-           <programlisting>
-(def-function ("getenv" c-getenv) 
-   ((name :cstring))
-   :returning :cstring)
-
-(defun getenv (key)
-  "Returns an environment variable, or NIL if it does not exist"
-  (check-type key string)
-  (with-cstring (key-cstring key)
-    (convert-from-cstring (c-getenv key-cstring))))
-           </programlisting>
-         </para>
-       </refsect1>
-      <refsect1>
-       <title>Side Effects</title>
-       <para>None.</para>
-      </refsect1>
-      <refsect1>
-       <title>Affected by</title>
-       <para>None.</para>
-      </refsect1>
-      <refsect1>
-       <title>Exceptional Situations</title>
-       <para>None.</para>
-      </refsect1>
-    </refentry>
-
-
-    <refentry id="convert-from-foreign-string">
-      <refnamediv>
-       <refname>convert-from-foreign-string</refname>
-       <refpurpose>Converts a foreign string into a Lisp string.
-       </refpurpose>
-       <refclass>Macro</refclass>
-      </refnamediv>
-      <refsynopsisdiv>
-       <title>Syntax</title>
-       <synopsis>
-         <function>convert-from-foreign-string</function> <replaceable>foreign-string &amp;key length null-terminated-p</replaceable> => <returnvalue>string</returnvalue>
-       </synopsis>
-      </refsynopsisdiv>
-      <refsect1>
-       <title>Arguments and Values</title>
-       <variablelist>
-         <varlistentry>
-           <term><parameter>foreign-string</parameter></term>
-           <listitem>
-             <para>A foreign string.
-             </para>
-           </listitem>
-         </varlistentry>
-         <varlistentry>
-           <term><parameter>length</parameter></term>
-           <listitem>
-             <para>The length of the foreign string to
-convert. The default is the length of the string until a &null;
-character is reached.
-             </para>
-           </listitem>
-         </varlistentry>
-         <varlistentry>
-           <term><parameter>null-terminated-p</parameter></term>
-           <listitem>
-             <para>A boolean flag with a default value of &t; When true,
-the string is converted until the first &null; character is reached.
-             </para>
-           </listitem>
-         </varlistentry>
-         <varlistentry>
-           <term><returnvalue>string</returnvalue></term>
-           <listitem>
-             <para>A Lisp string.
-             </para>
-           </listitem>
-         </varlistentry>
-       </variablelist>
-      </refsect1>
-      <refsect1>
-       <title>Description</title>
-       <para>
-         Returns a Lisp string from a foreign string. 
-Can translated ASCII and binary strings.
-       </para>
-      </refsect1>
-      <refsect1>
-       <title>Side Effects</title>
-       <para>None.</para>
-      </refsect1>
-      <refsect1>
-       <title>Affected by</title>
-       <para>None.</para>
-      </refsect1>
-      <refsect1>
-       <title>Exceptional Situations</title>
-       <para>None.</para>
-      </refsect1>
-    </refentry>
-
-
-    <refentry id="convert-to-foreign-string">
-      <refnamediv>
-       <refname>convert-to-foreign-string</refname>
-       <refpurpose>Converts a Lisp string to a foreign string.
-       </refpurpose>
-       <refclass>Macro</refclass>
-      </refnamediv>
-      <refsynopsisdiv>
-       <title>Syntax</title>
-       <synopsis>
-         <function>convert-to-foreign-string</function> <replaceable>string</replaceable> => <returnvalue>foreign-string</returnvalue>
-       </synopsis>
-      </refsynopsisdiv>
-      <refsect1>
-       <title>Arguments and Values</title>
-       <variablelist>
-         <varlistentry>
-           <term><parameter>string</parameter></term>
-           <listitem>
-             <para>A Lisp string.
-             </para>
-           </listitem>
-         </varlistentry>
-         <varlistentry>
-           <term><returnvalue>foreign-string</returnvalue></term>
-           <listitem>
-             <para>A foreign string.
-             </para>
-           </listitem>
-         </varlistentry>
-       </variablelist>
-      </refsect1>
-      <refsect1>
-       <title>Description</title>
-       <para>
-         Converts a Lisp string to a foreign string. Memory should be
-         freed with <function>free-foreign-object</function>.
-       </para>
-      </refsect1>
-      <refsect1>
-       <title>Side Effects</title>
-       <para>None.</para>
-      </refsect1>
-      <refsect1>
-       <title>Affected by</title>
-       <para>None.</para>
-      </refsect1>
-      <refsect1>
-       <title>Exceptional Situations</title>
-       <para>None.</para>
-      </refsect1>
-    </refentry>
-
-
-
-    <refentry id="allocate-foreign-string">
-      <refnamediv>
-       <refname>allocate-foreign-string</refname>
-       <refpurpose>Allocates space for a foreign string.
-       </refpurpose>
-       <refclass>Macro</refclass>
-      </refnamediv>
-      <refsynopsisdiv>
-       <title>Syntax</title>
-       <synopsis>
-         <function>allocate-foreign-string</function> <replaceable>size &amp;key unsigned</replaceable> => <returnvalue>foreign-string</returnvalue>
-       </synopsis>
-      </refsynopsisdiv>
-      <refsect1>
-       <title>Arguments and Values</title>
-       <variablelist>
-         <varlistentry>
-           <term><parameter>size</parameter></term>
-           <listitem>
-             <para>The size of the space to be allocated in bytes.
-             </para>
-           </listitem>
-         </varlistentry>
-         <varlistentry>
-           <term><parameter>unsigned</parameter></term>
-           <listitem>
-             <para>A boolean flag with a default value of &t;. When true,
-marks the pointer as an <constant>:unsigned-char</constant>.
-             </para>
-           </listitem>
-         </varlistentry>
-         <varlistentry>
-           <term><returnvalue>foreign-string</returnvalue></term>
-           <listitem>
-             <para>A foreign string which has undefined contents.
-             </para>
-           </listitem>
-         </varlistentry>
-       </variablelist>
-      </refsect1>
-      <refsect1>
-       <title>Description</title>
-       <para>
-         Allocates space for a foreign string. Memory should
-         be freed with <function>free-foreign-object</function>.
-       </para>
-      </refsect1>
-      <refsect1>
-       <title>Side Effects</title>
-       <para>None.</para>
-      </refsect1>
-      <refsect1>
-       <title>Affected by</title>
-       <para>None.</para>
-      </refsect1>
-      <refsect1>
-       <title>Exceptional Situations</title>
-       <para>None.</para>
-      </refsect1>
-    </refentry>
-
-  </reference>
-
-  <reference>
-      <title>Functions &amp; Libraries</title>
-
-      <refentry id="def-function">
-       <refnamediv>
-         <refname>def-function</refname>
-       <refpurpose>Declares a function. 
-       </refpurpose>
-       <refclass>Macro</refclass>
-      </refnamediv>
-      <refsynopsisdiv>
-       <title>Syntax</title>
-       <synopsis>
-         <function>def-function</function> <replaceable>name args &amp;key module returning</replaceable>
-       </synopsis>
-      </refsynopsisdiv>
-      <refsect1>
-       <title>Arguments and Values</title>
-       <variablelist>
-         <varlistentry>
-           <term><parameter>name</parameter></term>
-           <listitem>
-             <para>A string or list specificying the function name. If it is a string, that names the foreign function. A Lisp name is created by translating #\_ to #\- and by converting to upper-case in case-insensitive Lisp implementations. If it is a list, the first item is a string specifying the foreign function name and the second it is a symbol stating the Lisp name.
-             </para>
-           </listitem>
-         </varlistentry>
-         <varlistentry>
-           <term><parameter>args</parameter></term>
-           <listitem>
-             <para>A list of argument declarations. If &nil;, indicates that the function does not take any arguments.
-             </para>
-           </listitem>
-         </varlistentry>
-         <varlistentry>
-           <term><parameter>module</parameter></term>
-           <listitem>
-             <para>A string specifying which module (or library) that the foreign function resides. (Required by Lispworks)</para>
-           </listitem>
-         </varlistentry>
-         <varlistentry>
-           <term><returnvalue>returning</returnvalue></term>
-           <listitem>
-             <para>A declaration specifying the result type of the
-foreign function. If <constant>:void</constant> indicates module does not return any value.
-             </para>
-           </listitem>
-         </varlistentry>
-       </variablelist>
-      </refsect1>
-      <refsect1>
-       <title>Description</title>
-       <para>Declares a foreign function.
-       </para>
-      </refsect1>
-      <refsect1>
-       <title>Examples</title>
-       <programlisting>
-(def-function "gethostname" 
-  ((name (* :unsigned-char))
-   (len :int))
-  :returning :int)
-       </programlisting>
-      </refsect1>
-      <refsect1>
-       <title>Side Effects</title>
-       <para>None.</para>
-      </refsect1>
-      <refsect1>
-       <title>Affected by</title>
-       <para>None.</para>
-      </refsect1>
-      <refsect1>
-       <title>Exceptional Situations</title>
-       <para>None.</para>
-      </refsect1>
-    </refentry>
-
-      <refentry id="load-foreign-library">
-       <refnamediv>
-         <refname>load-foreign-library</refname>
-       <refpurpose>Loads a foreign library. 
-       </refpurpose>
-       <refclass>Function</refclass>
-      </refnamediv>
-      <refsect1>
-       <title>Syntax</title>
-<synopsis>
-         <function>load-foreign-library</function> <replaceable>filename &amp;key module supporting-libraries force-load</replaceable> => <returnvalue>success</returnvalue>
-</synopsis>
-      </refsect1>
-      <refsect1>
-       <title>Arguments and Values</title>
-       <variablelist>
-         <varlistentry>
-           <term><parameter>filename</parameter></term>
-           <listitem>
-             <para>A string or pathname specifying the library location
-in the filesystem. At least one implementation (&lw;) can not
-accept a logical pathname.
-             </para>
-           </listitem>
-         </varlistentry>
-         <varlistentry>
-           <term><parameter>module</parameter></term>
-           <listitem>
-             <para>A string designating the name of the module to apply
-to functions in this library. (Required for Lispworks)
-             </para>
-           </listitem>
-         </varlistentry>
-         <varlistentry>
-           <term><parameter>supporting-libraries</parameter></term>
-           <listitem>
-             <para>A list of strings naming the libraries required to
-link the foreign library. (Required by CMUCL)
-             </para>
-           </listitem>
-         </varlistentry>
-         <varlistentry>
-           <term><parameter>force-load</parameter></term>
-           <listitem>
-             <para>Forces the loading of the library if it has been previously loaded. 
-             </para>
-           </listitem>
-         </varlistentry>
-         <varlistentry>
-           <term><returnvalue>success</returnvalue></term>
-           <listitem>
-             <para>A boolean flag, &t; if the library was able to be
-loaded successfully or if the library has been previously loaded,
-otherwise &nil;.
-             </para>
-           </listitem>
-         </varlistentry>
-       </variablelist>
-      </refsect1>
-      <refsect1>
-       <title>Description</title>
-       <para>Loads a foreign library. Applies a module name to functions
-within the library. Ensures that a library is only loaded once during
-a session. A library can be reloaded by using the <symbol>:force-load</symbol> key.
-       </para>
-      </refsect1>
-      <refsect1>
-       <title>Examples</title>
-       <programlisting>
-  (load-foreign-library #p"/usr/lib/libmysqlclient.so" 
-                        :module "mysql" 
-                        :supporting-libraries '("c"))
-    => T
-       </programlisting>
-      </refsect1>
-      <refsect1>
-       <title>Side Effects</title>
-       <para>Loads the foreign code into the Lisp system.
-       </para>
-      </refsect1>
-      <refsect1>
-       <title>Affected by</title>
-       <para>Ability to load the file.</para>
-      </refsect1>
-      <refsect1>
-       <title>Exceptional Situations</title>
-       <para>None.</para>
-      </refsect1>
-    </refentry>
-
-      <refentry id="find-foreign-library">
-       <refnamediv>
-         <refname>find-foreign-library</refname>
-       <refpurpose>Finds a foreign library file.
-       </refpurpose>
-       <refclass>Function</refclass>
-      </refnamediv>
-      <refsect1>
-       <title>Syntax</title>
-<synopsis>
-         <function>find-foreign-library</function> <replaceable>names directories &amp; drive-letters types</replaceable> => <returnvalue>path</returnvalue>
-</synopsis>
-      </refsect1>
-      <refsect1>
-       <title>Arguments and Values</title>
-       <variablelist>
-         <varlistentry>
-           <term><parameter>names</parameter></term>
-           <listitem>
-             <para>A string or list of strings containing the base name of the library file.
-             </para>
-           </listitem>
-         </varlistentry>
-         <varlistentry>
-           <term><parameter>directories</parameter></term>
-           <listitem>
-             <para>A string or list of strings containing the directory the library file.
-             </para>
-           </listitem>
-         </varlistentry>
-         <varlistentry>
-           <term><parameter>drive-letters</parameter></term>
-           <listitem>
-             <para>A string or list of strings containing the drive letters for the library file.
-             </para>
-           </listitem>
-         </varlistentry>
-         <varlistentry>
-           <term><parameter>types</parameter></term>
-           <listitem>
-             <para>A string or list of strings containing the file type of the library file. Default
-is &nil;. If &nil;, will use a default type based on the currently running implementation.
-             </para>
-           </listitem>
-         </varlistentry>
-         <varlistentry>
-           <term><returnvalue>path</returnvalue></term>
-           <listitem>
-             <para>A path containing the path found, or &nil; if the library file was not found.
-             </para>
-           </listitem>
-         </varlistentry>
-       </variablelist>
-      </refsect1>
-      <refsect1>
-       <title>Description</title>
-       <para>Finds a foreign library by searching through a number of possible locations. Returns
-the path of the first found file.
-       </para>
-      </refsect1>
-      <refsect1>
-       <title>Examples</title>
-       <programlisting>
-(find-foreign-library '("libmysqlclient" "libmysql")
-    '("/opt/mysql/lib/mysql/" "/usr/local/lib/" "/usr/lib/" "/mysql/lib/opt/")
-    :types '("so" "dll")
-    :drive-letters '("C" "D" "E"))
-=> #P"D:\\mysql\\lib\\opt\\libmysql.dll"
-       </programlisting>
-      </refsect1>
-      <refsect1>
-       <title>Side Effects</title>
-       <para>None.
-       </para>
-      </refsect1>
-      <refsect1>
-       <title>Affected by</title>
-       <para>None.</para>
-      </refsect1>
-      <refsect1>
-       <title>Exceptional Situations</title>
-       <para>None.</para>
-      </refsect1>
-    </refentry>
-
-</reference>
-
-
-<appendix>
-  <title>Installation</title>
-  <sect1>
-    <title>Download &uffi;</title>
-    <para>
-You need to download the &uffi; package from its web
-<ulink url="http://uffi.med-info.com"><citetitle>home</citetitle></ulink>.
-You also need to have a copy of &asdf;. If you need a copy of
-&asdf;, it is included in the 
-  <ulink
-      url="http://www.sourceforge.net/projects/cclan">
-      <citetitle>CCLAN</citetitle></ulink> package. You can download
-the file <filename>defsystem.lisp</filename> from the CVS 
-<ulink url="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/cclan/asdf/asdf.lisp"><citetitle>tree</citetitle></ulink>.
-    </para>
-  </sect1>
-  <sect1>
-    <title>Installation</title>
-    <para>
-      After downloading and installing &asdf;, simply
-      <function>push</function> the
-      directory containing &uffi; into
-      <varname>asdf:*central-registry*</varname> variable. Whenever you
-want to load the &uffi; package, use the function
-      <computeroutput>(asdf:oos 'asdf:load-op :uffi)</computeroutput>.
-    </para>
-  </sect1>
-</appendix>
-
-
-<glossary>
-  <glossentry id="gloss-ffi">
-    <glossterm>Foreign Function Interface
-      <acronym>FFI</acronym>)
-    </glossterm>
-    <glossdef>
-      <para>
-        An interface to a C-compatible library.
-      </para>
-    </glossdef>
-  </glossentry>
-</glossary>
-
 
+<book> <!-- xmlns:xi="http://www.w3.org/2003/XInclude"> -->
 
+  &bookinfo; <!-- <xi:include href="bookinfo.xml" /> -->
+  &preface;
+  &intro;
+  &notes;
+  &ref;
+  &appendix;
+  &glossary;
 </book>