merge new-evsql into new structure
authorTero Marttila <terom@fixme.fi>
Sun, 08 Mar 2009 01:33:45 +0200
changeset 58 02e539965ef4
parent 57 527d23bf6441 (current diff)
parent 55 0b92d553400a (diff)
child 59 54a2e6be81a7
merge new-evsql into new structure
.hgignore
include/evsql.h
src/CMakeLists.txt
src/core.c
src/evsql/evsql.h
src/evsql/query.c
src/evsql/result.c
src/internal.h
src/query.c
src/result.c
src/util.c
--- a/.hgignore	Sun Mar 08 01:16:54 2009 +0200
+++ b/.hgignore	Sun Mar 08 01:33:45 2009 +0200
@@ -2,3 +2,4 @@
 
 ^build
 \.[^/]+.sw[op]$
+^doc/(\w+/)?html$
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/doc/doxygen-evsql.conf	Sun Mar 08 01:33:45 2009 +0200
@@ -0,0 +1,6 @@
+@INCLUDE = doc/doxygen.conf
+
+PROJECT_NAME = evsql
+INPUT = doc/evsql.dox src/evsql.h
+OUTPUT_DIRECTORY = doc/evsql
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/doc/doxygen.conf	Sun Mar 08 01:33:45 2009 +0200
@@ -0,0 +1,1417 @@
+# Doxyfile 1.5.6
+
+# This file describes the settings to be used by the documentation system
+# doxygen (www.doxygen.org) for a project
+#
+# All text after a hash (#) is considered a comment and will be ignored
+# The format is:
+#       TAG = value [value, ...]
+# For lists items can also be appended using:
+#       TAG += value [value, ...]
+# Values that contain spaces should be placed between quotes (" ")
+
+#---------------------------------------------------------------------------
+# Project related configuration options
+#---------------------------------------------------------------------------
+
+# This tag specifies the encoding used for all characters in the config file 
+# that follow. The default is UTF-8 which is also the encoding used for all 
+# text before the first occurrence of this tag. Doxygen uses libiconv (or the 
+# iconv built into libc) for the transcoding. See 
+# http://www.gnu.org/software/libiconv for the list of possible encodings.
+
+DOXYFILE_ENCODING      = UTF-8
+
+# The PROJECT_NAME tag is a single word (or a sequence of words surrounded 
+# by quotes) that should identify the project.
+
+PROJECT_NAME           = evsql
+
+# The PROJECT_NUMBER tag can be used to enter a project or revision number. 
+# This could be handy for archiving the generated documentation or 
+# if some version control system is used.
+
+PROJECT_NUMBER         = 
+
+# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) 
+# base path where the generated documentation will be put. 
+# If a relative path is entered, it will be relative to the location 
+# where doxygen was started. If left blank the current directory will be used.
+
+OUTPUT_DIRECTORY       = doc
+
+# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create 
+# 4096 sub-directories (in 2 levels) under the output directory of each output 
+# format and will distribute the generated files over these directories. 
+# Enabling this option can be useful when feeding doxygen a huge amount of 
+# source files, where putting all generated files in the same directory would 
+# otherwise cause performance problems for the file system.
+
+CREATE_SUBDIRS         = NO
+
+# The OUTPUT_LANGUAGE tag is used to specify the language in which all 
+# documentation generated by doxygen is written. Doxygen will use this 
+# information to generate all constant output in the proper language. 
+# The default language is English, other supported languages are: 
+# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, 
+# Croatian, Czech, Danish, Dutch, Farsi, Finnish, French, German, Greek, 
+# Hungarian, Italian, Japanese, Japanese-en (Japanese with English messages), 
+# Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, Polish, 
+# Portuguese, Romanian, Russian, Serbian, Slovak, Slovene, Spanish, Swedish, 
+# and Ukrainian.
+
+OUTPUT_LANGUAGE        = English
+
+# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will 
+# include brief member descriptions after the members that are listed in 
+# the file and class documentation (similar to JavaDoc). 
+# Set to NO to disable this.
+
+BRIEF_MEMBER_DESC      = YES
+
+# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend 
+# the brief description of a member or function before the detailed description. 
+# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the 
+# brief descriptions will be completely suppressed.
+
+REPEAT_BRIEF           = YES
+
+# This tag implements a quasi-intelligent brief description abbreviator 
+# that is used to form the text in various listings. Each string 
+# in this list, if found as the leading text of the brief description, will be 
+# stripped from the text and the result after processing the whole list, is 
+# used as the annotated text. Otherwise, the brief description is used as-is. 
+# If left blank, the following values are used ("$name" is automatically 
+# replaced with the name of the entity): "The $name class" "The $name widget" 
+# "The $name file" "is" "provides" "specifies" "contains" 
+# "represents" "a" "an" "the"
+
+ABBREVIATE_BRIEF       = 
+
+# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then 
+# Doxygen will generate a detailed section even if there is only a brief 
+# description.
+
+ALWAYS_DETAILED_SEC    = NO
+
+# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all 
+# inherited members of a class in the documentation of that class as if those 
+# members were ordinary class members. Constructors, destructors and assignment 
+# operators of the base classes will not be shown.
+
+INLINE_INHERITED_MEMB  = NO
+
+# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full 
+# path before files name in the file list and in the header files. If set 
+# to NO the shortest path that makes the file name unique will be used.
+
+FULL_PATH_NAMES        = YES
+
+# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag 
+# can be used to strip a user-defined part of the path. Stripping is 
+# only done if one of the specified strings matches the left-hand part of 
+# the path. The tag can be used to show relative paths in the file list. 
+# If left blank the directory from which doxygen is run is used as the 
+# path to strip.
+
+STRIP_FROM_PATH        = 
+
+# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of 
+# the path mentioned in the documentation of a class, which tells 
+# the reader which header file to include in order to use a class. 
+# If left blank only the name of the header file containing the class 
+# definition is used. Otherwise one should specify the include paths that 
+# are normally passed to the compiler using the -I flag.
+
+STRIP_FROM_INC_PATH    = 
+
+# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter 
+# (but less readable) file names. This can be useful is your file systems 
+# doesn't support long names like on DOS, Mac, or CD-ROM.
+
+SHORT_NAMES            = NO
+
+# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen 
+# will interpret the first line (until the first dot) of a JavaDoc-style 
+# comment as the brief description. If set to NO, the JavaDoc 
+# comments will behave just like regular Qt-style comments 
+# (thus requiring an explicit @brief command for a brief description.)
+
+JAVADOC_AUTOBRIEF      = YES
+
+# If the QT_AUTOBRIEF tag is set to YES then Doxygen will 
+# interpret the first line (until the first dot) of a Qt-style 
+# comment as the brief description. If set to NO, the comments 
+# will behave just like regular Qt-style comments (thus requiring 
+# an explicit \brief command for a brief description.)
+
+QT_AUTOBRIEF           = NO
+
+# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen 
+# treat a multi-line C++ special comment block (i.e. a block of //! or /// 
+# comments) as a brief description. This used to be the default behaviour. 
+# The new default is to treat a multi-line C++ comment block as a detailed 
+# description. Set this tag to YES if you prefer the old behaviour instead.
+
+MULTILINE_CPP_IS_BRIEF = NO
+
+# If the DETAILS_AT_TOP tag is set to YES then Doxygen 
+# will output the detailed description near the top, like JavaDoc.
+# If set to NO, the detailed description appears after the member 
+# documentation.
+
+DETAILS_AT_TOP         = NO
+
+# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented 
+# member inherits the documentation from any documented member that it 
+# re-implements.
+
+INHERIT_DOCS           = YES
+
+# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce 
+# a new page for each member. If set to NO, the documentation of a member will 
+# be part of the file/class/namespace that contains it.
+
+SEPARATE_MEMBER_PAGES  = NO
+
+# The TAB_SIZE tag can be used to set the number of spaces in a tab. 
+# Doxygen uses this value to replace tabs by spaces in code fragments.
+
+TAB_SIZE               = 4
+
+# This tag can be used to specify a number of aliases that acts 
+# as commands in the documentation. An alias has the form "name=value". 
+# For example adding "sideeffect=\par Side Effects:\n" will allow you to 
+# put the command \sideeffect (or @sideeffect) in the documentation, which 
+# will result in a user-defined paragraph with heading "Side Effects:". 
+# You can put \n's in the value part of an alias to insert newlines.
+
+ALIASES                = 
+
+# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C 
+# sources only. Doxygen will then generate output that is more tailored for C. 
+# For instance, some of the names that are used will be different. The list 
+# of all members will be omitted, etc.
+
+OPTIMIZE_OUTPUT_FOR_C  = YES
+
+# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java 
+# sources only. Doxygen will then generate output that is more tailored for 
+# Java. For instance, namespaces will be presented as packages, qualified 
+# scopes will look different, etc.
+
+OPTIMIZE_OUTPUT_JAVA   = NO
+
+# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran 
+# sources only. Doxygen will then generate output that is more tailored for 
+# Fortran.
+
+OPTIMIZE_FOR_FORTRAN   = NO
+
+# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL 
+# sources. Doxygen will then generate output that is tailored for 
+# VHDL.
+
+OPTIMIZE_OUTPUT_VHDL   = NO
+
+# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want 
+# to include (a tag file for) the STL sources as input, then you should 
+# set this tag to YES in order to let doxygen match functions declarations and 
+# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. 
+# func(std::string) {}). This also make the inheritance and collaboration 
+# diagrams that involve STL classes more complete and accurate.
+
+BUILTIN_STL_SUPPORT    = NO
+
+# If you use Microsoft's C++/CLI language, you should set this option to YES to
+# enable parsing support.
+
+CPP_CLI_SUPPORT        = NO
+
+# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. 
+# Doxygen will parse them like normal C++ but will assume all classes use public 
+# instead of private inheritance when no explicit protection keyword is present.
+
+SIP_SUPPORT            = NO
+
+# For Microsoft's IDL there are propget and propput attributes to indicate getter 
+# and setter methods for a property. Setting this option to YES (the default) 
+# will make doxygen to replace the get and set methods by a property in the 
+# documentation. This will only work if the methods are indeed getting or 
+# setting a simple type. If this is not the case, or you want to show the 
+# methods anyway, you should set this option to NO.
+
+IDL_PROPERTY_SUPPORT   = YES
+
+# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC 
+# tag is set to YES, then doxygen will reuse the documentation of the first 
+# member in the group (if any) for the other members of the group. By default 
+# all members of a group must be documented explicitly.
+
+DISTRIBUTE_GROUP_DOC   = NO
+
+# Set the SUBGROUPING tag to YES (the default) to allow class member groups of 
+# the same type (for instance a group of public functions) to be put as a 
+# subgroup of that type (e.g. under the Public Functions section). Set it to 
+# NO to prevent subgrouping. Alternatively, this can be done per class using 
+# the \nosubgrouping command.
+
+SUBGROUPING            = YES
+
+# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum 
+# is documented as struct, union, or enum with the name of the typedef. So 
+# typedef struct TypeS {} TypeT, will appear in the documentation as a struct 
+# with name TypeT. When disabled the typedef will appear as a member of a file, 
+# namespace, or class. And the struct will be named TypeS. This can typically 
+# be useful for C code in case the coding convention dictates that all compound 
+# types are typedef'ed and only the typedef is referenced, never the tag name.
+
+TYPEDEF_HIDES_STRUCT   = NO
+
+#---------------------------------------------------------------------------
+# Build related configuration options
+#---------------------------------------------------------------------------
+
+# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in 
+# documentation are documented, even if no documentation was available. 
+# Private class members and static file members will be hidden unless 
+# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
+
+EXTRACT_ALL            = NO
+
+# If the EXTRACT_PRIVATE tag is set to YES all private members of a class 
+# will be included in the documentation.
+
+EXTRACT_PRIVATE        = NO
+
+# If the EXTRACT_STATIC tag is set to YES all static members of a file 
+# will be included in the documentation.
+
+EXTRACT_STATIC         = NO
+
+# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) 
+# defined locally in source files will be included in the documentation. 
+# If set to NO only classes defined in header files are included.
+
+EXTRACT_LOCAL_CLASSES  = YES
+
+# This flag is only useful for Objective-C code. When set to YES local 
+# methods, which are defined in the implementation section but not in 
+# the interface are included in the documentation. 
+# If set to NO (the default) only methods in the interface are included.
+
+EXTRACT_LOCAL_METHODS  = NO
+
+# If this flag is set to YES, the members of anonymous namespaces will be 
+# extracted and appear in the documentation as a namespace called 
+# 'anonymous_namespace{file}', where file will be replaced with the base 
+# name of the file that contains the anonymous namespace. By default 
+# anonymous namespace are hidden.
+
+EXTRACT_ANON_NSPACES   = NO
+
+# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all 
+# undocumented members of documented classes, files or namespaces. 
+# If set to NO (the default) these members will be included in the 
+# various overviews, but no documentation section is generated. 
+# This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_MEMBERS     = NO
+
+# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all 
+# undocumented classes that are normally visible in the class hierarchy. 
+# If set to NO (the default) these classes will be included in the various 
+# overviews. This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_CLASSES     = NO
+
+# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all 
+# friend (class|struct|union) declarations. 
+# If set to NO (the default) these declarations will be included in the 
+# documentation.
+
+HIDE_FRIEND_COMPOUNDS  = NO
+
+# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any 
+# documentation blocks found inside the body of a function. 
+# If set to NO (the default) these blocks will be appended to the 
+# function's detailed documentation block.
+
+HIDE_IN_BODY_DOCS      = NO
+
+# The INTERNAL_DOCS tag determines if documentation 
+# that is typed after a \internal command is included. If the tag is set 
+# to NO (the default) then the documentation will be excluded. 
+# Set it to YES to include the internal documentation.
+
+INTERNAL_DOCS          = NO
+
+# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate 
+# file names in lower-case letters. If set to YES upper-case letters are also 
+# allowed. This is useful if you have classes or files whose names only differ 
+# in case and if your file system supports case sensitive file names. Windows 
+# and Mac users are advised to set this option to NO.
+
+CASE_SENSE_NAMES       = YES
+
+# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen 
+# will show members with their full class and namespace scopes in the 
+# documentation. If set to YES the scope will be hidden.
+
+HIDE_SCOPE_NAMES       = NO
+
+# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen 
+# will put a list of the files that are included by a file in the documentation 
+# of that file.
+
+SHOW_INCLUDE_FILES     = YES
+
+# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] 
+# is inserted in the documentation for inline members.
+
+INLINE_INFO            = YES
+
+# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen 
+# will sort the (detailed) documentation of file and class members 
+# alphabetically by member name. If set to NO the members will appear in 
+# declaration order.
+
+SORT_MEMBER_DOCS       = YES
+
+# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the 
+# brief documentation of file, namespace and class members alphabetically 
+# by member name. If set to NO (the default) the members will appear in 
+# declaration order.
+
+SORT_BRIEF_DOCS        = NO
+
+# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the 
+# hierarchy of group names into alphabetical order. If set to NO (the default) 
+# the group names will appear in their defined order.
+
+SORT_GROUP_NAMES       = NO
+
+# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be 
+# sorted by fully-qualified names, including namespaces. If set to 
+# NO (the default), the class list will be sorted only by class name, 
+# not including the namespace part. 
+# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.
+# Note: This option applies only to the class list, not to the 
+# alphabetical list.
+
+SORT_BY_SCOPE_NAME     = NO
+
+# The GENERATE_TODOLIST tag can be used to enable (YES) or 
+# disable (NO) the todo list. This list is created by putting \todo 
+# commands in the documentation.
+
+GENERATE_TODOLIST      = YES
+
+# The GENERATE_TESTLIST tag can be used to enable (YES) or 
+# disable (NO) the test list. This list is created by putting \test 
+# commands in the documentation.
+
+GENERATE_TESTLIST      = YES
+
+# The GENERATE_BUGLIST tag can be used to enable (YES) or 
+# disable (NO) the bug list. This list is created by putting \bug 
+# commands in the documentation.
+
+GENERATE_BUGLIST       = YES
+
+# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or 
+# disable (NO) the deprecated list. This list is created by putting 
+# \deprecated commands in the documentation.
+
+GENERATE_DEPRECATEDLIST= YES
+
+# The ENABLED_SECTIONS tag can be used to enable conditional 
+# documentation sections, marked by \if sectionname ... \endif.
+
+ENABLED_SECTIONS       = 
+
+# The MAX_INITIALIZER_LINES tag determines the maximum number of lines 
+# the initial value of a variable or define consists of for it to appear in 
+# the documentation. If the initializer consists of more lines than specified 
+# here it will be hidden. Use a value of 0 to hide initializers completely. 
+# The appearance of the initializer of individual variables and defines in the 
+# documentation can be controlled using \showinitializer or \hideinitializer 
+# command in the documentation regardless of this setting.
+
+MAX_INITIALIZER_LINES  = 30
+
+# Set the SHOW_USED_FILES tag to NO to disable the list of files generated 
+# at the bottom of the documentation of classes and structs. If set to YES the 
+# list will mention the files that were used to generate the documentation.
+
+SHOW_USED_FILES        = YES
+
+# If the sources in your project are distributed over multiple directories 
+# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy 
+# in the documentation. The default is NO.
+
+SHOW_DIRECTORIES       = NO
+
+# Set the SHOW_FILES tag to NO to disable the generation of the Files page.
+# This will remove the Files entry from the Quick Index and from the 
+# Folder Tree View (if specified). The default is YES.
+
+SHOW_FILES             = YES
+
+# Set the SHOW_NAMESPACES tag to NO to disable the generation of the 
+# Namespaces page.  This will remove the Namespaces entry from the Quick Index
+# and from the Folder Tree View (if specified). The default is YES.
+
+SHOW_NAMESPACES        = YES
+
+# The FILE_VERSION_FILTER tag can be used to specify a program or script that 
+# doxygen should invoke to get the current version for each file (typically from 
+# the version control system). Doxygen will invoke the program by executing (via 
+# popen()) the command <command> <input-file>, where <command> is the value of 
+# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file 
+# provided by doxygen. Whatever the program writes to standard output 
+# is used as the file version. See the manual for examples.
+
+FILE_VERSION_FILTER    = 
+
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+
+# The QUIET tag can be used to turn on/off the messages that are generated 
+# by doxygen. Possible values are YES and NO. If left blank NO is used.
+
+QUIET                  = YES
+
+# The WARNINGS tag can be used to turn on/off the warning messages that are 
+# generated by doxygen. Possible values are YES and NO. If left blank 
+# NO is used.
+
+WARNINGS               = YES
+
+# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings 
+# for undocumented members. If EXTRACT_ALL is set to YES then this flag will 
+# automatically be disabled.
+
+WARN_IF_UNDOCUMENTED   = YES
+
+# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for 
+# potential errors in the documentation, such as not documenting some 
+# parameters in a documented function, or documenting parameters that 
+# don't exist or using markup commands wrongly.
+
+WARN_IF_DOC_ERROR      = YES
+
+# This WARN_NO_PARAMDOC option can be abled to get warnings for 
+# functions that are documented, but have no documentation for their parameters 
+# or return value. If set to NO (the default) doxygen will only warn about 
+# wrong or incomplete parameter documentation, but not about the absence of 
+# documentation.
+
+WARN_NO_PARAMDOC       = NO
+
+# The WARN_FORMAT tag determines the format of the warning messages that 
+# doxygen can produce. The string should contain the $file, $line, and $text 
+# tags, which will be replaced by the file and line number from which the 
+# warning originated and the warning text. Optionally the format may contain 
+# $version, which will be replaced by the version of the file (if it could 
+# be obtained via FILE_VERSION_FILTER)
+
+WARN_FORMAT            = "$file:$line: $text"
+
+# The WARN_LOGFILE tag can be used to specify a file to which warning 
+# and error messages should be written. If left blank the output is written 
+# to stderr.
+
+WARN_LOGFILE           = 
+
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+
+# The INPUT tag can be used to specify the files and/or directories that contain 
+# documented source files. You may enter file names like "myfile.cpp" or 
+# directories like "/usr/src/myproject". Separate the files or directories 
+# with spaces.
+
+INPUT                  = src
+
+# This tag can be used to specify the character encoding of the source files 
+# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is 
+# also the default input encoding. Doxygen uses libiconv (or the iconv built 
+# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for 
+# the list of possible encodings.
+
+INPUT_ENCODING         = UTF-8
+
+# If the value of the INPUT tag contains directories, you can use the 
+# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp 
+# and *.h) to filter out the source-files in the directories. If left 
+# blank the following patterns are tested: 
+# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx 
+# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90
+
+FILE_PATTERNS          = *.h *.c
+
+# The RECURSIVE tag can be used to turn specify whether or not subdirectories 
+# should be searched for input files as well. Possible values are YES and NO. 
+# If left blank NO is used.
+
+RECURSIVE              = YES
+
+# The EXCLUDE tag can be used to specify files and/or directories that should 
+# excluded from the INPUT source files. This way you can easily exclude a 
+# subdirectory from a directory tree whose root is specified with the INPUT tag.
+
+EXCLUDE                = 
+
+# The EXCLUDE_SYMLINKS tag can be used select whether or not files or 
+# directories that are symbolic links (a Unix filesystem feature) are excluded 
+# from the input.
+
+EXCLUDE_SYMLINKS       = NO
+
+# If the value of the INPUT tag contains directories, you can use the 
+# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude 
+# certain files from those directories. Note that the wildcards are matched 
+# against the file with absolute path, so to exclude all test directories 
+# for example use the pattern */test/*
+
+EXCLUDE_PATTERNS       = 
+
+# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names 
+# (namespaces, classes, functions, etc.) that should be excluded from the 
+# output. The symbol name can be a fully qualified name, a word, or if the 
+# wildcard * is used, a substring. Examples: ANamespace, AClass, 
+# AClass::ANamespace, ANamespace::*Test
+
+EXCLUDE_SYMBOLS        = 
+
+# The EXAMPLE_PATH tag can be used to specify one or more files or 
+# directories that contain example code fragments that are included (see 
+# the \include command).
+
+EXAMPLE_PATH           = 
+
+# If the value of the EXAMPLE_PATH tag contains directories, you can use the 
+# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp 
+# and *.h) to filter out the source-files in the directories. If left 
+# blank all files are included.
+
+EXAMPLE_PATTERNS       = 
+
+# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be 
+# searched for input files to be used with the \include or \dontinclude 
+# commands irrespective of the value of the RECURSIVE tag. 
+# Possible values are YES and NO. If left blank NO is used.
+
+EXAMPLE_RECURSIVE      = NO
+
+# The IMAGE_PATH tag can be used to specify one or more files or 
+# directories that contain image that are included in the documentation (see 
+# the \image command).
+
+IMAGE_PATH             = 
+
+# The INPUT_FILTER tag can be used to specify a program that doxygen should 
+# invoke to filter for each input file. Doxygen will invoke the filter program 
+# by executing (via popen()) the command <filter> <input-file>, where <filter> 
+# is the value of the INPUT_FILTER tag, and <input-file> is the name of an 
+# input file. Doxygen will then use the output that the filter program writes 
+# to standard output.  If FILTER_PATTERNS is specified, this tag will be 
+# ignored.
+
+INPUT_FILTER           = 
+
+# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern 
+# basis.  Doxygen will compare the file name with each pattern and apply the 
+# filter if there is a match.  The filters are a list of the form: 
+# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further 
+# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER 
+# is applied to all files.
+
+FILTER_PATTERNS        = 
+
+# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using 
+# INPUT_FILTER) will be used to filter the input files when producing source 
+# files to browse (i.e. when SOURCE_BROWSER is set to YES).
+
+FILTER_SOURCE_FILES    = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to source browsing
+#---------------------------------------------------------------------------
+
+# If the SOURCE_BROWSER tag is set to YES then a list of source files will 
+# be generated. Documented entities will be cross-referenced with these sources. 
+# Note: To get rid of all source code in the generated output, make sure also 
+# VERBATIM_HEADERS is set to NO.
+
+SOURCE_BROWSER         = NO
+
+# Setting the INLINE_SOURCES tag to YES will include the body 
+# of functions and classes directly in the documentation.
+
+INLINE_SOURCES         = NO
+
+# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct 
+# doxygen to hide any special comment blocks from generated source code 
+# fragments. Normal C and C++ comments will always remain visible.
+
+STRIP_CODE_COMMENTS    = YES
+
+# If the REFERENCED_BY_RELATION tag is set to YES 
+# then for each documented function all documented 
+# functions referencing it will be listed.
+
+REFERENCED_BY_RELATION = NO
+
+# If the REFERENCES_RELATION tag is set to YES 
+# then for each documented function all documented entities 
+# called/used by that function will be listed.
+
+REFERENCES_RELATION    = NO
+
+# If the REFERENCES_LINK_SOURCE tag is set to YES (the default)
+# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from
+# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will
+# link to the source code.  Otherwise they will link to the documentstion.
+
+REFERENCES_LINK_SOURCE = YES
+
+# If the USE_HTAGS tag is set to YES then the references to source code 
+# will point to the HTML generated by the htags(1) tool instead of doxygen 
+# built-in source browser. The htags tool is part of GNU's global source 
+# tagging system (see http://www.gnu.org/software/global/global.html). You 
+# will need version 4.8.6 or higher.
+
+USE_HTAGS              = NO
+
+# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen 
+# will generate a verbatim copy of the header file for each class for 
+# which an include is specified. Set to NO to disable this.
+
+VERBATIM_HEADERS       = YES
+
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+
+# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index 
+# of all compounds will be generated. Enable this if the project 
+# contains a lot of classes, structs, unions or interfaces.
+
+ALPHABETICAL_INDEX     = NO
+
+# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then 
+# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns 
+# in which this list will be split (can be a number in the range [1..20])
+
+COLS_IN_ALPHA_INDEX    = 5
+
+# In case all classes in a project start with a common prefix, all 
+# classes will be put under the same header in the alphabetical index. 
+# The IGNORE_PREFIX tag can be used to specify one or more prefixes that 
+# should be ignored while generating the index headers.
+
+IGNORE_PREFIX          = 
+
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_HTML tag is set to YES (the default) Doxygen will 
+# generate HTML output.
+
+GENERATE_HTML          = YES
+
+# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `html' will be used as the default path.
+
+HTML_OUTPUT            = html
+
+# The HTML_FILE_EXTENSION tag can be used to specify the file extension for 
+# each generated HTML page (for example: .htm,.php,.asp). If it is left blank 
+# doxygen will generate files with .html extension.
+
+HTML_FILE_EXTENSION    = .html
+
+# The HTML_HEADER tag can be used to specify a personal HTML header for 
+# each generated HTML page. If it is left blank doxygen will generate a 
+# standard header.
+
+HTML_HEADER            = 
+
+# The HTML_FOOTER tag can be used to specify a personal HTML footer for 
+# each generated HTML page. If it is left blank doxygen will generate a 
+# standard footer.
+
+HTML_FOOTER            = 
+
+# The HTML_STYLESHEET tag can be used to specify a user-defined cascading 
+# style sheet that is used by each HTML page. It can be used to 
+# fine-tune the look of the HTML output. If the tag is left blank doxygen 
+# will generate a default style sheet. Note that doxygen will try to copy 
+# the style sheet file to the HTML output directory, so don't put your own 
+# stylesheet in the HTML output directory as well, or it will be erased!
+
+HTML_STYLESHEET        = 
+
+# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, 
+# files or namespaces will be aligned in HTML using tables. If set to 
+# NO a bullet list will be used.
+
+HTML_ALIGN_MEMBERS     = YES
+
+# If the GENERATE_HTMLHELP tag is set to YES, additional index files 
+# will be generated that can be used as input for tools like the 
+# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) 
+# of the generated HTML documentation.
+
+GENERATE_HTMLHELP      = NO
+
+# If the GENERATE_DOCSET tag is set to YES, additional index files 
+# will be generated that can be used as input for Apple's Xcode 3 
+# integrated development environment, introduced with OSX 10.5 (Leopard). 
+# To create a documentation set, doxygen will generate a Makefile in the 
+# HTML output directory. Running make will produce the docset in that 
+# directory and running "make install" will install the docset in 
+# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find 
+# it at startup.
+
+GENERATE_DOCSET        = NO
+
+# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the 
+# feed. A documentation feed provides an umbrella under which multiple 
+# documentation sets from a single provider (such as a company or product suite) 
+# can be grouped.
+
+DOCSET_FEEDNAME        = "Doxygen generated docs"
+
+# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that 
+# should uniquely identify the documentation set bundle. This should be a 
+# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen 
+# will append .docset to the name.
+
+DOCSET_BUNDLE_ID       = org.doxygen.Project
+
+# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML 
+# documentation will contain sections that can be hidden and shown after the 
+# page has loaded. For this to work a browser that supports 
+# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox 
+# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari).
+
+HTML_DYNAMIC_SECTIONS  = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can 
+# be used to specify the file name of the resulting .chm file. You 
+# can add a path in front of the file if the result should not be 
+# written to the html output directory.
+
+CHM_FILE               = 
+
+# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can 
+# be used to specify the location (absolute path including file name) of 
+# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run 
+# the HTML help compiler on the generated index.hhp.
+
+HHC_LOCATION           = 
+
+# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag 
+# controls if a separate .chi index file is generated (YES) or that 
+# it should be included in the master .chm file (NO).
+
+GENERATE_CHI           = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING
+# is used to encode HtmlHelp index (hhk), content (hhc) and project file
+# content.
+
+CHM_INDEX_ENCODING     = 
+
+# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag 
+# controls whether a binary table of contents is generated (YES) or a 
+# normal table of contents (NO) in the .chm file.
+
+BINARY_TOC             = NO
+
+# The TOC_EXPAND flag can be set to YES to add extra items for group members 
+# to the contents of the HTML help documentation and to the tree view.
+
+TOC_EXPAND             = NO
+
+# The DISABLE_INDEX tag can be used to turn on/off the condensed index at 
+# top of each HTML page. The value NO (the default) enables the index and 
+# the value YES disables it.
+
+DISABLE_INDEX          = NO
+
+# This tag can be used to set the number of enum values (range [1..20]) 
+# that doxygen will group on one line in the generated HTML documentation.
+
+ENUM_VALUES_PER_LINE   = 4
+
+# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index
+# structure should be generated to display hierarchical information.
+# If the tag value is set to FRAME, a side panel will be generated
+# containing a tree-like index structure (just like the one that 
+# is generated for HTML Help). For this to work a browser that supports 
+# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, 
+# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are 
+# probably better off using the HTML help feature. Other possible values 
+# for this tag are: HIERARCHIES, which will generate the Groups, Directories,
+# and Class Hiererachy pages using a tree view instead of an ordered list;
+# ALL, which combines the behavior of FRAME and HIERARCHIES; and NONE, which
+# disables this behavior completely. For backwards compatibility with previous
+# releases of Doxygen, the values YES and NO are equivalent to FRAME and NONE
+# respectively.
+
+GENERATE_TREEVIEW      = NONE
+
+# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be 
+# used to set the initial width (in pixels) of the frame in which the tree 
+# is shown.
+
+TREEVIEW_WIDTH         = 250
+
+# Use this tag to change the font size of Latex formulas included 
+# as images in the HTML documentation. The default is 10. Note that 
+# when you change the font size after a successful doxygen run you need 
+# to manually remove any form_*.png images from the HTML output directory 
+# to force them to be regenerated.
+
+FORMULA_FONTSIZE       = 10
+
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will 
+# generate Latex output.
+
+GENERATE_LATEX         = NO
+
+# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `latex' will be used as the default path.
+
+LATEX_OUTPUT           = latex
+
+# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be 
+# invoked. If left blank `latex' will be used as the default command name.
+
+LATEX_CMD_NAME         = latex
+
+# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to 
+# generate index for LaTeX. If left blank `makeindex' will be used as the 
+# default command name.
+
+MAKEINDEX_CMD_NAME     = makeindex
+
+# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact 
+# LaTeX documents. This may be useful for small projects and may help to 
+# save some trees in general.
+
+COMPACT_LATEX          = NO
+
+# The PAPER_TYPE tag can be used to set the paper type that is used 
+# by the printer. Possible values are: a4, a4wide, letter, legal and 
+# executive. If left blank a4wide will be used.
+
+PAPER_TYPE             = a4wide
+
+# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX 
+# packages that should be included in the LaTeX output.
+
+EXTRA_PACKAGES         = 
+
+# The LATEX_HEADER tag can be used to specify a personal LaTeX header for 
+# the generated latex document. The header should contain everything until 
+# the first chapter. If it is left blank doxygen will generate a 
+# standard header. Notice: only use this tag if you know what you are doing!
+
+LATEX_HEADER           = 
+
+# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated 
+# is prepared for conversion to pdf (using ps2pdf). The pdf file will 
+# contain links (just like the HTML output) instead of page references 
+# This makes the output suitable for online browsing using a pdf viewer.
+
+PDF_HYPERLINKS         = YES
+
+# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of 
+# plain latex in the generated Makefile. Set this option to YES to get a 
+# higher quality PDF documentation.
+
+USE_PDFLATEX           = YES
+
+# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. 
+# command to the generated LaTeX files. This will instruct LaTeX to keep 
+# running if errors occur, instead of asking the user for help. 
+# This option is also used when generating formulas in HTML.
+
+LATEX_BATCHMODE        = NO
+
+# If LATEX_HIDE_INDICES is set to YES then doxygen will not 
+# include the index chapters (such as File Index, Compound Index, etc.) 
+# in the output.
+
+LATEX_HIDE_INDICES     = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output 
+# The RTF output is optimized for Word 97 and may not look very pretty with 
+# other RTF readers or editors.
+
+GENERATE_RTF           = NO
+
+# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `rtf' will be used as the default path.
+
+RTF_OUTPUT             = rtf
+
+# If the COMPACT_RTF tag is set to YES Doxygen generates more compact 
+# RTF documents. This may be useful for small projects and may help to 
+# save some trees in general.
+
+COMPACT_RTF            = NO
+
+# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated 
+# will contain hyperlink fields. The RTF file will 
+# contain links (just like the HTML output) instead of page references. 
+# This makes the output suitable for online browsing using WORD or other 
+# programs which support those fields. 
+# Note: wordpad (write) and others do not support links.
+
+RTF_HYPERLINKS         = NO
+
+# Load stylesheet definitions from file. Syntax is similar to doxygen's 
+# config file, i.e. a series of assignments. You only have to provide 
+# replacements, missing definitions are set to their default value.
+
+RTF_STYLESHEET_FILE    = 
+
+# Set optional variables used in the generation of an rtf document. 
+# Syntax is similar to doxygen's config file.
+
+RTF_EXTENSIONS_FILE    = 
+
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_MAN tag is set to YES (the default) Doxygen will 
+# generate man pages
+
+GENERATE_MAN           = NO
+
+# The MAN_OUTPUT tag is used to specify where the man pages will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `man' will be used as the default path.
+
+MAN_OUTPUT             = doc/man
+
+# The MAN_EXTENSION tag determines the extension that is added to 
+# the generated man pages (default is the subroutine's section .3)
+
+MAN_EXTENSION          = .3
+
+# If the MAN_LINKS tag is set to YES and Doxygen generates man output, 
+# then it will generate one additional man file for each entity 
+# documented in the real man page(s). These additional files 
+# only source the real man page, but without them the man command 
+# would be unable to find the correct page. The default is NO.
+
+MAN_LINKS              = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the XML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_XML tag is set to YES Doxygen will 
+# generate an XML file that captures the structure of 
+# the code including all documentation.
+
+GENERATE_XML           = NO
+
+# The XML_OUTPUT tag is used to specify where the XML pages will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `xml' will be used as the default path.
+
+XML_OUTPUT             = xml
+
+# The XML_SCHEMA tag can be used to specify an XML schema, 
+# which can be used by a validating XML parser to check the 
+# syntax of the XML files.
+
+XML_SCHEMA             = 
+
+# The XML_DTD tag can be used to specify an XML DTD, 
+# which can be used by a validating XML parser to check the 
+# syntax of the XML files.
+
+XML_DTD                = 
+
+# If the XML_PROGRAMLISTING tag is set to YES Doxygen will 
+# dump the program listings (including syntax highlighting 
+# and cross-referencing information) to the XML output. Note that 
+# enabling this will significantly increase the size of the XML output.
+
+XML_PROGRAMLISTING     = YES
+
+#---------------------------------------------------------------------------
+# configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will 
+# generate an AutoGen Definitions (see autogen.sf.net) file 
+# that captures the structure of the code including all 
+# documentation. Note that this feature is still experimental 
+# and incomplete at the moment.
+
+GENERATE_AUTOGEN_DEF   = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_PERLMOD tag is set to YES Doxygen will 
+# generate a Perl module file that captures the structure of 
+# the code including all documentation. Note that this 
+# feature is still experimental and incomplete at the 
+# moment.
+
+GENERATE_PERLMOD       = NO
+
+# If the PERLMOD_LATEX tag is set to YES Doxygen will generate 
+# the necessary Makefile rules, Perl scripts and LaTeX code to be able 
+# to generate PDF and DVI output from the Perl module output.
+
+PERLMOD_LATEX          = NO
+
+# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be 
+# nicely formatted so it can be parsed by a human reader.  This is useful 
+# if you want to understand what is going on.  On the other hand, if this 
+# tag is set to NO the size of the Perl module output will be much smaller 
+# and Perl will parse it just the same.
+
+PERLMOD_PRETTY         = YES
+
+# The names of the make variables in the generated doxyrules.make file 
+# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. 
+# This is useful so different doxyrules.make files included by the same 
+# Makefile don't overwrite each other's variables.
+
+PERLMOD_MAKEVAR_PREFIX = 
+
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor   
+#---------------------------------------------------------------------------
+
+# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will 
+# evaluate all C-preprocessor directives found in the sources and include 
+# files.
+
+ENABLE_PREPROCESSING   = YES
+
+# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro 
+# names in the source code. If set to NO (the default) only conditional 
+# compilation will be performed. Macro expansion can be done in a controlled 
+# way by setting EXPAND_ONLY_PREDEF to YES.
+
+MACRO_EXPANSION        = NO
+
+# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES 
+# then the macro expansion is limited to the macros specified with the 
+# PREDEFINED and EXPAND_AS_DEFINED tags.
+
+EXPAND_ONLY_PREDEF     = NO
+
+# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files 
+# in the INCLUDE_PATH (see below) will be search if a #include is found.
+
+SEARCH_INCLUDES        = YES
+
+# The INCLUDE_PATH tag can be used to specify one or more directories that 
+# contain include files that are not input files but should be processed by 
+# the preprocessor.
+
+INCLUDE_PATH           = 
+
+# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard 
+# patterns (like *.h and *.hpp) to filter out the header-files in the 
+# directories. If left blank, the patterns specified with FILE_PATTERNS will 
+# be used.
+
+INCLUDE_FILE_PATTERNS  = 
+
+# The PREDEFINED tag can be used to specify one or more macro names that 
+# are defined before the preprocessor is started (similar to the -D option of 
+# gcc). The argument of the tag is a list of macros of the form: name 
+# or name=definition (no spaces). If the definition and the = are 
+# omitted =1 is assumed. To prevent a macro definition from being 
+# undefined via #undef or recursively expanded use the := operator 
+# instead of the = operator.
+
+PREDEFINED             = 
+
+# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then 
+# this tag can be used to specify a list of macro names that should be expanded. 
+# The macro definition that is found in the sources will be used. 
+# Use the PREDEFINED tag if you want to use a different macro definition.
+
+EXPAND_AS_DEFINED      = 
+
+# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then 
+# doxygen's preprocessor will remove all function-like macros that are alone 
+# on a line, have an all uppercase name, and do not end with a semicolon. Such 
+# function macros are typically used for boiler-plate code, and will confuse 
+# the parser if not removed.
+
+SKIP_FUNCTION_MACROS   = YES
+
+#---------------------------------------------------------------------------
+# Configuration::additions related to external references   
+#---------------------------------------------------------------------------
+
+# The TAGFILES option can be used to specify one or more tagfiles. 
+# Optionally an initial location of the external documentation 
+# can be added for each tagfile. The format of a tag file without 
+# this location is as follows: 
+#   TAGFILES = file1 file2 ... 
+# Adding location for the tag files is done as follows: 
+#   TAGFILES = file1=loc1 "file2 = loc2" ... 
+# where "loc1" and "loc2" can be relative or absolute paths or 
+# URLs. If a location is present for each tag, the installdox tool 
+# does not have to be run to correct the links.
+# Note that each tag file must have a unique name
+# (where the name does NOT include the path)
+# If a tag file is not located in the directory in which doxygen 
+# is run, you must also specify the path to the tagfile here.
+
+TAGFILES               = 
+
+# When a file name is specified after GENERATE_TAGFILE, doxygen will create 
+# a tag file that is based on the input files it reads.
+
+GENERATE_TAGFILE       = 
+
+# If the ALLEXTERNALS tag is set to YES all external classes will be listed 
+# in the class index. If set to NO only the inherited external classes 
+# will be listed.
+
+ALLEXTERNALS           = NO
+
+# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed 
+# in the modules index. If set to NO, only the current project's groups will 
+# be listed.
+
+EXTERNAL_GROUPS        = YES
+
+# The PERL_PATH should be the absolute path and name of the perl script 
+# interpreter (i.e. the result of `which perl').
+
+PERL_PATH              = /usr/bin/perl
+
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool   
+#---------------------------------------------------------------------------
+
+# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will 
+# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base 
+# or super classes. Setting the tag to NO turns the diagrams off. Note that 
+# this option is superseded by the HAVE_DOT option below. This is only a 
+# fallback. It is recommended to install and use dot, since it yields more 
+# powerful graphs.
+
+CLASS_DIAGRAMS         = YES
+
+# You can define message sequence charts within doxygen comments using the \msc 
+# command. Doxygen will then run the mscgen tool (see 
+# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the 
+# documentation. The MSCGEN_PATH tag allows you to specify the directory where 
+# the mscgen tool resides. If left empty the tool is assumed to be found in the 
+# default search path.
+
+MSCGEN_PATH            = 
+
+# If set to YES, the inheritance and collaboration graphs will hide 
+# inheritance and usage relations if the target is undocumented 
+# or is not a class.
+
+HIDE_UNDOC_RELATIONS   = YES
+
+# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is 
+# available from the path. This tool is part of Graphviz, a graph visualization 
+# toolkit from AT&T and Lucent Bell Labs. The other options in this section 
+# have no effect if this option is set to NO (the default)
+
+HAVE_DOT               = YES
+
+# By default doxygen will write a font called FreeSans.ttf to the output 
+# directory and reference it in all dot files that doxygen generates. This 
+# font does not include all possible unicode characters however, so when you need 
+# these (or just want a differently looking font) you can specify the font name 
+# using DOT_FONTNAME. You need need to make sure dot is able to find the font, 
+# which can be done by putting it in a standard location or by setting the 
+# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory 
+# containing the font.
+
+DOT_FONTNAME           = FreeSans
+
+# By default doxygen will tell dot to use the output directory to look for the 
+# FreeSans.ttf font (which doxygen will put there itself). If you specify a 
+# different font using DOT_FONTNAME you can set the path where dot 
+# can find it using this tag.
+
+DOT_FONTPATH           = 
+
+# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen 
+# will generate a graph for each documented class showing the direct and 
+# indirect inheritance relations. Setting this tag to YES will force the 
+# the CLASS_DIAGRAMS tag to NO.
+
+CLASS_GRAPH            = YES
+
+# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen 
+# will generate a graph for each documented class showing the direct and 
+# indirect implementation dependencies (inheritance, containment, and 
+# class references variables) of the class with other documented classes.
+
+COLLABORATION_GRAPH    = YES
+
+# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen 
+# will generate a graph for groups, showing the direct groups dependencies
+
+GROUP_GRAPHS           = YES
+
+# If the UML_LOOK tag is set to YES doxygen will generate inheritance and 
+# collaboration diagrams in a style similar to the OMG's Unified Modeling 
+# Language.
+
+UML_LOOK               = NO
+
+# If set to YES, the inheritance and collaboration graphs will show the 
+# relations between templates and their instances.
+
+TEMPLATE_RELATIONS     = NO
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT 
+# tags are set to YES then doxygen will generate a graph for each documented 
+# file showing the direct and indirect include dependencies of the file with 
+# other documented files.
+
+INCLUDE_GRAPH          = NO
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and 
+# HAVE_DOT tags are set to YES then doxygen will generate a graph for each 
+# documented header file showing the documented files that directly or 
+# indirectly include this file.
+
+INCLUDED_BY_GRAPH      = NO
+
+# If the CALL_GRAPH and HAVE_DOT options are set to YES then 
+# doxygen will generate a call dependency graph for every global function 
+# or class method. Note that enabling this option will significantly increase 
+# the time of a run. So in most cases it will be better to enable call graphs 
+# for selected functions only using the \callgraph command.
+
+CALL_GRAPH             = NO
+
+# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then 
+# doxygen will generate a caller dependency graph for every global function 
+# or class method. Note that enabling this option will significantly increase 
+# the time of a run. So in most cases it will be better to enable caller 
+# graphs for selected functions only using the \callergraph command.
+
+CALLER_GRAPH           = NO
+
+# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen 
+# will graphical hierarchy of all classes instead of a textual one.
+
+GRAPHICAL_HIERARCHY    = YES
+
+# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES 
+# then doxygen will show the dependencies a directory has on other directories 
+# in a graphical way. The dependency relations are determined by the #include
+# relations between the files in the directories.
+
+DIRECTORY_GRAPH        = YES
+
+# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images 
+# generated by dot. Possible values are png, jpg, or gif
+# If left blank png will be used.
+
+DOT_IMAGE_FORMAT       = png
+
+# The tag DOT_PATH can be used to specify the path where the dot tool can be 
+# found. If left blank, it is assumed the dot tool can be found in the path.
+
+DOT_PATH               = 
+
+# The DOTFILE_DIRS tag can be used to specify one or more directories that 
+# contain dot files that are included in the documentation (see the 
+# \dotfile command).
+
+DOTFILE_DIRS           = 
+
+# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of 
+# nodes that will be shown in the graph. If the number of nodes in a graph 
+# becomes larger than this value, doxygen will truncate the graph, which is 
+# visualized by representing a node as a red box. Note that doxygen if the 
+# number of direct children of the root node in a graph is already larger than 
+# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note 
+# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.
+
+DOT_GRAPH_MAX_NODES    = 50
+
+# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the 
+# graphs generated by dot. A depth value of 3 means that only nodes reachable 
+# from the root by following a path via at most 3 edges will be shown. Nodes 
+# that lay further from the root node will be omitted. Note that setting this 
+# option to 1 or 2 may greatly reduce the computation time needed for large 
+# code bases. Also note that the size of a graph can be further restricted by 
+# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction.
+
+MAX_DOT_GRAPH_DEPTH    = 0
+
+# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent 
+# background. This is enabled by default, which results in a transparent 
+# background. Warning: Depending on the platform used, enabling this option 
+# may lead to badly anti-aliased labels on the edges of a graph (i.e. they 
+# become hard to read).
+
+DOT_TRANSPARENT        = YES
+
+# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output 
+# files in one run (i.e. multiple -o and -T options on the command line). This 
+# makes dot run faster, but since only newer versions of dot (>1.8.10) 
+# support this, this feature is disabled by default.
+
+DOT_MULTI_TARGETS      = NO
+
+# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will 
+# generate a legend page explaining the meaning of the various boxes and 
+# arrows in the dot generated graphs.
+
+GENERATE_LEGEND        = YES
+
+# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will 
+# remove the intermediate dot files that are used to generate 
+# the various graphs.
+
+DOT_CLEANUP            = YES
+
+#---------------------------------------------------------------------------
+# Configuration::additions related to the search engine   
+#---------------------------------------------------------------------------
+
+# The SEARCHENGINE tag specifies whether or not a search engine should be 
+# used. If set to NO the values of all tags below this one will be ignored.
+
+SEARCHENGINE           = NO
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/doc/evsql.dox	Sun Mar 08 01:33:45 2009 +0200
@@ -0,0 +1,83 @@
+/**
+@mainpage evsql
+@author Tero Marttila
+
+@section introduction Introduction
+Evsql is a C-language SQL library designed for use with <a href="http://monkey.org/~provos/libevent/">libevent</a>, 
+and primarily <a href="http://www.postgresql.org/">PostgreSQL</a>'s <a href="http://www.postgresql.org/docs/8.3/static/libpq.html">libpq</a>.
+
+Evsql was born as a result of wanting to use a SQL database from within a libevent application, and discovering
+libpq's asynchronous API. Since the libpq API is somewhat cumbersome to use, I wrote a separate interface that
+drives libpq using libevent and makes writing asynchronous SQL clients a lot easier - plus adding some conveniance
+for parametrized queries and such along the way.
+
+The evsql.h API doesn't expose the underlying database library's API, although since the only currently existing
+implementation is libpq, this should really be thought of as a generically-named PostgreSQL library rather than a
+database-agnostic API...
+
+@section usage Usage
+Include the top-level evsql.h header, making sure you also have the evpq and lib modules available.
+
+@section connecting Connecting
+Evsql sessions are represented using an opaque struct, called simply evsql. Use the \ref evsql_ "evsql_new_*" function
+corresponding to your database engine (PostgreSQL -> evsql_new_pq()) to allocate this handle. It is valid for use
+immediately, although the initial connection may not yet be complete.
+
+There is an evsql_close() function, but it is currently not implemented.
+
+@see \ref evsql_new_
+
+@section transactions Transactions
+Evsql supports both non-transactional queries and transactional queries. A evsql_trans is allocated its own dedicated
+connection which it can use for its queries without being interfered by other queries/transactions. Evsql takes care of
+sending the initial "BEGIN TRANSACTION" query, and provides evsql_trans_commit()/evsql_trans_abort() functions to send the
+"COMMIT TRANSACTION" and "ROLLBACK TRANSACTION" queries.
+
+@see evsql_trans()
+@see \ref evsql_trans_
+
+@section queries Querying
+There is a single evsql_query() function used for both transactional and non-transactional queries; you can pass NULL
+as the \a trans argument.
+
+The given evsql_query_cb() callback function is invoked once the query has been processed and the evsql_result is
+available, or the query failed.
+
+The important distinction between transactional and non-transactional queries is that transactions only support one
+outstanding query at a time, meaning that you must wait for your callback to be invoked before calling evsql_query()
+again for the transaction. Non-transactional queries are sent using an idle connection, and will be enqueued for later
+execution if no idle connections are available.
+
+evsql_query() returns an evsql_query handle that can be passed to evsql_query_abort() to abort the query, ensuring
+that the evsql_query_cb() given to evsql_query() is not invoked, and any associated resources released.
+
+@see evsql_query()
+@see \ref evsql_query_
+
+@section param_queries Parametrized Queries
+Evsql also provides functions to send parametrized queries, the behaviour of evsql_query explained above applies as
+well. 
+
+The first of these is evsql_query_params(), which takes the parametrized SQL command and a evsql_query_params containing the
+parameter types and values as arguments.
+
+The second of these is evsql_query_exec(), which takes a evsql_query_info struct containing the parametrized SQL command
+and the parameter types, and the parameter values themselves as a list of variable arguments (of the correct type!).
+
+@see \ref evsql_query_
+@see \ref evsql_param_
+
+@section query_results Query Results
+Once a evsql_query completes (sucess or failure, unless the query/transaction is aborted), the query's evsql_query_cb() is
+called. It receives a evsql_result handle, which can then be used with the \ref evsql_result_ "result interface" to
+get information about the number of rows returned, access induvidual fields, iterate over the rows, etc. It is
+important to note that the query callback is responsible for releasing the evsql_result using evsql_result_free() (or
+equivalent) once it is done with it.
+
+@see evsql_query_cb
+@see \ref evsql_result_
+
+@section API Reference
+The entire API is defined in the top-level evsql.h header, divided into various groups.
+
+*/
--- a/include/evsql.h	Sun Mar 08 01:16:54 2009 +0200
+++ b/include/evsql.h	Sun Mar 08 01:33:45 2009 +0200
@@ -1,32 +1,93 @@
 #ifndef EVSQL_H
 #define EVSQL_H
 
-/*
- * An event-based (Postgre)SQL client API using libevent
+/**
+ * @file src/evsql.h
+ *
+ * A SQL library designed for use with libevent and PostgreSQL's libpq. Provides support for queueing non-transactional
+ * requests, transaction support, parametrized queries and result iteration.
+ *
+ * Currently, the API does not expose the underlying libpq data structures, but since it is currently the only
+ * underlying implementation, there is no guarantee that the same API will actually work with other databases' interface
+ * libraries...
+ *
+ * The order of function calls and callbacks goes something like this:
+ *
+ *  -   evsql_new_pq()
+ *
+ *  -   evsql_trans()
+ *      -   evsql_trans_abort()
+ *      -   evsql_trans_error_cb()
+ *      -   evsql_trans_ready_cb()
+ *
+ *  -   evsql_query(), \ref evsql_param_ + evsql_query_params(), evsql_query_exec()
+ *      -   evsql_query_abort()
+ *      -   evsql_query_cb()
+ *          -   \ref evsql_result_
+ *          -   evsql_result_free()
+ *
+ *  -   evsql_trans_commit()
+ *      -   evsql_trans_done_cb()
+ *
  */
 
-// XXX: libpq
+/**
+ * System includes
+ */
 #include <stdint.h>
-#include <postgresql/libpq-fe.h>
+#include <stdbool.h>
 #include <event2/event.h>
 
-/*
- * The generic context handle
+/**
+ * XXX: err_t
+ */
+#ifndef LIB_ERR_H
+#define LIB_ERR_H
+#include <errno.h>
+typedef unsigned int err_t;
+#endif
+
+/**
+ * @struct evsql
+ *
+ * The generic session handle used to manage a single "database connector" with multiple queries/transactions.
+ *
+ * @see \ref evsql_
  */
 struct evsql;
 
-/*
- * A query handle
+/**
+ * @struct evsql_trans
+ *
+ * Opaque transaction handle returned by evsql_trans() and used for the \ref evsql_query_ functions
+ *
+ * @see \ref evsql_trans_
+ */
+struct evsql_trans;
+
+/**
+ * @struct evsql_query
+ *
+ * Opaque query handle returned by the \ref evsql_query_ functions and used for evsql_query_abort()
+ *
+ * @see \ref evsql_query_
  */
 struct evsql_query;
 
-/*
- * Transaction handle
+/**
+ * @struct evsql_result
+ *
+ * Opaque result handle received by evsql_query_cb(), and used with the \ref evsql_result_ functions
+ *
+ * @see evsql_query_cb
+ * @see \ref evsql_result_
  */
-struct evsql_trans;
+struct evsql_result;
 
-/*
- * Transaction type
+/**
+ * Various transaction isolation levels for conveniance
+ *
+ * @see evsql_trans
  */
 enum evsql_trans_type {
     EVSQL_TRANS_DEFAULT,
@@ -36,241 +97,721 @@
     EVSQL_TRANS_READ_UNCOMMITTED,
 };
 
-/*
- * Parameter type
+/**
+ * An item can be in different formats, the classical text-based format (i.e. snprintf "1234") or a more low-level
+ * binary format (i.e uint16_t 0x04F9 in network-byte order).
  */
-enum evsql_param_format {
+enum evsql_item_format {
+    /** Format values as text strings */
     EVSQL_FMT_TEXT,
+
+    /** Type-specific binary encoding */
     EVSQL_FMT_BINARY,
 };
 
-enum evsql_param_type {
-    EVSQL_PARAM_INVALID,
-
-    EVSQL_PARAM_NULL_,
+/**
+ * An item has a specific type, these correspond somewhat to the native database types.
+ */
+enum evsql_item_type {
+    /** End marker, zero */
+    EVSQL_TYPE_INVALID,
     
-    EVSQL_PARAM_BINARY,
-    EVSQL_PARAM_STRING,
-    EVSQL_PARAM_UINT16,
-    EVSQL_PARAM_UINT32,
-    EVSQL_PARAM_UINT64,
+    /** A SQL NULL */
+    EVSQL_TYPE_NULL_,
+    
+    /** A `struct evsql_item_binary` */
+    EVSQL_TYPE_BINARY,
+
+    /** A NUL-terminated char* */
+    EVSQL_TYPE_STRING,
+
+    /** A uint16_t value */
+    EVSQL_TYPE_UINT16,
+
+    /** A uint32_t value */
+    EVSQL_TYPE_UINT32,
+
+    /** A uint64_t value */
+    EVSQL_TYPE_UINT64,
+
+    EVSQL_TYPE_MAX
 };
 
-/*
- * Query parameter info.
+/**
+ * Value for use with EVSQL_TYPE_BINARY, this just a non-NUL-terminated char* and an explicit length
+ */
+struct evsql_item_binary {
+    /** The binary data */
+    const char *ptr;
+
+    /** Number of bytes pointed to by ptr */
+    size_t len;
+};
+
+/**
+ * Metadata about the format and type of an item, this does not hold any actual value.
+ */
+struct evsql_item_info {
+    /** The format */
+    enum evsql_item_format format;
+    
+    /** The type type */
+    enum evsql_item_type type;
+
+    /** Various flags */
+    struct evsql_item_flags {
+        /** The value may be NULL @see evsql_result_next */
+        bool null_ok : 1;
+    } flags;
+};
+
+/**
+ * An union to provide storage for the values of small types
  *
- * Use the EVSQL_PARAM_* macros to define the value of list
+ * @see evsql_item
+ */
+union evsql_item_value {
+    /** 16-bit unsigned integer */
+    uint16_t uint16;
+
+    /** 32-bit unsigned integer */
+    uint32_t uint32;
+
+    /** 64-bit unsigned integer */
+    uint64_t uint64;
+};
+
+/**
+ * A generic structure containing the type and value of a query parameter or a result field.
+ *
+ * @see evsql_query_info
+ * @see evsql_query_params
+ * @see evsql_result_info
+ */
+struct evsql_item {
+    /** The "header" containing the type and format */
+    struct evsql_item_info info;
+
+    /**
+     * Pointer to the raw databytes. 
+     * Set to NULL for SQL NULLs, otherwise &value or an external buf 
+     */
+    const char *bytes;
+
+    /**
+     * Size of the byte array pointed to by bytes, zero for EVSQL_FMT_TEXT data.
+     */
+    size_t length;
+
+    /**
+     * Inline storage for small values
+     */
+    union evsql_item_value value;
+    
+    /** Internal flags */
+    struct {
+        /**
+         * The item has a value stored in `value`
+         */
+        bool has_value : 1;
+    } flags;
+};
+
+/**
+ * Query meta-info, similar to a prepared statement.
+ *
+ * Contains the literal SQL query and the types of the parameters, but no more.
+ *
+ * @see evsql_query_exec
+ */
+struct evsql_query_info {
+    /** The SQL query itself */
+    const char *sql;
+
+    /** 
+     * A variable-length array of the item_info parameters, terminated by an EVSQL_TYPE_INVALID entry.
+     */
+    struct evsql_item_info params[];
+};
+
+/**
+ * Contains the query parameter types and their actual values
+ *
+ * @see evsql_query_params
  */
 struct evsql_query_params {
-    // nonzero to get results in binary format
-    enum evsql_param_format result_fmt;
+    /** Requested result format for this query. XXX: move elsewhere */
+    enum evsql_item_format result_format;
     
-    // the list of parameters, terminated by { 0, 0 }
-    struct evsql_query_param {
-        // the param type
-        enum evsql_param_type type;
-        
-        // pointer to the raw data
-        const char *data_raw;
-        
-        // the value
-        union {
-            uint16_t uint16;
-            uint32_t uint32;
-            uint64_t uint64;
-        } data;
-
-        // the explicit length of the parameter if it's binary, zero for text.
-        // set to -1 to indicate that the value is still missing
-        ssize_t length;
-    } list[];
+    /**
+     * A variable-length array of the item parameter-values, terminated by an EVSQL_TYPE_INVALID entry.
+     */
+    struct evsql_item list[];
 };
 
-// macros for defining evsql_query_params
-#define EVSQL_PARAMS(result_fmt)            { result_fmt, 
-#define EVSQL_PARAM(typenam)                    { EVSQL_PARAM_ ## typenam, NULL }
-#define EVSQL_PARAMS_END                        { EVSQL_PARAM_INVALID, NULL } \
-                                              } // <<<
-
-/*
- * Result type
+/**
+ * Result layout metadata. This contains the stucture needed to decode result rows.
+ *
+ * @see evsql_result_begin
  */
 struct evsql_result_info {
-    struct evsql *evsql;
-    struct evsql_trans *trans;
-    
-    int error;
+    /** XXX: make up something useful to stick here */
+    int _unused;
 
-    union evsql_result {
-        // libpq
-        PGresult *pq;
-    } result;
+    /**
+     * A variable-length array of the item_info column types.
+     */
+    struct evsql_item_info columns[];
 };
 
-/*
+/**
+ * Magic macros for defining param/result info -lists
+ *  
+ * @code
+ *  static struct evsql_query_params params = EVSQL_PARAMS(EVSQL_FMT_BINARY) {
+ *      EVSQL_PARAM( UINT32 ),
+ *      ...,
+ *
+ *      EVSQL_PARAMS_END
+ *  };
+ * @endcode
+ *
+ * @name EVSQL_TYPE/PARAM_*
+ * @{
+ */
+
+/**
+ * A `struct evsql_item_info` initializer, using FMT_BINARY and the given EVSQL_TYPE_ -suffix.
+ *
+ * @param typenam the suffix of an evsql_item_type name
+ *
+ * @see struct evsql_item_info
+ * @see enum evsql_item_type
+ */
+#define EVSQL_TYPE(typenam)                     { EVSQL_FMT_BINARY, EVSQL_TYPE_ ## typenam  }
+
+/**
+ * End marker for a `struct evsql_item_info` array.
+ *
+ * @see struct evsql_item_info
+ */
+#define EVSQL_TYPE_END                          { EVSQL_FMT_BINARY, EVSQL_TYPE_INVALID      }
+
+/**
+ * Initializer block for an evsql_query_params struct
+ */
+#define EVSQL_PARAMS(result_fmt)            { result_fmt, 
+
+/**
+ * An evsql_item initializer
+ */
+#define EVSQL_PARAM(typenam)                    { EVSQL_TYPE(typenam) }
+
+/**
+ * Include the ending item and terminate the pseudo-block started using #EVSQL_PARAMS
+ */
+#define EVSQL_PARAMS_END                        { EVSQL_TYPE_END } \
+                                              } // <<<
+
+// @}
+
+/**
+ * Callback definitions
+ *
+ * @name evsql_*_cb
+ * @{
+ */
+
+/**
  * Callback for handling query results.
  *
- * The query has completed, either succesfully or unsuccesfully (nonzero .error).
+ * The query has completed, either succesfully or unsuccesfully.
  *
- * Use the evsql_result_* functions to manipulate the results.
+ * Use the \ref evsql_result_ functions to manipulate the results, and call evsql_result_free() (or equivalent) once done.
+ *
+ * @param res The result handle that must be result_free'd after use
+ * @param arg The void* passed to \ref evsql_query_
+ *
+ * @see evsql_query
  */
-typedef void (*evsql_query_cb)(const struct evsql_result_info *res, void *arg);
+typedef void (*evsql_query_cb)(struct evsql_result *res, void *arg);
 
-/*
+/**
  * Callback for handling global-level errors.
  *
  * The evsql is not useable anymore.
  *
- * XXX: this is not actually called yet, no retry logic implemented.
+ * XXX: this is not actually called yet, as no retry logic is implemented, so an evsql itself never fails.
+ *
+ * @see evsql_new_pq
  */
 typedef void (*evsql_error_cb)(struct evsql *evsql, void *arg);
 
-/*
- * Callback for handling transaction-level errors.
+/**
+ * Callback for handling transaction-level errors. This may be called at any time during a transaction's lifetime,
+ * including from within the \ref evsql_query_ functions (but not always).
  *
  * The transaction is not useable anymore.
+ *
+ * @param trans the transaction in question
+ * @param arg the void* passed to evsql_trans
+ *
+ * @see evsql_trans
  */
 typedef void (*evsql_trans_error_cb)(struct evsql_trans *trans, void *arg);
 
-/*
- * The transaction is ready for use.
+/**
+ * Callback for handling evsql_trans/evsql_query_abort completion. The transaction is ready for use with \ref evsql_query_.
+ *
+ * @param trans the transaction in question
+ * @param arg the void* passed to evsql_trans
+ *
+ * @see evsql_trans
+ * @see evsql_query_abort
  */
 typedef void (*evsql_trans_ready_cb)(struct evsql_trans *trans, void *arg);
 
-/*
- * The transaction was commited, and should not be used anymore.
+/**
+ * Callback for handling evsql_trans_commit completion. The transaction was commited, and should not be used anymore.
+ *
+ * @param trans the transaction in question
+ * @param arg the void* passed to evsql_trans
+ *
+ * @see evsql_trans
+ * @see evsql_trans_commit
  */
 typedef void (*evsql_trans_done_cb)(struct evsql_trans *trans, void *arg);
 
-/*
- * Create a new PostgreSQL/libpq(evpq) -based evsql using the given conninfo.
- *
- * The given conninfo must stay valid for the duration of the evsql's lifetime.
- */
-struct evsql *evsql_new_pq (struct event_base *ev_base, const char *pq_conninfo, evsql_error_cb error_fn, void *cb_arg);
+// @}
 
-/*
- * Create a new transaction.
- *
- * Transactions are separate connections that provide transaction-isolation.
+/**
+ * Session functions
  *
- * Once the transaction is ready for use, ready_fn will be called. If the transaction fails, any pending query will be
- * forgotten, and error_fn called. This also includes some (but not all) cases where evsql_query returns nonzero.
+ * @defgroup evsql_* Session interface
+ * @see evsql.h
+ * @{
+ */
+
+/**
+ * Session creation functions
  *
+ * @defgroup evsql_new_* Session creation interface
+ * @see evsql.h
+ * @{
  */
-struct evsql_trans *evsql_trans (struct evsql *evsql, enum evsql_trans_type type, evsql_trans_error_cb error_fn, evsql_trans_ready_cb ready_fn, evsql_trans_done_cb done_fn, void *cb_arg);
 
-/*
+/**
+ * Create a new PostgreSQL/libpq (evpq) -based evsql using the given conninfo.
+ *
+ * The given \a pq_conninfo pointer must stay valid for the duration of the evsql's lifetime.
+ *
+ * See the libpq reference manual for the syntax of pq_conninfo
+ *
+ * @param ev_base the libevent base to use
+ * @param pq_conninfo the libpq connection information
+ * @param error_fn XXX: not used, may be NULL
+ * @param cb_arg: XXX: not used, argument for error_fn
+ * @return the evsql context handle for use with other functions
+ */
+struct evsql *evsql_new_pq (struct event_base *ev_base, const char *pq_conninfo, 
+    evsql_error_cb error_fn, 
+    void *cb_arg
+);
+
+// @}
+
+/**
+ * Close a connection. Callbacks for waiting queries will not be run.
+ *
+ * XXX: not implemented yet.
+ *
+ * @param evsql the context handle from \ref evsql_new_
+ */
+void evsql_close (struct evsql *evsql);
+
+// @}
+
+/**
+ * Query API
+ *
+ * @defgroup evsql_query_* Query interface
+ * @see evsql.h
+ * @{
+ */
+
+/**
  * Queue the given query for execution.
  *
- * If trans is specified (not NULL), then the transaction must be idle, and the query will be executed in that
- * transaction's context. Otherwise, the query will be executed without a transaction, andmay be executed immediately,
- * or if other similar queries are running, it will be queued for later execution.
+ * If \a trans is given (i.e. not NULL), then the transaction must be idle, and the query will be executed in that
+ * transaction's context. Otherwise, the query will be executed without a transaction using an idle connection, or
+ * enqueued for later execution.
  *
- * Once the query is complete (got a result, got an error, the connection failed), then the query_cb will be triggered.
+ * Once the query is complete (got a result, got an error, the connection failed), then \a query_fn will be called.
+ * The callback can use the \ref evsql_result_ functions to manipulate the query results.
+ *
+ * The returned evsql_query handle can be passed to evsql_query_abort at any point before \a query_fn being called. 
+ *
+ * @param evsql the context handle from \ref evsql_new_
+ * @param trans the optional transaction handle from evsql_trans
+ * @param command the raw SQL command itself
+ * @param query_fn the evsql_query_cb() to call once the query is complete
+ * @param cb_arg the void* passed to the above
+ * @return the evsql_query handle that can be used to abort the query
  */
 struct evsql_query *evsql_query (struct evsql *evsql, struct evsql_trans *trans, const char *command, evsql_query_cb query_fn, void *cb_arg);
 
-/*
- * Same as evsql_query, but uses the SQL-level support for binding parameters.
+/**
+ * Execute the given SQL query using the list of parameter types/values given via evsql_query_params.
+ *
+ * Use the EVSQL_PARAMS macros to declare \a params, and the \ref evsql_param_ functions to populate the values.
+ *
+ * See evsql_query() for more info about behaviour.
+ *
+ * See the <a href="http://www.postgresql.org/docs/8.3/static/libpq-exec.html#LIBPQ-EXEC-MAIN">libpq PQexecParams tip</a>
+ * for the parameter syntax to use.
+ *
+ * @param evsql the context handle from \ref evsql_new_
+ * @param trans the optional transaction handle from evsql_trans
+ * @param command the SQL command to bind the parameters to
+ * @param params the parameter types and values
+ * @param query_fn the evsql_query_cb() to call once the query is complete
+ * @param cb_arg the void* passed to the above
+ * @see evsql_query
  */
-struct evsql_query *evsql_query_params (struct evsql *evsql, struct evsql_trans *trans, const char *command, const struct evsql_query_params *params, evsql_query_cb query_fn, void *cb_arg);
+struct evsql_query *evsql_query_params (struct evsql *evsql, struct evsql_trans *trans, 
+    const char *command, const struct evsql_query_params *params, 
+    evsql_query_cb query_fn, void *cb_arg
+);
 
-/*
- * Abort a query, the query callback will not be called, the query and any possible results will be discarded.
+/**
+ * Execute the given \a query_info's SQL query with the values given as variable arguments, using the \a query_info to
+ * resolve the types.
  *
- * This does not garuntee that the query will not execute, simply that you won't get the results.
+ * See evsql_query() for more info about behaviour.
  *
- * If the query is part of a transaction, then trans must be given, and the query must be the query that is currently
- * executing on that trans. The transaction's ready_fn will be called once the query has been aborted.
+ * @param evsql the context handle from \ref evsql_new_
+ * @param trans the optional transaction handle from evsql_trans
+ * @param query_info the SQL query information
+ * @param query_fn the evsql_query_cb() to call once the query is complete
+ * @param cb_arg the void* passed to the above
+ * @see evsql_query
+ */
+struct evsql_query *evsql_query_exec (struct evsql *evsql, struct evsql_trans *trans, 
+    const struct evsql_query_info *query_info,
+    evsql_query_cb query_fn, void *cb_arg,
+    ...
+);
+
+/**
+ * Abort a \a query returned by \ref evsql_query_ that has not yet completed (query_fn has not been called yet).
+ *
+ * The actual query itself may or may not be aborted (and hence may or may not be executed on the server), but \a query_fn
+ * will not be called anymore, and the query will dispose of itself and any results returned.
+ *
+ * If the \a query is part of a transaction, then \a trans must be given, and the query must be the query that is currently
+ * executing on that trans. The transaction's \a ready_fn will be called once the query has been aborted and the
+ * transaction is now idle again.
+ *
+ * @param trans if the query is part of a transaction, then it MUST be given here
+ * @param query the in-progress query to abort
  */
 void evsql_query_abort (struct evsql_trans *trans, struct evsql_query *query);
 
-/*
- * Commit a transaction, calling done_fn if it was succesfull (error_fn otherwise).
+/**
+ * Print out a textual dump of the given \a sql query and \a params using DEBUG
  *
- * trans must be idle, just like for evsql_query.
+ * @param sql the SQL query command
+ * @param params the list of parameter types and values
+ */
+void evsql_query_debug (const char *sql, const struct evsql_query_params *params);
+
+// @}
+
+/**
+ * Transaction API
  *
- * done_fn will never be called directly, always via the event loop.
+ * @defgroup evsql_trans_* Transaction interface
+ * @see evsql.h
+ * @{
+ */
+
+/**
+ * Create a new transaction.
  *
- * You cannot abort a COMMIT, calling trans_abort on trans after a succesful trans_commit is a FATAL error.
+ * A transaction will be allocated its own connection, and the "BEGIN TRANSACTION ..." query will be sent (use the
+ * \a type argument to specify this). 
+ *
+ * Once the transaction has been opened, the given \a ready_fn will be triggered, and the transaction can then
+ * be used (see \ref evsql_query_).
+ *
+ * If, at any point, the transaction-connection fails, any pending query will be forgotten (i.e. the query callback
+ * will NOT be called), and the given \a error_fn will be called. Note that this includes some, but not all,
+ * cases where \ref evsql_query_ returns an error.
+ *
+ * Once you are done with the transaction, call either evsql_trans_commit() or evsql_trans_abort().
+ *
+ * @param evsql the context handle from \ref evsql_new_
+ * @param type the type of transaction to create
+ * @param error_fn the evsql_trans_error_cb() to call if this transaction fails
+ * @param ready_fn the evsql_trans_ready_cb() to call once this transaction is ready for use
+ * @param done_fn the evsql_trans_done_cb() to call once this transaction has been commmited
+ * @param cb_arg the void* to pass to the above
+ * @return the evsql_trans handle for use with other functions
+ */
+struct evsql_trans *evsql_trans (struct evsql *evsql, enum evsql_trans_type type, 
+    evsql_trans_error_cb error_fn, 
+    evsql_trans_ready_cb ready_fn, 
+    evsql_trans_done_cb done_fn, 
+    void *cb_arg
+);
+
+/**
+ * Commit a transaction using "COMMIT TRANSACTION".
+ *
+ * The transaction must be idle, just like for evsql_query. Once the transaction has been commited, the transaction's
+ * \a done_fn will be called, after which the transaction must not be used anymore.
+ *
+ * You cannot abort a COMMIT, calling trans_abort() on trans after a succesful trans_commit is an error.
+ *
+ * Note that \a done_fn will never be called directly, always indirectly via the event loop.
+ *
+ * @param trans the transaction handle from evsql_trans to commit
+ * @see evsql_trans
  */
 int evsql_trans_commit (struct evsql_trans *trans);
 
-/*
- * Abort a transaction, rolling it back. No callbacks will be called.
+/**
+ * Abort a transaction, using "ROLLBACK TRANSACTION".
  *
- * You cannot abort a COMMIT, calling trans_abort on trans after a succesful trans_commit is a FATAL error.
+ * No more transaction callbacks will be called. If there was a query running, it will be aborted, and the transaction
+ * then rollback'd.
+ *
+ * You cannot abort a COMMIT, calling trans_abort on \a trans after a call to trans_commit is an error.
+ * 
+ * Do not call evsql_trans_abort from within evsql_trans_error_cb()!
+ *
+ * @param trans the transaction from evsql_trans to abort
+ * @see evsql_trans
  */
 void evsql_trans_abort (struct evsql_trans *trans);
 
-/*
- * Transaction-handling functions
+/** 
+ * Retrieve the transaction-specific error message from the underlying engine.
+ *
+ * Intended to be called from evsql_trans_error_cb()
  */
-
-// error string, meant to be called from evsql_trans_error_cb
 const char *evsql_trans_error (struct evsql_trans *trans);
 
-/*
- * Param-building functions
- */
-int evsql_param_binary (struct evsql_query_params *params, size_t param, const char *ptr, size_t len);
-int evsql_param_string (struct evsql_query_params *params, size_t param, const char *ptr);
-int evsql_param_uint16 (struct evsql_query_params *params, size_t param, uint16_t uval);
-int evsql_param_uint32 (struct evsql_query_params *params, size_t param, uint32_t uval);
-int evsql_param_null   (struct evsql_query_params *params, size_t param);
-int evsql_params_clear (struct evsql_query_params *params);
+// @}
 
-/*
- * Query-handling functions
- */
-
-// print out a textual repr of the given query/params via DEBUG
-void evsql_query_debug (const char *sql, const struct evsql_query_params *params);
-
-/*
- * Result-handling functions
+/**
+ * Parameter-building functions.
+ *
+ * These manipulate the value of the given parameter index.
+ *
+ * @defgroup evsql_param_* Parameter interface
+ * @see evsql.h
+ * @{
  */
 
-// get error message associated with function
-const char *evsql_result_error (const struct evsql_result_info *res);
-
-// number of rows in the result
-size_t evsql_result_rows (const struct evsql_result_info *res);
-
-// number of columns in the result
-size_t evsql_result_cols (const struct evsql_result_info *res);
-
-// number of affected rows for UPDATE/INSERT
-size_t evsql_result_affected (const struct evsql_result_info *res);
-
-// fetch the raw binary value from a result set, and return it via ptr
-// if size is nonzero, check that the size of the field data matches
-int evsql_result_binary (const struct evsql_result_info *res, size_t row, size_t col, const char **ptr, size_t *size, int nullok);
-int evsql_result_string (const struct evsql_result_info *res, size_t row, size_t col, const char **ptr, int nullok);
+/**
+ * Sets the value of the parameter at the given index
+ *
+ * @param params the evsql_query_params struct
+ * @param param the parameter index
+ * @param ptr pointer to the binary data
+ * @param len size of the binary data in bytes
+ * @return zero on success, <0 on error
+ */
+int evsql_param_binary (struct evsql_query_params *params, size_t param, const char *ptr, size_t len);
 
-// fetch certain kinds of values from a binary result set
-int evsql_result_uint16 (const struct evsql_result_info *res, size_t row, size_t col, uint16_t *uval, int nullok);
-int evsql_result_uint32 (const struct evsql_result_info *res, size_t row, size_t col, uint32_t *uval, int nullok);
-int evsql_result_uint64 (const struct evsql_result_info *res, size_t row, size_t col, uint64_t *uval, int nullok);
-
-// release the result set, freeing its memory
-void evsql_result_free (const struct evsql_result_info *res);
-
-// platform-dependant aliases
-#define evsql_result_ushort evsql_result_uint16
+/** @see evsql_param_binary */
+int evsql_param_string (struct evsql_query_params *params, size_t param, const char *ptr);
 
-#if _LP64
-#define evsql_result_ulong evsql_result_uint64
-#else
-#define evsql_result_ulong evsql_result_uint32
-#endif /* _LP64 */
+/** @see evsql_param_binary */
+int evsql_param_uint16 (struct evsql_query_params *params, size_t param, uint16_t uval);
 
-/*
- * Close a connection. Callbacks for waiting queries will not be run.
+/** @see evsql_param_binary */
+int evsql_param_uint32 (struct evsql_query_params *params, size_t param, uint32_t uval);
+
+/**
+ * Sets the given parameter to NULL
  *
- * XXX: not implemented yet.
+ * @param params the evsql_query_params struct
+ * @param param the parameter index
+ * @return zero on success, <0 on error
  */
-void evsql_close (struct evsql *evsql);
+int evsql_param_null (struct evsql_query_params *params, size_t param);
+
+/**
+ * Clears all the parameter values (sets them to NULL)
+ *
+ * @param params the evsql_query_params struct
+ * @return zero on success, <0 on error
+ */
+int evsql_params_clear (struct evsql_query_params *params);
+
+// @}
+
+/**
+ * Result-handling functions
+ *
+ * @defgroup evsql_result_* Result interface
+ * @see evsql.h
+ * @see evsql_result
+ * @{
+ */
+
+/**
+ * Check the result for errors. Intended for use with non-data queries, i.e. CREATE, etc.
+ *
+ * Returns zero if the query was OK, err otherwise. EIO indicates an SQL error, the error message can be retrived
+ * using evsql_result_error.
+ *
+ * @param res the result handle passed to evsql_query_cb()
+ * @return zero on success, EIO on SQL error, positive error code otherwise
+ */
+err_t evsql_result_check (struct evsql_result *res);
+
+/**
+ * The iterator-based interface results interface.
+ *
+ * Define an evsql_result_info struct that describes the columns returned by the query, and call evsql_result_begin on
+ * the evsql_result. This verifies the query result, and then prepares it for iteration using evsql_result_next.
+ *
+ * Call evsql_result_end once you've stopped iteration.
+ *
+ * Returns zero if the evsql_result is ready for iteration, err otherwise. EIO indicates an SQL error, the error
+ * message can be retreived using evsql_result_error. The result must be released in both cases.
+ *
+ * Note: currently the iterator state is simply stored in evsql_result, so only one iterator at a time per evsql_result.
+ *
+ * @param info the metadata to use to handle the result row columns
+ * @param res the result handle passed to evsql_query_cb()
+ * @return zero on success, +err on error
+ */
+err_t evsql_result_begin (struct evsql_result_info *info, struct evsql_result *res);
+
+/**
+ * Reads the next result row from the result prepared using evsql_result_begin. Stores the field values into to given
+ * pointer arguments based on the evsql_result_info given to evsql_result_begin.
+ *
+ * If a field is NULL, and the result_info's evsql_item_type has flags.null_ok set, the given pointer is left
+ * untouched, otherwise, an error is returned.
+ *
+ * @param res the result handle previous prepared using evsql_result_begin
+ * @param ... a set of pointers corresponding to the evsql_result_info specified using evsql_result_begin
+ * @return >0 when a row was read, zero when there are no more rows left, and -err on error
+ */
+int evsql_result_next (struct evsql_result *res, ...);
+
+/**
+ * Ends the result iteration, releasing any associated resources and the result itself.
+ *
+ * The result should not be iterated or accessed anymore.
+ *
+ * Note: this does the same thing as evsql_result_free, and works regardless of evsql_result_begin returning
+ * succesfully or not.
+ *
+ * @param res the result handle passed to evsql_query_cb()
+ * @see evsql_result_free
+ */
+void evsql_result_end (struct evsql_result *res);
+
+/**
+ * Get the error message associated with the result, intended for use after evsql_result_check/begin return an error
+ * code.
+ * 
+ * @param res the result handle passed to evsql_query_cb()
+ * @return a char* containing the NUL-terminated error string. Valid until evsql_result_free is called.
+ */
+const char *evsql_result_error (const struct evsql_result *res);
+
+/**
+ * Get the number of data rows returned by the query
+ *
+ * @param res the result handle passed to evsql_query_cb()
+ * @return the number of rows, >= 0
+ */
+size_t evsql_result_rows (const struct evsql_result *res);
+
+/**
+ * Get the number of columns in the data results from the query
+ *
+ * @param res the result handle passed to evsql_query_cb()
+ * @return the number of columns, presumeably zero if there were no results
+ */
+size_t evsql_result_cols (const struct evsql_result *res);
+
+/**
+ * Get the number of rows affected by an UPDATE/INSERT/etc query.
+ *
+ * @param res the result handle passed to evsql_query_cb()
+ * @return the number of rows affected, >= 0
+ */
+size_t evsql_result_affected (const struct evsql_result *res);
+
+/**
+ * Fetch the raw binary value for the given field, returning it via ptr/size.
+ *
+ * The given row/col must be within bounds as returned by evsql_result_rows/cols.
+ *
+ * *ptr will point to *size bytes of read-only memory allocated internally.
+ *
+ * @param res the result handle passed to evsql_query_cb()
+ * @param row the row index to access
+ * @param col the column index to access
+ * @param ptr where to store a pointer to the read-only field data, free'd upon evsql_result_free
+ * @param size updated to the size of the field value pointed to by ptr
+ * @param nullok when true and the field value is NULL, *ptr and *size are not modified, otherwise NULL means an error
+ * @return zero on success, <0 on error
+ */
+int evsql_result_binary (const struct evsql_result *res, size_t row, size_t col, const char **ptr, size_t *size, bool nullok);
+
+/**
+ * Fetch the textual value of the given field, returning it via ptr.
+ *
+ * The given row/col must be within bounds as returned by evsql_result_rows/cols.
+ *
+ * *ptr will point to a NUL-terminated string allocated internally.
+ *
+ * @param res the result handle passed to evsql_query_cb()
+ * @param row the row index to access
+ * @param col the column index to access
+ * @param ptr where to store a pointer to the read-only field data, free'd upon evsql_result_free
+ * @param nullok when true and the field value is NULL, *ptr and *size are not modified, otherwise NULL means an error
+ * @return zero on success, <0 on error
+ */
+int evsql_result_string (const struct evsql_result *res, size_t row, size_t col, const char **ptr, int nullok);
+
+/**
+ * Use evsql_result_binary to read a binary field value, and then convert it using ntoh[slq], storing the value in
+ * *val.
+ *
+ * The given row/col must be within bounds as returned by evsql_result_rows/cols.
+ *
+ * @param res the result handle passed to evsql_query_cb()
+ * @param row the row index to access
+ * @param col the column index to access
+ * @param uval where to store the decoded value
+ * @param nullok when true and the field value is NULL, *ptr and *size are not modified, otherwise NULL means an error
+ * @return zero on success, <0 on error
+ */
+int evsql_result_uint16 (const struct evsql_result *res, size_t row, size_t col, uint16_t *uval, int nullok);
+
+/** @see evsql_result_uint16 */
+int evsql_result_uint32 (const struct evsql_result *res, size_t row, size_t col, uint32_t *uval, int nullok);
+
+/** @see evsql_result_uint16 */
+int evsql_result_uint64 (const struct evsql_result *res, size_t row, size_t col, uint64_t *uval, int nullok);
+
+/**
+ * Every result handle passed to evsql_query_cb() MUST be released by the user, using this function.
+ *
+ * @param res the result handle passed to evsql_query_cb()
+ */
+void evsql_result_free (struct evsql_result *res);
+
+// @}
 
 #endif /* EVSQL_H */
--- a/src/CMakeLists.txt	Sun Mar 08 01:16:54 2009 +0200
+++ b/src/CMakeLists.txt	Sun Mar 08 01:33:45 2009 +0200
@@ -7,9 +7,9 @@
 set (EVSQL_SOURCES core.c util.c)
 
 # XXX: silly cmake does silly things when you SET with only one arg
-set (SOURCES lib/log.c evpq.c core.c util.c)
+set (EVSQL_SOURCES lib/log.c evpq.c core.c query.c result.c util.c)
 
 # add our library
-add_library (evsql STATIC ${SOURCES})
+add_library (evsql STATIC ${EVSQL_SOURCES})
 target_link_libraries (evsql ${LibEvent_LIBRARIES})
 
--- a/src/core.c	Sun Mar 08 01:16:54 2009 +0200
+++ b/src/core.c	Sun Mar 08 01:33:45 2009 +0200
@@ -63,12 +63,7 @@
     return err;
 }
 
-/*
- * Free the query and related resources, doesn't trigger any callbacks or remove from any queues.
- *
- * The command should already be taken care of (NULL).
- */
-static void _evsql_query_free (struct evsql_query *query) {
+void _evsql_query_free (struct evsql_query *query) {
     if (!query)
         return;
         
@@ -89,13 +84,17 @@
  *
  * The query has been aborted, it will simply be freed
  */
-static void _evsql_query_done (struct evsql_query *query, const struct evsql_result_info *res) {
+static void _evsql_query_done (struct evsql_query *query, struct evsql_result *res) {
     if (res) {
         if (query->cb_fn)
             // call the callback
             query->cb_fn(res, query->cb_arg);
-        else
+        else {
             WARNING("supressing cb_fn because query was aborted");
+            
+            // free the results
+            evsql_result_free(res);
+        }
     }
 
     // free
@@ -105,7 +104,7 @@
 /*
  * XXX:
  * /
-static void _evsql_destroy (struct evsql *evsql, const struct evsql_result_info *res) {
+static void _evsql_destroy (struct evsql *evsql, const struct evsql_result *res) {
     struct evsql_query *query;
     
     // clear the queue
@@ -184,11 +183,10 @@
  * NOTE: Only for *TRANSACTIONLESS* queries.
  */
 static void _evsql_query_fail (struct evsql* evsql, struct evsql_query *query) {
-    struct evsql_result_info res; ZINIT(res);
+    struct evsql_result res; ZINIT(res);
     
     // set up the result_info
     res.evsql = evsql;
-    res.trans = NULL;
     res.error = 1;
     
     // finish off the query
@@ -260,6 +258,9 @@
     
     // look for waiting queries
     while ((query = TAILQ_FIRST(&evsql->query_queue)) != NULL) {
+        // zero err
+        err = 0;
+
         // dequeue
         TAILQ_REMOVE(&evsql->query_queue, query, entry);
         
@@ -303,23 +304,23 @@
 /*
  * Callback for a trans's 'BEGIN' query, which means the transaction is now ready for use.
  */
-static void _evsql_trans_ready (const struct evsql_result_info *res, void *arg) {
-    (void) arg;
+static void _evsql_trans_ready (struct evsql_result *res, void *arg) {
+    struct evsql_trans *trans = arg;
 
-    assert(res->trans);
+    assert(trans != NULL);
 
     // check for errors
     if (res->error)
         ERROR("transaction 'BEGIN' failed: %s", evsql_result_error(res));
     
     // transaction is now ready for use
-    res->trans->ready_fn(res->trans, res->trans->cb_arg);
+    trans->ready_fn(trans, trans->cb_arg);
     
     // good
     return;
 
 error:
-    _evsql_trans_fail(res->trans);
+    _evsql_trans_fail(trans);
 }
 
 /*
@@ -364,7 +365,7 @@
         ERROR("trans_sql overflow: %d >= %d", ret, EVSQL_QUERY_BEGIN_BUF);
     
     // execute the query
-    if (evsql_query(evsql, trans, trans_sql, _evsql_trans_ready, NULL) == NULL)
+    if (evsql_query(evsql, trans, trans_sql, _evsql_trans_ready, trans) == NULL)
         ERROR("evsql_query");
     
     // success
@@ -403,14 +404,14 @@
     assert(query != NULL);
 
     // if we get multiple results, only return the first one
-    if (query->result.evpq) {
+    if (query->result.pq) {
         WARNING("[evsql] evpq query returned multiple results, discarding previous one");
         
-        PQclear(query->result.evpq); query->result.evpq = NULL;
+        PQclear(query->result.pq); query->result.pq = NULL;
     }
     
     // remember the result
-    query->result.evpq = result;
+    query->result.pq = result;
 }
 
 /*
@@ -419,28 +420,27 @@
 static void _evsql_evpq_done (struct evpq_conn *_conn, void *arg) {
     struct evsql_conn *conn = arg;
     struct evsql_query *query = conn->query;
-    struct evsql_result_info res; ZINIT(res);
+    struct evsql_result res; ZINIT(res);
     
     assert(query != NULL);
     
     // set up the result_info
     res.evsql = conn->evsql;
-    res.trans = conn->trans;
+    res.result = query->result;
     
-    if (query->result.evpq == NULL) {
+    if (query->result.pq == NULL) {
         // if a query didn't return any results (bug?), warn and fail the query
         WARNING("[evsql] evpq query didn't return any results");
 
         res.error = 1;
     
-    } else if (strcmp(PQresultErrorMessage(query->result.evpq), "") != 0) {
+    } else if (strcmp(PQresultErrorMessage(query->result.pq), "") != 0) {
         // the query failed with some error
         res.error = 1;
-        res.result.pq = query->result.evpq;
 
     } else {
+        // the query succeeded \o/
         res.error = 0;
-        res.result.pq = query->result.evpq;
 
     }
 
@@ -731,9 +731,9 @@
 }
 
 /*
- * Validate and allocate the basic stuff for a new query.
+ * Internal query functions
  */
-static struct evsql_query *_evsql_query_new (struct evsql *evsql, struct evsql_trans *trans, evsql_query_cb query_fn, void *cb_arg) {
+struct evsql_query *_evsql_query_new (struct evsql *evsql, struct evsql_trans *trans, evsql_query_cb query_fn, void *cb_arg) {
     struct evsql_query *query = NULL;
     
     // if it's part of a trans, then make sure the trans is idle
@@ -755,13 +755,7 @@
     return NULL;
 }
 
-/*
- * Handle a new query.
- *
- * For transactions this will associate the query and then execute it, otherwise this will either find an idle
- * connection and send the query, or enqueue it.
- */
-static int _evsql_query_enqueue (struct evsql *evsql, struct evsql_trans *trans, struct evsql_query *query, const char *command) {
+int _evsql_query_enqueue (struct evsql *evsql, struct evsql_trans *trans, struct evsql_query *query, const char *command) {
     // transaction queries are handled differently
     if (trans) {
         // it's an in-transaction query
@@ -818,127 +812,25 @@
     return -1;
 }
 
-struct evsql_query *evsql_query (struct evsql *evsql, struct evsql_trans *trans, const char *command, evsql_query_cb query_fn, void *cb_arg) {
-    struct evsql_query *query = NULL;
-    
-    // alloc new query
-    if ((query = _evsql_query_new(evsql, trans, query_fn, cb_arg)) == NULL)
-        goto error;
-    
-    // just execute the command string directly
-    if (_evsql_query_enqueue(evsql, trans, query, command))
-        goto error;
-
-    // ok
-    return query;
-
-error:
-    _evsql_query_free(query);
-
-    return NULL;
-}
-
-struct evsql_query *evsql_query_params (struct evsql *evsql, struct evsql_trans *trans, const char *command, const struct evsql_query_params *params, evsql_query_cb query_fn, void *cb_arg) {
-    struct evsql_query *query = NULL;
-    const struct evsql_query_param *param;
-    int idx;
-    
-    // alloc new query
-    if ((query = _evsql_query_new(evsql, trans, query_fn, cb_arg)) == NULL)
-        goto error;
-
-    // count the params
-    for (param = params->list; param->type; param++) 
-        query->params.count++;
-
-    // allocate the vertical storage for the parameters
-    if (0
-        
-        ||  !(query->params.types    = calloc(query->params.count, sizeof(Oid)))
-        ||  !(query->params.values   = calloc(query->params.count, sizeof(char *)))
-        ||  !(query->params.lengths  = calloc(query->params.count, sizeof(int)))
-        ||  !(query->params.formats  = calloc(query->params.count, sizeof(int)))
-    )
-        ERROR("calloc");
-
-    // transform
-    for (param = params->list, idx = 0; param->type; param++, idx++) {
-        // `set for NULLs, otherwise not
-        query->params.types[idx] = param->data_raw ? 0 : EVSQL_PQ_ARBITRARY_TYPE_OID;
-        
-        // values
-        query->params.values[idx] = param->data_raw;
 
-        // lengths
-        query->params.lengths[idx] = param->length;
-
-        // formats, binary if length is nonzero, but text for NULLs
-        query->params.formats[idx] = param->length && param->data_raw ? 1 : 0;
-    }
-
-    // result format
-    switch (params->result_fmt) {
-        case EVSQL_FMT_TEXT:
-            query->params.result_format = 0; break;
-
-        case EVSQL_FMT_BINARY:
-            query->params.result_format = 1; break;
-
-        default:
-            FATAL("params.result_fmt: %d", params->result_fmt);
-    }
-
-    // execute it
-    if (_evsql_query_enqueue(evsql, trans, query, command))
-        goto error;
-
-#ifdef DEBUG_ENABLED
-    // debug it?
-    DEBUG("evsql.%p: enqueued query=%p on trans=%p", evsql, query, trans);
-    evsql_query_debug(command, params);
-#endif /* DEBUG_ENABLED */
-
-    // ok
-    return query;
-
-error:
-    _evsql_query_free(query);
-    
-    return NULL;
-}
-
-void evsql_query_abort (struct evsql_trans *trans, struct evsql_query *query) {
-    assert(query);
-
-    if (trans) {
-        // must be the right query
-        assert(trans->query == query);
-    }
-
-    // just strip the callback and wait for it to complete as normal
-    query->cb_fn = NULL;
-}
-
-void _evsql_trans_commit_res (const struct evsql_result_info *res, void *arg) {
-    (void) arg;
-
-    assert(res->trans);
+void _evsql_trans_commit_res (struct evsql_result *res, void *arg) {
+    struct evsql_trans *trans = arg;
 
     // check for errors
     if (res->error)
         ERROR("transaction 'COMMIT' failed: %s", evsql_result_error(res));
     
     // transaction is now done
-    res->trans->done_fn(res->trans, res->trans->cb_arg);
+    trans->done_fn(trans, trans->cb_arg);
     
     // release it
-    _evsql_trans_release(res->trans);
+    _evsql_trans_release(trans);
 
     // success
     return;
 
 error:
-    _evsql_trans_fail(res->trans);
+    _evsql_trans_fail(trans);
 }
 
 int evsql_trans_commit (struct evsql_trans *trans) {
@@ -948,7 +840,7 @@
         ERROR("cannot COMMIT because transaction is still busy");
     
     // query
-    if (evsql_query(trans->evsql, trans, sql, _evsql_trans_commit_res, NULL) == NULL)
+    if (evsql_query(trans->evsql, trans, sql, _evsql_trans_commit_res, trans) == NULL)
         goto error;
     
     // mark it as commited in case someone wants to abort it
@@ -961,37 +853,35 @@
     return -1;
 }
 
-void _evsql_trans_rollback_res (const struct evsql_result_info *res, void *arg) {
-    (void) arg;
-
-    assert(res->trans);
+void _evsql_trans_rollback_res (struct evsql_result *res, void *arg) {
+    struct evsql_trans *trans = arg;
 
     // fail the connection on errors
     if (res->error)
         ERROR("transaction 'ROLLBACK' failed: %s", evsql_result_error(res));
 
     // release it
-    _evsql_trans_release(res->trans);
+    _evsql_trans_release(trans);
 
     // success
     return;
 
 error:
     // fail the connection too, errors are supressed
-    _evsql_trans_fail(res->trans);
+    _evsql_trans_fail(trans);
 }
 
 /*
  * Used as the ready_fn callback in case of abort, otherwise directly
  */
-void _evsql_trans_rollback (struct evsql_trans *trans, void *unused) {
+void _evsql_trans_rollback (struct evsql_trans *trans, void *arg) {
     static const char *sql = "ROLLBACK TRANSACTION";
 
-    (void) unused;
+    (void) arg;
 
     // query
-    if (evsql_query(trans->evsql, trans, sql, _evsql_trans_rollback_res, NULL) == NULL) {
-        // fail the transaction/connection
+    if (evsql_query(trans->evsql, trans, sql, _evsql_trans_rollback_res, trans) == NULL) {
+        // fail the transaction/connection, errors are supressed
         _evsql_trans_fail(trans);
     }
 
@@ -1010,7 +900,7 @@
         // gah, some query is running
         WARNING("aborting pending query");
         
-        // prepare to rollback once complete
+        // prepare to rollback once complete by hijacking ready_fn
         trans->ready_fn = _evsql_trans_rollback;
         
         // abort
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/evsql_test.c	Sun Mar 08 01:33:45 2009 +0200
@@ -0,0 +1,279 @@
+
+#include "evsql.h"
+#include "lib/log.h"
+#include "lib/signals.h"
+#include "lib/misc.h"
+
+#include <event2/event.h>
+#include <event2/event_struct.h>
+#include <assert.h>
+
+#define CONNINFO_DEFAULT "dbname=dbfs port=5433"
+
+struct evsql_test_ctx {
+    struct evsql *db;
+    struct evsql_trans *trans;
+};
+
+// forward-declare
+void query_send (struct evsql *db, struct evsql_trans *trans);
+
+
+void query_timer (int fd, short what, void *arg) {
+    struct evsql *db = arg;
+    
+    INFO("[evsql_test.timer] *tick*");
+
+    query_send(db, NULL);
+}
+
+void query_start (struct event_base *base, struct evsql *db) {
+    static struct event ev;
+    struct timeval tv = { 5, 0 };
+
+    evperiodic_assign(&ev, base, &tv, &query_timer, db);
+    event_add(&ev, &tv);
+
+    INFO("[evsql_test.timer_start] started timer");
+}
+
+void query_results (struct evsql_result *result, void *arg) {
+    struct evsql *db = arg;
+    uint32_t val;
+
+    (void) db;
+
+    static struct evsql_result_info result_info = {
+        0, {
+            {   EVSQL_FMT_BINARY,   EVSQL_TYPE_UINT32   },
+            {   0,                  0                   }
+        }
+    };
+
+    // begin
+    assert(evsql_result_begin(&result_info, result) == 0);
+
+    // one row
+    assert(evsql_result_next(result, 
+        &val
+    ) > 0);
+
+    // print
+    INFO("[evsql_test.results] got result: %p: val=%lu", result, (unsigned long) val);
+
+    // done
+    evsql_result_end(result);
+}
+
+void query_send (struct evsql *db, struct evsql_trans *trans) {
+    struct evsql_query *query = NULL;
+    static int query_id = 0;
+
+    static struct evsql_query_info query_info = {
+        .sql    = "SELECT $1::int4 + 5",
+
+        .params = {
+            {   EVSQL_FMT_BINARY,   EVSQL_TYPE_UINT32   },
+            {   0,                  0                   }
+        }
+    };
+
+    // query
+    if ((query = evsql_query_exec(db, trans, &query_info, query_results, db,
+        (uint32_t) ++query_id
+    )) == NULL)
+        WARNING("evsql_query_exec failed");
+
+    INFO("[evsql_test.query_send] enqueued query, trans=%p: %p: %d", trans, query, query_id);
+}
+
+void trans_commit (struct evsql_test_ctx *ctx) {
+    if (evsql_trans_commit(ctx->trans))
+        FATAL("evsql_trans_commit failed");
+    
+    INFO("[evsql_test.trans_commit] commiting transaction");
+}
+
+void trans_insert_result (struct evsql_result *res, void *arg) {
+    struct evsql_test_ctx *ctx = arg;
+    err_t err;
+    
+    // the result info
+    uint32_t id;
+    const char *str;
+
+    static struct evsql_result_info result_info = {
+        0, {
+            {   EVSQL_FMT_BINARY,   EVSQL_TYPE_UINT32   },
+            {   EVSQL_FMT_BINARY,   EVSQL_TYPE_STRING   },
+            {   0,                  0                   }
+        }
+    };
+
+    // begin
+    if ((err = evsql_result_begin(&result_info, res)))
+        EFATAL(err, "query failed%s", err == EIO ? evsql_result_error(res) : "");
+    
+    INFO("[evsql_test.insert] got %zu rows:", evsql_result_rows(res));
+
+    // iterate over rows
+    while ((err = evsql_result_next(res, &id, &str)) > 0) {
+        INFO("\t%-4lu %s", (unsigned long) id, str);
+    }
+
+    if (err)
+        EFATAL(err, "evsql_result_next failed");
+    
+    INFO("\t(done)");
+
+    // done
+    evsql_result_end(res);
+
+    // commit the transaction
+    trans_commit(ctx);
+}
+
+void trans_insert (struct evsql_test_ctx *ctx) {
+    struct evsql_query *query = NULL;
+
+    // the query info
+    static struct evsql_query_info query_info = {
+        .sql    = "INSERT INTO evsql_test (str) VALUES ($1::varchar), ($2::varchar) RETURNING id, str",
+
+        .params = {
+            {   EVSQL_FMT_BINARY,   EVSQL_TYPE_STRING   },
+            {   EVSQL_FMT_BINARY,   EVSQL_TYPE_STRING   },
+            {   0,                  0                   }
+        }
+    };
+
+    // run the query
+    assert((query = evsql_query_exec(ctx->db, ctx->trans, &query_info, trans_insert_result, ctx,
+        (const char *) "row A",
+        (const char *) "row B"
+    )) != NULL);
+
+    INFO("[evsql_test.insert] enqueued query: %p", query);
+}
+
+void trans_create_result (struct evsql_result *res, void *arg) {
+    struct evsql_test_ctx *ctx = arg;
+
+    // check
+    if (evsql_result_check(res))
+        FATAL("query failed: %s", evsql_result_error(res));
+    
+    INFO("[evsql_test.create_result] table created succesfully: %p", res);
+
+    // free result
+    evsql_result_free(res);
+
+    // insert
+    trans_insert(ctx);
+}
+
+void trans_create_query (struct evsql_test_ctx *ctx) {
+    struct evsql_query *query = NULL;
+
+    // the query info
+    static struct evsql_query_info query_info = {
+        .sql    = "CREATE TEMPORARY TABLE evsql_test ( id serial4, str varchar(32) DEFAULT 'foobar' ) ON COMMIT DROP",
+
+        .params = {
+//            {   EVSQL_FMT_BINARY,   EVSQL_TYPE_STRING   },
+            {   0,                  0,                  }
+        }
+    };
+
+    // run the query
+    assert((query = evsql_query_exec(ctx->db, ctx->trans, &query_info, trans_create_result, ctx
+//        (const char *) "foobar"
+    )) != NULL);
+
+    INFO("[evsql_test.trans_create_query] enqueued query: %p", query);
+}
+
+void trans_error (struct evsql_trans *trans, void *arg) {
+    struct evsql_test_ctx *ctx = arg;
+
+    FATAL("[evsql_test.trans_error] failure: trans=%p: %s", ctx->trans, evsql_trans_error(trans));
+}
+
+void trans_ready (struct evsql_trans *trans, void *arg) {
+    struct evsql_test_ctx *ctx = arg;
+
+    INFO("[evsql_test.trans_ready] ready");
+    
+    trans_create_query(ctx);
+}
+
+void trans_done (struct evsql_trans *trans, void *arg) {
+    struct evsql_test_ctx *ctx = arg;
+
+    INFO("[evsql_test.trans_done] done: trans=%p", ctx->trans);
+}
+
+void begin_transaction (struct evsql_test_ctx *ctx) {
+    assert((ctx->trans = evsql_trans(ctx->db, EVSQL_TRANS_DEFAULT, 
+        &trans_error, &trans_ready, &trans_done,
+        ctx
+    )) != NULL);
+
+    INFO("[evsql_test.begin_trans] created transaction");
+ }
+
+int main (int argc, char **argv) {
+    struct evsql_test_ctx ctx;
+    struct event_base *ev_base = NULL;
+    struct signals *signals = NULL;
+
+    const char *db_conninfo;
+    
+    // parse args
+    db_conninfo = CONNINFO_DEFAULT;
+    
+    // init libevent
+    if ((ev_base = event_base_new()) == NULL)
+        ERROR("event_base_new");
+    
+    // setup signals
+    if ((signals = signals_default(ev_base)) == NULL)
+        ERROR("signals_default");
+
+    // setup evsql
+    if ((ctx.db = evsql_new_pq(ev_base, db_conninfo, NULL, NULL)) == NULL)
+        ERROR("evsql_new_pq");
+
+    // send query
+    query_send(ctx.db, NULL);
+
+    // being transaction
+    begin_transaction(&ctx);
+
+    // send query
+    query_send(ctx.db, NULL);
+
+    // start query timer
+    query_start(ev_base, ctx.db);
+
+    // run libevent
+    INFO("[evsql_test.main] running libevent loop");
+
+    if (event_base_dispatch(ev_base))
+        PERROR("event_base_dispatch");
+    
+    // clean shutdown
+
+error :
+    if (ctx.db) {
+        /* evsql_close(db); */
+    }
+
+    if (signals)
+        signals_free(signals);
+
+    if (ev_base)
+        event_base_free(ev_base);
+    
+}
+
--- a/src/internal.h	Sun Mar 08 01:16:54 2009 +0200
+++ b/src/internal.h	Sun Mar 08 01:33:45 2009 +0200
@@ -97,6 +97,13 @@
 };
 
 /*
+ * Backend result handle
+ */
+union evsql_result_handle {
+    PGresult *pq;
+};
+
+/*
  * A single query.
  *
  * Has the info needed to exec the query (as these may be queued), and the callback/result info.
@@ -106,7 +113,7 @@
     char *command;
     
     // possible query params
-    struct evsql_query_param_info {
+    struct evsql_query_params_pq {
         int count;
 
         Oid *types;
@@ -114,22 +121,39 @@
         int *lengths;
         int *formats;
 
+        // storage for numeric values
+        union evsql_item_value *item_vals;
+
         int result_format;
     } params;
 
     // our callback
     evsql_query_cb cb_fn;
     void *cb_arg;
+        
+    // the result we get
+    union evsql_result_handle result;
 
     // our position in the query list
     TAILQ_ENTRY(evsql_query) entry;
+};
 
-    // the result
-    union {
-        PGresult *evpq;
-    } result;
+// the result
+struct evsql_result {
+    struct evsql *evsql;
+
+    // possible error code
+    int error;
+    
+    // the actual result
+    union evsql_result_handle result;
+
+    // result_* state
+    struct evsql_result_info *info;
+    size_t row_offset;
 };
 
+
 // maximum length for a 'BEGIN TRANSACTION ...' query
 #define EVSQL_QUERY_BEGIN_BUF 512
 
@@ -137,4 +161,32 @@
 // 16 = bool in 8.3
 #define EVSQL_PQ_ARBITRARY_TYPE_OID 16
 
+/*
+ * Core query-submission interface.
+ *
+ * This performs some error-checking on the trans, allocates the evsql_query and does some basic initialization.
+ *
+ * This does not actually enqueue the query anywhere, no reference is stored anywhere.
+ *
+ * Returns the new evsql_query on success, NULL on failure.
+ */
+struct evsql_query *_evsql_query_new (struct evsql *evsql, struct evsql_trans *trans, evsql_query_cb query_fn, void *cb_arg);
+
+/*
+ * Begin processing the given query, which should now be fully filled out.
+ *
+ * If trans is given, it MUST be idle, and the query will be executed. Otherwise, it will either be executed directly
+ * or enqueued for future execution.
+ *
+ * Returns zero on success, nonzero on failure.
+ */
+int _evsql_query_enqueue (struct evsql *evsql, struct evsql_trans *trans, struct evsql_query *query, const char *command);
+
+/*
+ * Free the query and related resources, doesn't trigger any callbacks or remove from any queues.
+ *
+ * The command should already be taken care of (NULL).
+ */
+void _evsql_query_free (struct evsql_query *query);
+
 #endif /* EVSQL_INTERNAL_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/lib/err.h	Sun Mar 08 01:33:45 2009 +0200
@@ -0,0 +1,11 @@
+#ifndef LIB_ERR_H
+#define LIB_ERR_H
+
+#include <errno.h>
+
+/*
+ * err_t is always positive
+ */
+typedef unsigned int err_t;
+
+#endif /* LIB_ERR_H */
--- a/src/lib/error.h	Sun Mar 08 01:16:54 2009 +0200
+++ b/src/lib/error.h	Sun Mar 08 01:33:45 2009 +0200
@@ -2,11 +2,7 @@
 #define LIB_ERROR_H
 
 #include "log.h"
-
-/*
- * err_t is always positive
- */
-typedef unsigned int err_t;
+#include "err.h"
 
 #define ERROR(...) do { err_func(__func__, __VA_ARGS__); goto error; } while (0)
 #define PERROR(...) do { perr_func(__func__, __VA_ARGS__); goto error; } while (0)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/query.c	Sun Mar 08 01:33:45 2009 +0200
@@ -0,0 +1,256 @@
+
+#include "internal.h"
+#include "lib/error.h"
+#include "lib/misc.h"
+
+#include <stdlib.h>
+#include <assert.h>
+
+/*
+ * Initialize params->types/values/lengths/formats, params->count, params->result_format based on the given args
+ */
+static int _evsql_query_params_init_pq (struct evsql_query_params_pq *params, size_t param_count, enum evsql_item_format result_format) {
+    // set count
+    params->count = param_count;
+
+    // allocate vertical storage for the parameters
+    if (0
+        
+        ||  !(params->types     = calloc(param_count, sizeof(Oid)))
+        ||  !(params->values    = calloc(param_count, sizeof(char *)))
+        ||  !(params->lengths   = calloc(param_count, sizeof(int)))
+        ||  !(params->formats   = calloc(param_count, sizeof(int)))
+        ||  !(params->item_vals = calloc(param_count, sizeof(union evsql_item_value)))
+    )
+        ERROR("calloc");
+
+    // result format
+    switch (result_format) {
+        case EVSQL_FMT_TEXT:
+            params->result_format = 0; break;
+
+        case EVSQL_FMT_BINARY:
+            params->result_format = 1; break;
+
+        default:
+            FATAL("params.result_fmt: %d", result_format);
+    }
+    
+    // good
+    return 0;
+
+error:
+    return -1;
+}
+
+struct evsql_query *evsql_query (struct evsql *evsql, struct evsql_trans *trans, const char *command, evsql_query_cb query_fn, void *cb_arg) {
+    struct evsql_query *query = NULL;
+    
+    // alloc new query
+    if ((query = _evsql_query_new(evsql, trans, query_fn, cb_arg)) == NULL)
+        goto error;
+    
+    // just execute the command string directly
+    if (_evsql_query_enqueue(evsql, trans, query, command))
+        goto error;
+
+    // ok
+    return query;
+
+error:
+    _evsql_query_free(query);
+
+    return NULL;
+}
+
+struct evsql_query *evsql_query_params (struct evsql *evsql, struct evsql_trans *trans, 
+    const char *command, const struct evsql_query_params *params, 
+    evsql_query_cb query_fn, void *cb_arg
+) {
+    struct evsql_query *query = NULL;
+    const struct evsql_item *param;
+    size_t count = 0, idx;
+    
+    // alloc new query
+    if ((query = _evsql_query_new(evsql, trans, query_fn, cb_arg)) == NULL)
+        goto error;
+
+    // count the params
+    for (param = params->list; param->info.type; param++) 
+        count++;
+    
+    // initialize params
+    _evsql_query_params_init_pq(&query->params, count, params->result_format);
+
+    // transform
+    for (param = params->list, idx = 0; param->info.type; param++, idx++) {
+        // set for NULLs, otherwise not
+        query->params.types[idx] = (param->bytes || param->flags.has_value) ? 0 : EVSQL_PQ_ARBITRARY_TYPE_OID;
+
+        // scalar values
+        query->params.item_vals[idx] = param->value;
+        
+        // values
+        // point this at the value stored in the item_vals union if flagged as such
+        query->params.values[idx] = param->flags.has_value ? (const char *) &query->params.item_vals[idx] : param->bytes;
+
+        // lengths
+        query->params.lengths[idx] = param->length;
+        
+        // XXX: this assumes that format is FMT_BINARY...
+        query->params.formats[idx] = param->info.format;
+    }
+
+    // execute it
+    if (_evsql_query_enqueue(evsql, trans, query, command))
+        goto error;
+
+#ifdef DEBUG_ENABLED
+    // debug it?
+    DEBUG("evsql.%p: enqueued query=%p on trans=%p", evsql, query, trans);
+    evsql_query_debug(command, params);
+#endif /* DEBUG_ENABLED */
+
+    // ok
+    return query;
+
+error:
+    _evsql_query_free(query);
+    
+    return NULL;
+}
+
+struct evsql_query *evsql_query_exec (struct evsql *evsql, struct evsql_trans *trans, 
+    const struct evsql_query_info *query_info,
+    evsql_query_cb query_fn, void *cb_arg,
+    ...
+) {
+    va_list vargs;
+    struct evsql_query *query = NULL;
+    const struct evsql_item_info *param;
+    size_t count = 0, idx;
+    err_t err = 1;
+
+    // varargs
+    va_start(vargs, cb_arg);
+    
+    // alloc new query
+    if ((query = _evsql_query_new(evsql, trans, query_fn, cb_arg)) == NULL)
+        goto error;
+
+    // count the params
+    for (param = query_info->params; param->type; param++) 
+        count++;
+    
+    // initialize params
+    _evsql_query_params_init_pq(&query->params, count, EVSQL_FMT_BINARY);
+
+    // transform
+    for (param = query_info->params, idx = 0; param->type; param++, idx++) {
+        // default type to 0 (implicit)
+        query->params.types[idx] = 0;
+
+        // default format to binary
+        query->params.formats[idx] = EVSQL_FMT_BINARY;
+
+        // consume argument
+        switch (param->type) {
+            case EVSQL_TYPE_NULL_: {
+                // explicit type + text fmt
+                query->params.types[idx] = EVSQL_PQ_ARBITRARY_TYPE_OID;
+                query->params.values[idx] = NULL;
+                query->params.lengths[idx] = 0;
+                query->params.formats[idx] = EVSQL_FMT_TEXT;
+            } break;
+
+            case EVSQL_TYPE_BINARY: {
+                struct evsql_item_binary item = va_arg(vargs, struct evsql_item_binary);
+                
+                // value + explicit len
+                query->params.values[idx] = item.ptr;
+                query->params.lengths[idx] = item.len;
+            } break;
+
+            case EVSQL_TYPE_STRING: {
+                const char *str = va_arg(vargs, const char *);
+
+                // value + automatic length, text format
+                query->params.values[idx] = str;
+                query->params.lengths[idx] = 0;
+                query->params.formats[idx] = EVSQL_FMT_TEXT;
+            } break;
+            
+            case EVSQL_TYPE_UINT16: {
+                // XXX: uint16_t is passed as `int'?
+                uint16_t uval = va_arg(vargs, int);
+
+                if (uval != (int16_t) uval)
+                    ERROR("param $%zu: uint16 overflow: %d", idx + 1, uval);
+                
+                // network-byte-order value + explicit len
+                query->params.item_vals[idx].uint16 = htons(uval);
+                query->params.values[idx] = (const char *) &query->params.item_vals[idx];
+                query->params.lengths[idx] = sizeof(uint16_t);
+            } break;
+            
+            case EVSQL_TYPE_UINT32: {
+                uint32_t uval = va_arg(vargs, uint32_t);
+
+                if (uval != (int32_t) uval)
+                    ERROR("param $%zu: uint32 overflow: %ld", idx + 1, (unsigned long) uval);
+                
+                // network-byte-order value + explicit len
+                query->params.item_vals[idx].uint32 = htonl(uval);
+                query->params.values[idx] = (const char *) &query->params.item_vals[idx];
+                query->params.lengths[idx] = sizeof(uint32_t);
+            } break;
+
+            case EVSQL_TYPE_UINT64: {
+                uint64_t uval = va_arg(vargs, uint64_t);
+
+                if (uval != (int64_t) uval)
+                    ERROR("param $%zu: uint16 overflow: %lld", idx + 1, (unsigned long long) uval);
+                
+                // network-byte-order value + explicit len
+                query->params.item_vals[idx].uint64 = htonq(uval);
+                query->params.values[idx] = (const char *) &query->params.item_vals[idx];
+                query->params.lengths[idx] = sizeof(uint64_t);
+            } break;
+            
+            default: 
+                FATAL("param $%zu: invalid type: %d", idx + 1, param->type);
+        }
+    }
+
+    // execute it
+    if (_evsql_query_enqueue(evsql, trans, query, query_info->sql))
+        goto error;
+    
+    // no error, fallthrough for va_end
+    err = 0;
+
+error:
+    // possible cleanup
+    if (err)
+        _evsql_query_free(query);
+    
+    // end varargs
+    va_end(vargs);
+    
+    // return 
+    return err ? NULL : query;
+}
+
+
+void evsql_query_abort (struct evsql_trans *trans, struct evsql_query *query) {
+    assert(query);
+
+    if (trans) {
+        // must be the right query
+        assert(trans->query == query);
+    }
+
+    // just strip the callback and wait for it to complete as normal
+    query->cb_fn = NULL;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/result.c	Sun Mar 08 01:33:45 2009 +0200
@@ -0,0 +1,258 @@
+
+#include "internal.h"
+#include "lib/error.h"
+#include "lib/misc.h"
+
+#include <stdlib.h>
+#include <assert.h>
+
+const char *evsql_result_error (const struct evsql_result *res) {
+    if (!res->error)
+        return "No error";
+
+    switch (res->evsql->type) {
+        case EVSQL_EVPQ:
+            if (!res->result.pq)
+                return "unknown error (no result)";
+            
+            return PQresultErrorMessage(res->result.pq);
+
+        default:
+            FATAL("res->evsql->type");
+    }
+
+}
+
+size_t evsql_result_rows (const struct evsql_result *res) {
+    switch (res->evsql->type) {
+        case EVSQL_EVPQ:
+            return PQntuples(res->result.pq);
+
+        default:
+            FATAL("res->evsql->type");
+    }
+}
+
+size_t evsql_result_cols (const struct evsql_result *res) {
+    switch (res->evsql->type) {
+        case EVSQL_EVPQ:
+            return PQnfields(res->result.pq);
+
+        default:
+            FATAL("res->evsql->type");
+    }
+}
+
+size_t evsql_result_affected (const struct evsql_result *res) {
+    switch (res->evsql->type) {
+        case EVSQL_EVPQ:
+            // XXX: errors?
+            return strtol(PQcmdTuples(res->result.pq), NULL, 10);
+
+        default:
+            FATAL("res->evsql->type");
+    }
+}
+
+
+int evsql_result_null (const struct evsql_result *res, size_t row, size_t col) {
+    switch (res->evsql->type) {
+        case EVSQL_EVPQ:
+            return PQgetisnull(res->result.pq, row, col);
+
+        default:
+            FATAL("res->evsql->type");
+    }
+}
+
+int evsql_result_field (const struct evsql_result *res, size_t row, size_t col, const char **ptr, size_t *size) {
+    *ptr = NULL;
+
+    switch (res->evsql->type) {
+        case EVSQL_EVPQ:
+            if (PQfformat(res->result.pq, col) != 1)
+                ERROR("[%zu:%zu] PQfformat is not binary: %d", row, col, PQfformat(res->result.pq, col));
+    
+            *size = PQgetlength(res->result.pq, row, col);
+            *ptr  = PQgetvalue(res->result.pq, row, col);
+
+            return 0;
+
+        default:
+            FATAL("res->evsql->type");
+    }
+
+error:
+    return -1;
+}
+
+err_t evsql_result_check (struct evsql_result *res) {
+    // so simple...
+    return res->error ? EIO : 0;
+}
+
+err_t evsql_result_begin (struct evsql_result_info *info, struct evsql_result *res) {
+    struct evsql_item_info *col;
+    size_t cols = 0, nrows;
+    err_t err;
+
+    // count info columns
+    for (col = info->columns; col->type; col++)
+        cols++;
+
+    // number of rows returned/affected
+    nrows = evsql_result_rows(res) || evsql_result_affected(res);
+
+    // did the query fail outright?
+    if (res->error)
+        // dump error message
+        NXERROR(err = EIO, evsql_result_error(res));
+
+/*
+    // SELECT/DELETE/UPDATE WHERE didn't match any rows -> ENOENT
+    if (nrows == 0)
+        XERROR(err = ENOENT, "no rows returned/affected");
+*/
+
+    // correct number of columns
+    if (evsql_result_cols(res) != cols)
+        XERROR(err = EINVAL, "wrong number of columns: %zu, should be %zu", evsql_result_cols(res), cols);
+    
+    // assign
+    res->info = info;
+    res->row_offset = 0;
+
+    // good
+    return 0;
+
+error:
+    return err;
+
+}
+
+int evsql_result_next (struct evsql_result *res, ...) {
+    va_list vargs;
+    struct evsql_item_info *col;
+    size_t col_idx, row_idx = res->row_offset;
+    err_t err;
+    
+    // ensure that evsql_result_begin has been called
+    assert(res->info);
+    
+    // check if we're past the end
+    if (row_idx >= evsql_result_rows(res))
+        return 0;
+    
+    // varargs
+    va_start(vargs, res);
+
+    for (col = res->info->columns, col_idx = 0; col->type; col++, col_idx++) {
+        const char *value = NULL;
+        size_t length = 0;
+        
+        // check for NULLs, then try and get the field value
+        if (evsql_result_null(res, row_idx, col_idx)) {
+            if (!col->flags.null_ok)
+                XERROR(err = EINVAL, "r%zu:c%zu: NULL", row_idx, col_idx);
+
+        } else if (evsql_result_field(res, row_idx, col_idx, &value, &length)) {
+            SERROR(err = EINVAL);
+
+        }
+        
+        // read the arg
+        switch (col->type) {
+            case EVSQL_TYPE_BINARY: {
+                struct evsql_item_binary *item_ptr = va_arg(vargs, struct evsql_item_binary *);
+
+                if (value) {
+                    item_ptr->ptr = value;
+                    item_ptr->len = length;
+                }
+            } break;
+
+            case EVSQL_TYPE_STRING: {
+                const char **str_ptr = va_arg(vargs, const char **);
+
+                if (value) {
+                    *str_ptr = value;
+                }
+
+            } break;
+
+            case EVSQL_TYPE_UINT16: {
+                uint16_t *uval_ptr = va_arg(vargs, uint16_t *);
+
+                if (!value) break;
+
+                if (length != sizeof(uint16_t)) XERROR(err = EINVAL, "r%zu:c%zu: wrong size for uint16_t: %zu", row_idx, col_idx, length);
+
+                int16_t sval = ntohs(*((int16_t *) value));
+
+                if (sval < 0) XERROR(err = ERANGE, "r%zu:c%zu: out of range for uint16_t: %hd", row_idx, col_idx, (signed short) sval);
+
+                *uval_ptr = sval;
+            } break;
+            
+            case EVSQL_TYPE_UINT32: {
+                uint32_t *uval_ptr = va_arg(vargs, uint32_t *);
+
+                if (!value) break;
+
+                if (length != sizeof(uint32_t)) XERROR(err = EINVAL, "r%zu:c%zu: wrong size for uint32_t: %zu", row_idx, col_idx, length);
+
+                int32_t sval = ntohl(*((int32_t *) value));
+
+                if (sval < 0) XERROR(err = ERANGE, "r%zu:c%zu: out of range for uint32_t: %ld", row_idx, col_idx, (signed long) sval);
+
+                *uval_ptr = sval;
+            } break;
+            
+            case EVSQL_TYPE_UINT64: {
+                uint64_t *uval_ptr = va_arg(vargs, uint64_t *);
+
+                if (!value) break;
+
+                if (length != sizeof(uint64_t)) XERROR(err = EINVAL, "r%zu:c%zu: wrong size for uint64_t: %zu", row_idx, col_idx, length);
+
+                int64_t sval = ntohq(*((int64_t *) value));
+
+                if (sval < 0) XERROR(err = ERANGE, "r%zu:c%zu: out of range for uint64_t: %lld", row_idx, col_idx, (signed long long) sval);
+
+                *uval_ptr = sval;
+            } break;
+            
+            default:
+                XERROR(err = EINVAL, "r%zu:c%zu: invalid type: %d", row_idx, col_idx, col->type);
+        }
+    }
+
+    // advance row index
+    res->row_offset++;
+
+    // row handled succesfully
+    return 1;
+
+error:
+    return -err;
+}
+
+void evsql_result_end (struct evsql_result *res) {
+    // not much more to it...
+    evsql_result_free(res);
+}
+
+void evsql_result_free (struct evsql_result *res) {
+    // note that the result itself might be NULL...
+    // in the case of internal-error results, these may be free'd multiple times!
+    switch (res->evsql->type) {
+        case EVSQL_EVPQ:
+            if (res->result.pq)
+                return PQclear(res->result.pq);
+
+        default:
+            FATAL("res->evsql->type");
+    }
+}
+
+
--- a/src/util.c	Sun Mar 08 01:16:54 2009 +0200
+++ b/src/util.c	Sun Mar 08 01:33:45 2009 +0200
@@ -5,13 +5,13 @@
 #include "lib/log.h"
 #include "lib/misc.h"
 
-#define _PARAM_TYPE_CASE(typenam) case EVSQL_PARAM_ ## typenam: return #typenam
+#define _PARAM_TYPE_CASE(typenam) case EVSQL_TYPE_ ## typenam: return #typenam
 
 #define _PARAM_VAL_BUF_MAX 120
-#define _PARAM_VAL_CASE(typenam, ...) case EVSQL_PARAM_ ## typenam: if (param->data_raw) ret = snprintf(buf, _PARAM_VAL_BUF_MAX, __VA_ARGS__); else return "(null)"; break
+#define _PARAM_VAL_CASE(typenam, ...) case EVSQL_TYPE_ ## typenam: if (item->bytes) ret = snprintf(buf, _PARAM_VAL_BUF_MAX, __VA_ARGS__); else return "(null)"; break
 
-const char *evsql_param_type (const struct evsql_query_param *param) {
-    switch (param->type) {
+const char *evsql_item_type (const struct evsql_item_info *item_info) {
+    switch (item_info->type) {
         _PARAM_TYPE_CASE (INVALID   );
         _PARAM_TYPE_CASE (NULL_     );
         _PARAM_TYPE_CASE (BINARY    );
@@ -24,18 +24,18 @@
 }
 
 
-static const char *evsql_param_val (const struct evsql_query_param *param) {
+static const char *evsql_item_val (const struct evsql_item *item) {
     static char buf[_PARAM_VAL_BUF_MAX];
     int ret;
 
-    switch (param->type) {
+    switch (item->info.type) {
         _PARAM_VAL_CASE (INVALID,   "???"                               );
         _PARAM_VAL_CASE (NULL_,     "(null)"                            );
-        _PARAM_VAL_CASE (BINARY,    "%zu:%s",   param->length, "..."    );
-        _PARAM_VAL_CASE (STRING,    "%s",       param->data_raw         );
-        _PARAM_VAL_CASE (UINT16,    "%hu",      (unsigned short int)     ntohs(param->data.uint16)  );
-        _PARAM_VAL_CASE (UINT32,    "%lu",      (unsigned long int)      ntohl(param->data.uint32)  );
-        _PARAM_VAL_CASE (UINT64,    "%llu",     (unsigned long long int) ntohq(param->data.uint64)  );
+        _PARAM_VAL_CASE (BINARY,    "%zu:%s",   item->length, "... "    );
+        _PARAM_VAL_CASE (STRING,    "%s",       item->bytes             );
+        _PARAM_VAL_CASE (UINT16,    "%hu",      (unsigned short int)     ntohs(item->value.uint16)  );
+        _PARAM_VAL_CASE (UINT32,    "%lu",      (unsigned long int)      ntohl(item->value.uint32)  );
+        _PARAM_VAL_CASE (UINT64,    "%llu",     (unsigned long long int) ntohq(item->value.uint64)  );
         default: return "???";
     }
 
@@ -43,132 +43,91 @@
 }
 
 int evsql_params_clear (struct evsql_query_params *params) {
-    struct evsql_query_param *param;
+    struct evsql_item *param;
 
-    for (param = params->list; param->type; param++) 
-        param->data_raw = NULL;
+    for (param = params->list; param->info.type; param++) {
+        param->bytes = NULL;
+        param->flags.has_value = 0;
+    }
 
     return 0;
 }
 
-int evsql_param_null   (struct evsql_query_params *params, size_t param) {
-    struct evsql_query_param *p = &params->list[param];
+int evsql_param_null (struct evsql_query_params *params, size_t param) {
+    struct evsql_item *p = &params->list[param];
 
-    p->data_raw = NULL;
+    p->bytes = NULL;
+    p->flags.has_value = 0;
 
     return 0;
 }
 
 int evsql_param_binary (struct evsql_query_params *params, size_t param, const char *ptr, size_t len) {
-    struct evsql_query_param *p = &params->list[param];
+    struct evsql_item *p = &params->list[param];
     
-    assert(p->type == EVSQL_PARAM_BINARY);
+    assert(p->info.type == EVSQL_TYPE_BINARY);
 
-    p->data_raw = ptr;
+    p->bytes = ptr;
     p->length = len;
 
     return 0;
 }
 
 int evsql_param_string (struct evsql_query_params *params, size_t param, const char *ptr) {
-    struct evsql_query_param *p = &params->list[param];
+    struct evsql_item *p = &params->list[param];
     
-    assert(p->type == EVSQL_PARAM_STRING);
+    assert(p->info.type == EVSQL_TYPE_STRING);
+    
+    // XXX: hmm...
+    p->info.format = EVSQL_FMT_TEXT;
 
-    p->data_raw = ptr;
+    p->bytes = ptr;
     p->length = 0;
 
     return 0;
 }
 
 int evsql_param_uint16 (struct evsql_query_params *params, size_t param, uint16_t uval) {
-    struct evsql_query_param *p = &params->list[param];
+    struct evsql_item *p = &params->list[param];
     
-    assert(p->type == EVSQL_PARAM_UINT16);
+    assert(p->info.type == EVSQL_TYPE_UINT16);
 
-    p->data.uint16 = htons(uval);
-    p->data_raw = (const char *) &p->data.uint16;
+    p->value.uint16 = htons(uval);
     p->length = sizeof(uval);
+    p->flags.has_value = 1;
 
     return 0;
 }
 
 int evsql_param_uint32 (struct evsql_query_params *params, size_t param, uint32_t uval) {
-    struct evsql_query_param *p = &params->list[param];
+    struct evsql_item *p = &params->list[param];
     
-    assert(p->type == EVSQL_PARAM_UINT32);
+    assert(p->info.type == EVSQL_TYPE_UINT32);
 
-    p->data.uint32 = htonl(uval);
-    p->data_raw = (const char *) &p->data.uint32;
+    p->value.uint32 = htonl(uval);
     p->length = sizeof(uval);
+    p->flags.has_value = 1;
 
     return 0;
 }
 
 void evsql_query_debug (const char *sql, const struct evsql_query_params *params) {
-    const struct evsql_query_param *param;
+    const struct evsql_item *param;
     size_t param_count = 0, idx = 0;
 
     // count the params
-    for (param = params->list; param->type; param++) 
+    for (param = params->list; param->info.type; param++) 
         param_count++;
     
     DEBUG("sql:     %s", sql);
     DEBUG("params:  %zu", param_count);
 
-    for (param = params->list; param->type; param++) {
-        DEBUG("\t%2zu : %8s = %s", ++idx, evsql_param_type(param), evsql_param_val(param));
+    for (param = params->list; param->info.type; param++) {
+        DEBUG("\t%2zu : %8s = %s", ++idx, evsql_item_type(&param->info), evsql_item_val(param));
     }
 }
 
-const char *evsql_result_error (const struct evsql_result_info *res) {
-    if (!res->error)
-        return "No error";
-
-    switch (res->evsql->type) {
-        case EVSQL_EVPQ:
-            if (!res->result.pq)
-                return "unknown error (no result)";
-            
-            return PQresultErrorMessage(res->result.pq);
-
-        default:
-            FATAL("res->evsql->type");
-    }
-
-}
-
-size_t evsql_result_rows (const struct evsql_result_info *res) {
-    switch (res->evsql->type) {
-        case EVSQL_EVPQ:
-            return PQntuples(res->result.pq);
-
-        default:
-            FATAL("res->evsql->type");
-    }
-}
-
-size_t evsql_result_cols (const struct evsql_result_info *res) {
-    switch (res->evsql->type) {
-        case EVSQL_EVPQ:
-            return PQnfields(res->result.pq);
-
-        default:
-            FATAL("res->evsql->type");
-    }
-}
-
-size_t evsql_result_affected (const struct evsql_result_info *res) {
-    switch (res->evsql->type) {
-        case EVSQL_EVPQ:
-            return strtol(PQcmdTuples(res->result.pq), NULL, 10);
-
-        default:
-            FATAL("res->evsql->type");
-    }
-}
-
-int evsql_result_binary (const struct evsql_result_info *res, size_t row, size_t col, const char **ptr, size_t *size, int nullok) {
+int evsql_result_binary (const struct evsql_result *res, size_t row, size_t col, const char **ptr, size_t *size, bool nullok) {
     *ptr = NULL;
 
     switch (res->evsql->type) {
@@ -196,7 +155,7 @@
     return -1;
 }
 
-int evsql_result_binlen (const struct evsql_result_info *res, size_t row, size_t col, const char **ptr, size_t size, int nullok) {
+int evsql_result_binlen (const struct evsql_result *res, size_t row, size_t col, const char **ptr, size_t size, int nullok) {
     size_t real_size = 0;
 
     if (evsql_result_binary(res, row, col, ptr, &real_size, nullok))
@@ -216,7 +175,7 @@
     return -1;
 }
 
-int evsql_result_string (const struct evsql_result_info *res, size_t row, size_t col, const char **ptr, int nullok) {
+int evsql_result_string (const struct evsql_result *res, size_t row, size_t col, const char **ptr, int nullok) {
     size_t real_size;
 
     if (evsql_result_binary(res, row, col, ptr, &real_size, nullok))
@@ -230,7 +189,7 @@
     return -1;
 }
 
-int evsql_result_uint16 (const struct evsql_result_info *res, size_t row, size_t col, uint16_t *uval, int nullok) {
+int evsql_result_uint16 (const struct evsql_result *res, size_t row, size_t col, uint16_t *uval, int nullok) {
     const char *data;
     int16_t sval;
 
@@ -253,7 +212,7 @@
     return nullok ? 0 : -1;
 }
 
-int evsql_result_uint32 (const struct evsql_result_info *res, size_t row, size_t col, uint32_t *uval, int nullok) {
+int evsql_result_uint32 (const struct evsql_result *res, size_t row, size_t col, uint32_t *uval, int nullok) {
     const char *data;
     int32_t sval;
 
@@ -276,7 +235,7 @@
     return nullok ? 0 : -1;
 }
 
-int evsql_result_uint64 (const struct evsql_result_info *res, size_t row, size_t col, uint64_t *uval, int nullok) {
+int evsql_result_uint64 (const struct evsql_result *res, size_t row, size_t col, uint64_t *uval, int nullok) {
     const char *data;
     int64_t sval;
 
@@ -299,16 +258,6 @@
     return nullok ? 0 : -1;
 }
 
-void evsql_result_free (const struct evsql_result_info *res) {
-    switch (res->evsql->type) {
-        case EVSQL_EVPQ:
-            return PQclear(res->result.pq);
-
-        default:
-            FATAL("res->evsql->type");
-    }
-}
-
 const char *evsql_conn_error (struct evsql_conn *conn) {
     switch (conn->evsql->type) {
         case EVSQL_EVPQ: