Initial commit

All of the files from the tarball downloaded from SourceForge are
being checked in so there's a record of the changes made compared
to it (since I can't find the libcfu source repository). The
generated files will be removed in the following commit.
This commit is contained in:
Matthew Brush
2013-03-04 01:39:33 -08:00
commit f660e3460a
55 changed files with 25776 additions and 0 deletions

13
doc/Makefile.am Normal file
View File

@@ -0,0 +1,13 @@
MAKEINFO = case $@ in \
*.info) echo " INFO $@";; \
*.html) echo " HTML $@";; \
esac && @MAKEINFO@
TEXI2DVI = && case $@ in \
*.dvi) echo " DVI $@";; \
*.pdf) echo " PDF $@";; \
esac && texi2dvi --quiet
DVIPS = echo " PS $@" && dvips -q
info_TEXINFOS = libcfu.texi
.SILENT:

461
doc/Makefile.in Normal file
View File

@@ -0,0 +1,461 @@
# Makefile.in generated by automake 1.9.2 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ..
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
INSTALL = @INSTALL@
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
subdir = doc
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
$(srcdir)/stamp-vti $(srcdir)/version.texi mdate-sh \
texinfo.tex
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_CLEAN_FILES =
SOURCES =
DIST_SOURCES =
INFO_DEPS = $(srcdir)/libcfu.info
am__TEXINFO_TEX_DIR = $(srcdir)
DVIS = libcfu.dvi
PDFS = libcfu.pdf
PSS = libcfu.ps
HTMLS = libcfu.html
TEXINFOS = libcfu.texi
TEXI2PDF = $(TEXI2DVI) --pdf --batch
MAKEINFOHTML = $(MAKEINFO) --html
AM_MAKEINFOHTMLFLAGS = $(AM_MAKEINFOFLAGS)
am__installdirs = "$(DESTDIR)$(infodir)"
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMDEP_FALSE = @AMDEP_FALSE@
AMDEP_TRUE = @AMDEP_TRUE@
AMTAR = @AMTAR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CYGPATH_W = @CYGPATH_W@
DEBUG_FALSE = @DEBUG_FALSE@
DEBUG_TRUE = @DEBUG_TRUE@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
LIBCFU_TYPE_u_int = @LIBCFU_TYPE_u_int@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = case $@ in \
*.info) echo " INFO $@";; \
*.html) echo " HTML $@";; \
esac && @MAKEINFO@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
ac_ct_CC = @ac_ct_CC@
ac_ct_RANLIB = @ac_ct_RANLIB@
ac_ct_STRIP = @ac_ct_STRIP@
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build_alias = @build_alias@
datadir = @datadir@
exec_prefix = @exec_prefix@
host_alias = @host_alias@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
prefix = @prefix@
program_transform_name = @program_transform_name@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
TEXI2DVI = && case $@ in \
*.dvi) echo " DVI $@";; \
*.pdf) echo " PDF $@";; \
esac && texi2dvi --quiet
DVIPS = echo " PS $@" && dvips -q
info_TEXINFOS = libcfu.texi
all: all-am
.SUFFIXES:
.SUFFIXES: .dvi .html .info .pdf .ps .texi
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu doc/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --gnu doc/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
.texi.info:
restore=: && backupdir="$(am__leading_dot)am$$$$" && \
am__cwd=`pwd` && cd $(srcdir) && \
rm -rf $$backupdir && mkdir $$backupdir && \
for f in $@ $@-[0-9] $@-[0-9][0-9] $(@:.info=).i[0-9] $(@:.info=).i[0-9][0-9]; do \
if test -f $$f; then mv $$f $$backupdir; restore=mv; else :; fi; \
done; \
cd "$$am__cwd"; \
if $(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir) \
-o $@ $<; \
then \
rc=0; \
cd $(srcdir); \
else \
rc=$$?; \
cd $(srcdir) && \
$$restore $$backupdir/* `echo "./$@" | sed 's|[^/]*$$||'`; \
fi; \
rm -rf $$backupdir; exit $$rc
.texi.dvi:
TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \
MAKEINFO='$(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir)' \
$(TEXI2DVI) $<
.texi.pdf:
TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \
MAKEINFO='$(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir)' \
$(TEXI2PDF) $<
.texi.html:
rm -rf $(@:.html=.htp)
if $(MAKEINFOHTML) $(AM_MAKEINFOHTMLFLAGS) $(MAKEINFOFLAGS) -I $(srcdir) \
-o $(@:.html=.htp) $<; \
then \
rm -rf $@; \
if test ! -d $(@:.html=.htp) && test -d $(@:.html=); then \
mv $(@:.html=) $@; else mv $(@:.html=.htp) $@; fi; \
else \
if test ! -d $(@:.html=.htp) && test -d $(@:.html=); then \
rm -rf $(@:.html=); else rm -Rf $(@:.html=.htp) $@; fi; \
exit 1; \
fi
$(srcdir)/libcfu.info: libcfu.texi $(srcdir)/version.texi
libcfu.dvi: libcfu.texi $(srcdir)/version.texi
libcfu.pdf: libcfu.texi $(srcdir)/version.texi
libcfu.html: libcfu.texi $(srcdir)/version.texi
$(srcdir)/version.texi: $(srcdir)/stamp-vti
$(srcdir)/stamp-vti: libcfu.texi $(top_srcdir)/configure
@(dir=.; test -f ./libcfu.texi || dir=$(srcdir); \
set `$(SHELL) $(srcdir)/mdate-sh $$dir/libcfu.texi`; \
echo "@set UPDATED $$1 $$2 $$3"; \
echo "@set UPDATED-MONTH $$2 $$3"; \
echo "@set EDITION $(VERSION)"; \
echo "@set VERSION $(VERSION)") > vti.tmp
@cmp -s vti.tmp $(srcdir)/version.texi \
|| (echo "Updating $(srcdir)/version.texi"; \
cp vti.tmp $(srcdir)/version.texi)
-@rm -f vti.tmp
@cp $(srcdir)/version.texi $@
mostlyclean-vti:
-rm -f vti.tmp
maintainer-clean-vti:
-rm -f $(srcdir)/stamp-vti $(srcdir)/version.texi
.dvi.ps:
$(DVIPS) -o $@ $<
uninstall-info-am:
$(PRE_UNINSTALL)
@if (install-info --version && \
install-info --version 2>&1 | sed 1q | grep -i -v debian) >/dev/null 2>&1; then \
list='$(INFO_DEPS)'; \
for file in $$list; do \
relfile=`echo "$$file" | sed 's|^.*/||'`; \
echo " install-info --info-dir='$(DESTDIR)$(infodir)' --remove '$(DESTDIR)$(infodir)/$$relfile'"; \
install-info --info-dir="$(DESTDIR)$(infodir)" --remove "$(DESTDIR)$(infodir)/$$relfile"; \
done; \
else :; fi
@$(NORMAL_UNINSTALL)
@list='$(INFO_DEPS)'; \
for file in $$list; do \
relfile=`echo "$$file" | sed 's|^.*/||'`; \
relfile_i=`echo "$$relfile" | sed 's|\.info$$||;s|$$|.i|'`; \
(if cd "$(DESTDIR)$(infodir)"; then \
echo " rm -f $$relfile $$relfile-[0-9] $$relfile-[0-9][0-9] $$relfile_i[0-9] $$relfile_i[0-9][0-9])"; \
rm -f $$relfile $$relfile-[0-9] $$relfile-[0-9][0-9] $$relfile_i[0-9] $$relfile_i[0-9][0-9]; \
else :; fi); \
done
dist-info: $(INFO_DEPS)
@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
list='$(INFO_DEPS)'; \
for base in $$list; do \
case $$base in \
$(srcdir)/*) base=`echo "$$base" | sed "s|^$$srcdirstrip/||"`;; \
esac; \
if test -f $$base; then d=.; else d=$(srcdir); fi; \
for file in $$d/$$base*; do \
relfile=`expr "$$file" : "$$d/\(.*\)"`; \
test -f $(distdir)/$$relfile || \
cp -p $$file $(distdir)/$$relfile; \
done; \
done
mostlyclean-aminfo:
-rm -rf libcfu.aux libcfu.cp libcfu.cps libcfu.fn libcfu.fns libcfu.ky \
libcfu.kys libcfu.log libcfu.pg libcfu.pgs libcfu.tmp \
libcfu.toc libcfu.tp libcfu.tps libcfu.vr libcfu.vrs \
libcfu.dvi libcfu.pdf libcfu.ps libcfu.html
maintainer-clean-aminfo:
@list='$(INFO_DEPS)'; for i in $$list; do \
i_i=`echo "$$i" | sed 's|\.info$$||;s|$$|.i|'`; \
echo " rm -f $$i $$i-[0-9] $$i-[0-9][0-9] $$i_i[0-9] $$i_i[0-9][0-9]"; \
rm -f $$i $$i-[0-9] $$i-[0-9][0-9] $$i_i[0-9] $$i_i[0-9][0-9]; \
done
tags: TAGS
TAGS:
ctags: CTAGS
CTAGS:
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
list='$(DISTFILES)'; for file in $$list; do \
case $$file in \
$(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
$(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
esac; \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
if test "$$dir" != "$$file" && test "$$dir" != "."; then \
dir="/$$dir"; \
$(mkdir_p) "$(distdir)$$dir"; \
else \
dir=''; \
fi; \
if test -d $$d/$$file; then \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
$(MAKE) $(AM_MAKEFLAGS) \
top_distdir="$(top_distdir)" distdir="$(distdir)" \
dist-info
check-am: all-am
check: check-am
all-am: Makefile $(INFO_DEPS)
installdirs:
for dir in "$(DESTDIR)$(infodir)"; do \
test -z "$$dir" || $(mkdir_p) "$$dir"; \
done
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-generic mostlyclean-am
distclean: distclean-am
-rm -f Makefile
distclean-am: clean-am distclean-generic
dvi: dvi-am
dvi-am: $(DVIS)
html: html-am
html-am: $(HTMLS)
info: info-am
info-am: $(INFO_DEPS)
install-data-am: install-info-am
install-exec-am:
install-info: install-info-am
install-info-am: $(INFO_DEPS)
@$(NORMAL_INSTALL)
test -z "$(infodir)" || $(mkdir_p) "$(DESTDIR)$(infodir)"
@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
list='$(INFO_DEPS)'; \
for file in $$list; do \
case $$file in \
$(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
esac; \
if test -f $$file; then d=.; else d=$(srcdir); fi; \
file_i=`echo "$$file" | sed 's|\.info$$||;s|$$|.i|'`; \
for ifile in $$d/$$file $$d/$$file-[0-9] $$d/$$file-[0-9][0-9] \
$$d/$$file_i[0-9] $$d/$$file_i[0-9][0-9] ; do \
if test -f $$ifile; then \
relfile=`echo "$$ifile" | sed 's|^.*/||'`; \
echo " $(INSTALL_DATA) '$$ifile' '$(DESTDIR)$(infodir)/$$relfile'"; \
$(INSTALL_DATA) "$$ifile" "$(DESTDIR)$(infodir)/$$relfile"; \
else : ; fi; \
done; \
done
@$(POST_INSTALL)
@if (install-info --version && \
install-info --version 2>&1 | sed 1q | grep -i -v debian) >/dev/null 2>&1; then \
list='$(INFO_DEPS)'; \
for file in $$list; do \
relfile=`echo "$$file" | sed 's|^.*/||'`; \
echo " install-info --info-dir='$(DESTDIR)$(infodir)' '$(DESTDIR)$(infodir)/$$relfile'";\
install-info --info-dir="$(DESTDIR)$(infodir)" "$(DESTDIR)$(infodir)/$$relfile" || :;\
done; \
else : ; fi
install-man:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-aminfo \
maintainer-clean-generic maintainer-clean-vti
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-aminfo mostlyclean-generic mostlyclean-vti
pdf: pdf-am
pdf-am: $(PDFS)
ps: ps-am
ps-am: $(PSS)
uninstall-am: uninstall-info-am
.PHONY: all all-am check check-am clean clean-generic dist-info \
distclean distclean-generic distdir dvi dvi-am html html-am \
info info-am install install-am install-data install-data-am \
install-exec install-exec-am install-info install-info-am \
install-man install-strip installcheck installcheck-am \
installdirs maintainer-clean maintainer-clean-aminfo \
maintainer-clean-generic maintainer-clean-vti mostlyclean \
mostlyclean-aminfo mostlyclean-generic mostlyclean-vti pdf \
pdf-am ps ps-am uninstall uninstall-am uninstall-info-am
.SILENT:
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

956
doc/libcfu.info Normal file
View File

@@ -0,0 +1,956 @@
This is libcfu.info, produced by makeinfo version 4.7 from libcfu.texi.
Copyright (C) 2005 Don Owens
This code is released under the BSD license:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided with
the distribution.
* Neither the name of the author nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
INFO-DIR-SECTION Libraries
START-INFO-DIR-ENTRY
* Libcfu: (libcfu). The cfu library.
END-INFO-DIR-ENTRY
This manual describes the external interface to libcfu version
0.03
Copyright (C) 2005 Don Owens All rights reserved.
This code is released under the BSD license:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided with
the distribution.
* Neither the name of the author nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

File: libcfu.info, Node: Top, Next: Data structures, Prev: (dir), Up: (dir)
This manual describes the interface to libcfu version 0.03
Copyright (C) 2005 Don Owens
* Menu:
* Data structures::
* Conf:: For reading configuration files
* Options:: For parsing command-line arguments
* Thread queue:: For queueing up requests for a separate thread
* Timer:: An easy to use timer
* License:: License under which libcfu is distributed
* Concept index::
* Function index::

File: libcfu.info, Node: Data structures, Prev: Top, Up: Top
1 Data structures
*****************
* Menu:
* Hash table:: For key/value pairs
* Linked list:: For unordered data
* Strings:: For self-extending strings

File: libcfu.info, Node: Hash table, Next: Linked list, Prev: Data structures, Up: Data structures
1.1 Hash table
==============
-- Special Form: typedef u_int32_t (*cfuhash_function_t)(const void *
KEY, size_t LENGTH)
Prototype for a pointer to a hashing function.
-- Special Form: typedef void (*cfuhash_free_fn_t)(void * DATA)
Prototype for a pointer to a free function.
-- Special Form: typedef int (*cfuhash_remove_fn_t)(void * KEY, size_t
KEY_SIZE, void * DATA, size_t DATA_SIZE, void * ARG)
Prototype for a pointer to a function that determines whether or
not to remove an entry from the hash.
-- Special Form: typedef int (*cfuhash_foreach_fn_t)(void * KEY,
size_t KEY_SIZE, void * DATA, size_t DATA_SIZE, void * ARG)
Prototype for a pointer to a function to be called foreach
key/value pair in the hash by cfuhash_foreach(). The return
value should normally be zero. A non-zero return value means to
stop iterating over the key/value pairs.
-- Function: cfuhash_table_t * cfuhash_new (size_t SIZE, u_int32_t
FLAGS)
Creates a new hash table.
-- Function: cfuhash_table_t * cfuhash_new_with_initial_size (size_t
SIZE)
Creates a new hash table with the specified size (number of
buckets).
-- Function: cfuhash_table_t * cfuhash_new_with_flags (u_int32_t FLAGS)
Creates a new hash table with the specified flags. Pass zero for
flags if you want the defaults.
-- Function: cfuhash_table_t * cfuhash_new_with_free_fn (size_t SIZE,
u_int32_t FLAGS, cfuhash_free_fn_t FF)
Same as cfuhash_new() except automatically calls
cfuhash_set_free_fn().
-- Function: int cfuhash_copy (cfuhash_table_t * SRC, cfuhash_table_t
* DST)
Copies entries in src to dst
-- Function: cfuhash_table_t * cfuhash_merge (cfuhash_table_t * HT1,
cfuhash_table_t * HT2, u_int32_t FLAGS)
Returns a new hash containing entries from both hash tables. For
any entries with the same key, the one from ht2 wins.
-- Function: int cfuhash_set_hash_function (cfuhash_table_t * HT,
cfuhash_function_t HF)
Sets the hashing function to use when computing which bucket to add
entries to. It should return a 32-bit unsigned integer. By
default, Perl's hashing algorithm is used.
-- Function: int cfuhash_set_thresholds (cfuhash_table_t * HT, float
LOW, float HIGH)
Sets the thresholds for when to rehash. The ratio
num_entries/buckets is compared against low and high. If it is
below 'low' or above 'high', the hash will shrink or grow,
respectively, unless the flags say to do otherwise.
-- Function: int cfuhash_set_free_function (cfuhash_table_t * HT,
cfuhash_free_fn_t FF)
Sets the function to use when removing an entry from the hash,
i.e., when replacing an existing entry, deleting an entry, or
clearing the hash. It is passed the value of the entry as a void
*.
-- Function: u_int32_t cfuhash_get_flags (cfuhash_table_t * HT)
Returns the hash's flags. See below for flag definitions.
-- Function: u_int32_t cfuhash_set_flag (cfuhash_table_t * HT,
u_int32_t FLAG)
Sets a flag.
-- Function: u_int32_t cfuhash_clear_flag (cfuhash_table_t * HT,
u_int32_t NEW_FLAG)
Clears a flag.
-- Function: int cfuhash_get_data (cfuhash_table_t * HT, const void *
KEY, size_t KEY_SIZE, void ** DATA, size_t * DATA_SIZE)
Returns the value for the entry with given key. If key_size is -1,
key is assumed to be a null-terminated string. If data_size is
not NULL, the size of the value is placed into data_size.
-- Function: int cfuhash_exists_data (cfuhash_table_t * HT, const void
* KEY, size_t KEY_SIZE)
Returns 1 if an entry with the given key exists in the hash, 0
otherwise.
-- Function: int cfuhash_put_data (cfuhash_table_t * HT, const void *
KEY, size_t KEY_SIZE, void * DATA, size_t DATA_SIZE, void **
R)
Inserts the given data value into the hash and associates it with
key. If key_size is -1, key is assumed to be a null-terminated
string. If data_size is -1, it is assumed to be a null-terminated
string (it's length will be calculated using strlen). If
data_size is zero, it will be returned as zero when the value is
requested.
-- Function: void cfuhash_clear (cfuhash_table_t * HT)
Clears the hash table (deletes all entries).
-- Function: void * cfuhash_delete_data (cfuhash_table_t * HT, const
void * KEY, size_t KEY_SIZE)
Deletes the entry in the hash associated with key. If the entry
existed, it's value will be returned.
-- Function: void **cfuhash_keys_data (cfuhash_table_t * HT, size_t *
NUM_KEYS, size_t ** KEY_SIZES, int FAST)
Returns all the keys from the hash. The number of keys is placed
into the value pointed to by num_keys. If key_sizes is not NULL,
it will be set to an array of key sizes. If fast is zero, copies
of the keys are returned. Otherwise, pointers to the real keys
will be returned.
-- Function: int cfuhash_each_data (cfuhash_table_t * HT, void ** KEY,
size_t * KEY_SIZE, void ** DATA, size_t * DATA_SIZE)
Initializes a loop over all the key/value pairs in the hash. It
returns the first key/value pair (see cfuhash_next_data()). 1 is
returned if there are any entries in the hash. 0 is returned
otherwise.
-- Function: int cfuhash_next_data (cfuhash_table_t * HT, void ** KEY,
size_t * KEY_SIZE, void ** DATA, size_t * DATA_SIZE)
Gets the next key/value pair from the hash. You must initialize
the loop using cfuhash_each_data() before calling this function.
If a entry is left to return, 1 is returned from the function. 0
is returned if there are no more entries in the hash.
-- Function: size_t cfuhash_foreach_remove (cfuhash_table_t * HT,
cfuhash_remove_fn_t R_FN, cfuhash_free_fn_t FF, void * ARG)
Iterates over the key/value pairs in the hash, passing each one
to r_fn, and removes all entries for which r_fn returns true. If
ff is not NULL, it is the passed the data to be freed. arg is
passed to r_fn.
-- Function: size_t cfuhash_foreach (cfuhash_table_t * HT,
cfuhash_foreach_fn_t FE_FN, void * ARG)
Iterates over the key/value pairs in the hash, passing each one
to fe_fn, along with arg. This locks the hash, so do not call any
operations on the hash from within fe_fn unless you really know
what you're doing.
If the return value from fe_fn() is not zero, the iteration stops.
-- Function: int cfuhash_destroy (cfuhash_table_t * HT)
Frees all resources allocated by the hash.
-- Function: int cfuhash_destroy_with_free_fn (cfuhash_table_t * HT,
cfuhash_free_fn_t FF)
Frees all resources allocated by the hash. If ff is not NULL, it
is called for each hash entry with the value of the entry passed as
its only argument. If ff is not NULL, it overrides any function
set previously with cfuhash_set_free_function().
-- Function: int cfuhash_rehash (cfuhash_table_t * HT)
Rebuild the hash to better accomodate the number of entries. See
cfuhash_set_thresholds().
-- Function: size_t cfuhash_num_entries (cfuhash_table_t * HT)
Returns the number entries in the hash.
-- Function: size_t cfuhash_num_buckets (cfuhash_table_t * HT)
Returns the number of buckets allocated for the hash.
-- Function: size_t cfuhash_num_buckets_used (cfuhash_table_t * HT)
Returns the number of buckets actually used out of the total number
allocated for the hash.
-- Function: char * cfuhash_bencode_strings (cfuhash_table_t * HT)
Assumes all the keys and values are null-terminated strings and
returns a bencoded string representing the hash (see
http://www.bittorrent.com/protocol.html)
-- Function: int cfuhash_lock (cfuhash_table_t * HT)
Locks the hash. Use this with the each and next functions for
concurrency control. Note that the hash is locked automatically
when doing inserts and deletes, so if you lock the hash and then
try to insert something into it, you may get into a deadlock,
depending on your system defaults for how mutexes work.
-- Function: int cfuhash_unlock (cfuhash_table_t * HT)
Unlocks the hash. Use this with the each an next functions for
concurrency control. The caveat for cfuhash_lock() also applies to
this function.
-- Function: int cfuhash_pretty_print (cfuhash_table_t * HT, FILE * FP)
Pretty print the hash's key/value pairs to the stream fp. It is
assumed that all the keys and values are null-terminated strings.
These are like the _data versions of these functions, with the
following exceptions:
1) They assume that the key provided is a null-terminated string.
2) They don't worry about the size of the data.
3) Returned keys or values are the return value of the function.
-- Function: void * cfuhash_get (cfuhash_table_t * HT, const char *
KEY)
-- Function: int cfuhash_exists (cfuhash_table_t * HT, const char *
KEY);
-- Function: void * cfuhash_put (cfuhash_table_t * HT, const char *
KEY, void * DATA);
-- Function: void * cfuhash_delete (cfuhash_table_t * HT, const char *
KEY);
-- Function: int cfuhash_each (cfuhash_table_t * HT, char ** KEY, void
** DATA);
-- Function: int cfuhash_next (cfuhash_table_t * HT, char ** KEY, void
** DATA);
-- Function: void ** cfuhash_keys (cfuhash_table_t * HT, size_t *
NUM_KEYS, int FAST);
Valid flags for cfuhash_new() or cfuhash_set_flag):
-- CFUHASH_NOCOPY_KEYS:
Don't copy the key when adding an entry to the hash table.
-- CFUHASH_NO_LOCKING:
Don't not use any mutexes. Beware that this flag makes the hash
table non thread-safe.
-- CFUHASH_FROZEN:
Do not rehash (don't grow or shrink the number of buckets in the
hash table when the thresholds are reached).
-- CFUHASH_FROZEN_UNTIL_GROWS:
Do not rehash until the upper threshold is reached the first time
(useful for preallocating a large hash to avoid rehashing while
filling it).
-- CFUHASH_FREE_DATA:
Call free() on the values when cfuhash_destroy() is called.
-- CFUHASH_IGNORE_CASE:
Treat the keys case-insensitively.

File: libcfu.info, Node: Linked list, Next: Strings, Prev: Hash table, Up: Data structures
1.2 Linked list
===============
-- Special Form: typedef int (*cfulist_foreach_fn_t)(void * DATA,
size_t DATA_SIZE, void * ARG)
Function called for each element in the list when passed to
cfulist_foreach(). A non-zero return value means to stop
iteration.
-- Special Form: typedef void * (*cfulist_map_fn_t)(void *DATA, size_t
DATA_SIZE, void *ARG, size_t *NEW_DATA_SIZE)
Function called for each element in the list when passed to
cfulist_map(). The return value is used to build a new list.
-- Special Form: typedef void (*cfulist_free_fn_t)(void * DATA)
Function called to free the data in an element.
-- Function: cfulist_t * cfulist_new ();
Returns a new list.
-- Function: size_t cfulist_num_entries (cfulist_t *LIST)
Returns the number of entries in the list.
-- Function: int cfulist_push_data (cfulist_t * LIST, void * DATA,
size_t DATA_SIZE)
Push a value onto the end of the list.
-- Function: int cfulist_pop_data (cfulist_t * LIST, void ** DATA,
size_t * DATA_SIZE)
Pop a value from the end of the list (removing it from the list).
-- Function: int cfulist_unshift_data (cfulist_t * LIST, void * DATA,
size_t DATA_SIZE)
Add a value at the beginning of the list.
-- Function: int cfulist_shift_data (cfulist_t * LIST, void ** DATA,
size_t * DATA_SIZE)
Shift a value off the beginning of the list.
-- Function: int cfulist_enqueue_data (cfulist_t * LIST, void * DATA,
size_t DATA_SIZE)
Add a value at the end of the queue (equivalent to push)
-- Function: int cfulist_dequeue_data (cfulist_t * LIST, void ** DATA,
size_t * DATA_SIZE)
Remove the value at the beginning of the list (equivalent to
shift).
-- Function: int cfulist_first_data (cfulist_t * LIST, void ** DATA,
size_t * DATA_SIZE);
Return the first entry from the list (without removing it from the
list).
-- Function: int cfulist_last_data (cfulist_t * LIST, void ** DATA,
size_t * DATA_SIZE);
Return the last entry from the list (without removing it from the
list).
-- Function: int cfulist_nth_data (cfulist_t * LIST, void ** DATA,
size_t * DATA_SIZE, size_t N);
Return the nth entry from the list (without removing it from the
list). n starts at zero.
-- Function: void cfulist_reset_each (cfulist_t * LIST);
-- Function: int cfulist_each_data (cfulist_t * LIST, void ** DATA,
size_t * DATA_SIZE);
-- Function: int cfulist_next_data (cfulist_t * LIST, void ** DATA,
size_t * DATA_SIZE);
-- Function: size_t cfulist_foreach (cfulist_t * LIST,
cfulist_foreach_fn_t FE_FN, void * ARG);
Calls fe_fn() for each element in the list. Also passes arg on each
call. Do not try to manipulate the list inside fe_fn(), as the
list will be locked.
If fe_fn() returns a non-zero value, the iteration over the
elements stops.
-- Function: cfulist_t * cfulist_map (cfulist_t *LIST,
cfulist_map_fn_t MAP_FN, void *ARG);
Creates a new list from the list passed in. Calls map_fn() on each
element in the list. The return value is placed in the
corresponding position in the new list.
-- Function: void cfulist_destroy (cfulist_t * LIST)
Free all resources used by the list.
-- Function: void cfulist_destroy (cfulist_t * LIST, cfulist_free_fn_t
FREE_FN)
Free all resources used by the list. If free_fn is not NULL, call
it for each element of the list, passing the data to it as a void
*.
When you don't care about the size of the data
-- Function: int cfulist_push (cfulist_t * LIST, void * DATA)
-- Function: void * cfulist_pop (cfulist_t * LIST);
-- Function: int cfulist_unshift (cfulist_t * LIST, void * DATA);
-- Function: void * cfulist_shift (cfulist_t * LIST);
-- Function: int cfulist_enqueue (cfulist_t * IST, void * DATA);
-- Function: void * cfulist_dequeue (cfulist_t * LIST);
Strings - assume data is a null-terminated string - size is
calculated by strlen(data) + 1
-- Function: int cfulist_push_string (cfulist_t * LIST, char * DATA)
-- Function: char * cfulist_pop_string (cfulist_t * LIST);
-- Function: int cfulist_unshift_string (cfulist_t * LIST, char *
DATA);
-- Function: char * cfulist_shift_string (cfulist_t * LIST);
-- Function: int cfulist_enqueue_string (cfulist_t * LIST, char *
DATA);
-- Function: char * cfulist_dequeue_string (cfulist_t * LIST);
-- Function: char * cfulist_join (cfulist_t * LIST, const char *
DELIMITER)

File: libcfu.info, Node: Strings, Prev: Linked list, Up: Data structures
1.3 Strings
===========
-- Function: cfustring_t * cfustring_new (size_t INITIAL_SIZE)
Returns a new String.
-- Function: cfustring_t * cfustring_new_from_string (const char *
STRING)
Returns a new String initalized with the given string.
-- Function: int cfustring_dup (cfustring_t * CFU_STR, const char *
STRING)
Overwrite anything currently in cfu_str with string.
-- Function: int cfustring_clear (cfustring_t * CFU_STR)
Truncate the string.
-- Function: int cfustring_append (cfustring_t * CFU_STR, const char *
STR)
Append str to the end of the buffer in cfu_str.
-- Function: char * cfustring_get_buffer (cfustring_t * CFU_STR)
Get the buffer used to hold the string. Do not free() it, as it is
used directly by cfustring and will be destroyed when
cfustring_destroy() is called.
-- Function: char * cfustring_get_buffer_copy (cfustring_t * CFU_STR)
Same as cfustring_get_buffer(), except return a copy of the string.
Caller is responsible for deallocating the buffer with free().
-- Function: cfustring_t ** cfustring_split (cfustring_t * CFU_STR,
size_t * NUM_STRINGS, size_t LIMIT, ...)
Split cfu_str on one or more delimiting strings, e.g.,
cfustring_split(cfu_str, 2, 0, "\r\n", "\n"). Use a limit > 0 if
you want to only get back a certain number of strings and ignore
any extra delimiters.
-- Function: char ** cfustring_split_to_c_str (cfustring_t * CFU_STR,
size_t * NUM_STRINGS, size_t LIMIT, ...)
Same as cfustring_split(), except return an array of C-strings.
Caller is responsible for deallocating the buffers.
-- Function: int cfustring_destroy (cfustring_t * CFU_STR)
Free all resources allocated by cfu_str.
-- Function: char * cfustring_dup_c_str (const char * STR)
Duplicate the C string str. Caller must free with free().
-- Function: char * cfustring_dup_c_str_n (const char * STR, size_t N)
Same as cfustring_dup_c_str(), but only copy at most n chars
-- Function: size_t cfustring_sprintf (cfustring_t * CFU_STR, const
char * FMT, ...);
Like sprintf(), but writes to a self-extending string.
-- Function: size_t cfustring_vsprintf (cfustring_t * CFU_STR, const
char * FMT, va_list AP);
Like vsprintf(), but writes to a self-extending string.
-- Function: char * cfustring_sprintf_c_str (const char * FMT, ...)
Similar to sprintf(), but allocates a C string of the appropriate
size for you and returns it.
-- Function: char ** cfustring_c_str_split (const char * C_STR, size_t
* NUM_STRINGS, size_t LIMIT, ...)
Like cfustring_split_to_c_str(), but split a char * instead of a
cfustring_t *.

File: libcfu.info, Node: Conf, Next: Options, Prev: Top, Up: Top
2 Conf
******
This needs to be better documented.
Apache-style conf files contain directives and containers.
Directives are simple one line specifications with or without
arguments, e.g.,
Doit Expires On LoadModule my_mod modules/my_mod.so
Containers have a type and a name associated with them and they in
turn contain directives and/or containers, e.g.,
<MyContainer test1> Expires Off <DB devdb>
DBHost db.example.com DBUser
test_user </DB> </MyContainer>
Values may be quoted, e.g.
DBUser "test user"
But must be specified on a single line. To escape quotes within a
quoted string, use the '\' character.
-- Function: int cfuconf_parse_file (char * FILE_PATH, cfuconf_t **
CONF, char ** ERROR)
Parse the apache-like conf file specified by file_path, returning
a pointer to a cfuconf_t structure in conf. Returns zero on
success, less than zero on error. If an error occurs and error
is not NULL, it will be set to an error message (which must be
free()'d by the caller).
-- Function: int cfuconf_parse_buffer (char * BUFFER, cfuconf_t **
CONF, char ** ERROR)
Same as cfuconf_parse_file(), except assume the contents of the
file are already in buffer.
-- Function: void cfuconf_destroy (cfuconf_t * CONF)
Free all resources used by the cfuconf_t structure
-- Function: cfuhash_table_t * cfuconf_get_containers (cfuconf_t *
CONF)
Get a hash of containers at the top level of conf
-- Function: cfuhash_table_t * cfuconf_get_directives (cfuconf_t *
CONF)
Get a hash of directives at the to level
-- Function: int cfuconf_get_directive_one_arg (cfuconf_t * CONF, char
* DIRECTIVE, char ** RVALUE)
Get the value of the given directive, assuming there is only one
argument
-- Function: int cfuconf_get_directive_two_args (cfuconf_t * CONF,
char * DIRECTIVE, char ** RVALUE, char ** RVALUE2)
Get the value of the given directive, assuming there are two
arguments
-- Function: int cfuconf_get_directive_n_args (cfuconf_t * CONF, char
* DIRECTIVE, size_t N, ...)
Get the value of the given directives, with n arguments

File: libcfu.info, Node: Options, Next: Thread queue, Prev: Conf, Up: Top
3 Options
*********
Command-line arguments can be parsed with the following:
cfuopt_t *opt = cfuopt_new();
cfuopt_add_entry(opt, "verbose|v!", &verbose, "Verbosity", "");
cfuopt_add_entry(opt, "file|f:s", &file, "File to load", "FILE");
cfuopt_add_entry(opt, "count|c|n=i", &count, "Count to run", "COUNT");
cfuopt_add_entry(opt, "scale|s:f", &scale, "Scaling factor", "SCALE");
cfuopt_parse(opt, &argc, &argv, &error);
/* do stuff here with the options */
cfuopt_destroy(opt);
free(file);
-- Function: cfuopt_t * cfuopt_new ()
Returns a new options context.
-- Function: void cfuopt_add_entry (cfuopt_t *CONTEXT, const char
*OPT_STR, void *ARG_DATA, const char *DESCRIPTION, const char
*ARG_DESCRIPTION)
Adds to the list of known options.
-- Function: void cfuopt_parse (cfuopt_t *CONTEXT, int *ARGC, char
***ARGV, char **ERROR)
Parses the command line and modifies argc and argv to account for
left over arguments.
-- Function: char * cfuopt_get_help_str (cfuopt_t *CONTEXT)
Returns a help string built from the entries added with
cfuopt_add_entry().
-- Function: void cfuopt_destroy (cfuopt_t *CONTEXT)
Frees up resources used by the option parser.

File: libcfu.info, Node: Thread queue, Next: Timer, Prev: Options, Up: Top
4 Thread queue
**************
cfuthread_queue provides a way to serialize requests for a resource
where you want the resource to be accessed from a single thread only.
For instance, for a database connection where making calls in separate
threads does not work properly, you can use cfuthread_queue.
cfuthread_queue_new() creates a new thread that waits for something to
be added to the queue. Once something is added, the thread will
process the data by calling the function you pass as an argument to the
cfuthread_queue_new() function.
-- Function: cfuthread_queue_t * cfuthread_queue_new
(cfuthread_queue_fn_t FN)
Creates a new thread queue structure that will run the given
function when a request is received.
-- Function: cfuthread_queue_t * cfuthread_queue_new_with_cleanup
(cfuthread_queue_fn_t FN, cfuthread_queue_init_t INIT_FN,
void * INIT_ARG, cfuthread_queue_cleanup_t CLEANUP_FN, void *
CLEANUP_ARG)
Same as cfuthread_queue_new(), but with an initialization
function that gets called with the argument init_arg when the
thread is created, and a cleanup function that gets called with
the argument cleanup_arg when the thread exits, e.g., when
cfuthread_queue_destroy() is called.
-- Function: void * cfuthread_queue_make_request (cfuthread_queue_t *
TQ, void * DATA)
Add a request to the queue. data will get passed to the function
fn given to cfuthread_queue_new when it reaches the front of the
queue.
-- Function: void cfuthread_queue_destroy (cfuthread_queue_t * TQ)
Free up resources used by the queue, in addition to canceling the
thread.

File: libcfu.info, Node: Timer, Next: License, Prev: Thread queue, Up: Top
5 Timer
*******
-- Function: cfutime_t *cfutime_new ();
Return a new cfutime structure.
-- Function: void cfutime_begin (cfutime_t *TIME)
Start the timer.
-- Function: void cfutime_end (cfutime_t * TIME)
Stop the timer.
-- Function: double cfutime_elapsed (cfutime_t * TIME)
Return the number of seconds elapsed as a double.
-- Function: void cfutime_free (cfutime_t * TIME)
Deallocate resources allocated for time.

File: libcfu.info, Node: License, Prev: Timer, Up: Top
License
*******
Copyright (C) 2005 Don Owens All rights reserved.
This code is released under the BSD license:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided with
the distribution.
* Neither the name of the author nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

File: libcfu.info, Node: Concept index, Next: Function index, Prev: Top, Up: Top
Concept index
*************
[index]
* Menu:
* apache configuration file: Conf. (line 6)
* arguments: Options. (line 6)
* command-line arguments: Options. (line 6)
* configuration file: Conf. (line 6)
* data structures: Data structures. (line 6)
* hash tables: Hash table. (line 6)
* license: License. (line 6)
* linked list: Linked list. (line 6)
* options: Options. (line 6)
* queues: Linked list. (line 6)
* self-extending strings: Strings. (line 6)
* strings: Strings. (line 6)
* thread queue: Thread queue. (line 6)
* threading: Thread queue. (line 6)
* timer: Timer. (line 6)

File: libcfu.info, Node: Function index, Prev: Concept index, Up: Top
Function index
**************
[index]
* Menu:
* **cfuhash_keys_data: Hash table. (line 122)
* *cfutime_new: Timer. (line 7)
* cfuconf_destroy: Conf. (line 44)
* cfuconf_get_containers: Conf. (line 48)
* cfuconf_get_directive_n_args: Conf. (line 66)
* cfuconf_get_directive_one_arg: Conf. (line 56)
* cfuconf_get_directive_two_args: Conf. (line 61)
* cfuconf_get_directives: Conf. (line 52)
* cfuconf_parse_buffer: Conf. (line 39)
* cfuconf_parse_file: Conf. (line 30)
* cfuhash_bencode_strings: Hash table. (line 192)
* cfuhash_clear: Hash table. (line 112)
* cfuhash_clear_flag: Hash table. (line 86)
* cfuhash_copy: Hash table. (line 46)
* cfuhash_delete: Hash table. (line 236)
* cfuhash_delete_data: Hash table. (line 116)
* cfuhash_destroy: Hash table. (line 164)
* cfuhash_destroy_with_free_fn: Hash table. (line 169)
* cfuhash_each: Hash table. (line 239)
* cfuhash_each_data: Hash table. (line 131)
* cfuhash_exists: Hash table. (line 230)
* cfuhash_exists_data: Hash table. (line 97)
* cfuhash_foreach: Hash table. (line 155)
* cfuhash_foreach_remove: Hash table. (line 147)
* cfuhash_get: Hash table. (line 227)
* cfuhash_get_data: Hash table. (line 90)
* cfuhash_get_flags: Hash table. (line 78)
* cfuhash_keys: Hash table. (line 245)
* cfuhash_lock: Hash table. (line 198)
* cfuhash_merge: Hash table. (line 50)
* cfuhash_new: Hash table. (line 27)
* cfuhash_new_with_flags: Hash table. (line 36)
* cfuhash_new_with_free_fn: Hash table. (line 41)
* cfuhash_new_with_initial_size: Hash table. (line 31)
* cfuhash_next: Hash table. (line 242)
* cfuhash_next_data: Hash table. (line 139)
* cfuhash_num_buckets: Hash table. (line 184)
* cfuhash_num_buckets_used: Hash table. (line 187)
* cfuhash_num_entries: Hash table. (line 181)
* cfuhash_pretty_print: Hash table. (line 212)
* cfuhash_put: Hash table. (line 233)
* cfuhash_put_data: Hash table. (line 103)
* cfuhash_rehash: Hash table. (line 176)
* cfuhash_set_flag: Hash table. (line 82)
* cfuhash_set_free_function: Hash table. (line 71)
* cfuhash_set_hash_function: Hash table. (line 56)
* cfuhash_set_thresholds: Hash table. (line 63)
* cfuhash_unlock: Hash table. (line 206)
* cfulist_dequeue: Linked list. (line 112)
* cfulist_dequeue_data: Linked list. (line 49)
* cfulist_dequeue_string: Linked list. (line 129)
* cfulist_destroy: Linked list. (line 91)
* cfulist_each_data: Linked list. (line 71)
* cfulist_enqueue: Linked list. (line 110)
* cfulist_enqueue_data: Linked list. (line 45)
* cfulist_enqueue_string: Linked list. (line 127)
* cfulist_first_data: Linked list. (line 54)
* cfulist_foreach: Linked list. (line 77)
* cfulist_join: Linked list. (line 132)
* cfulist_last_data: Linked list. (line 59)
* cfulist_map: Linked list. (line 86)
* cfulist_new: Linked list. (line 21)
* cfulist_next_data: Linked list. (line 74)
* cfulist_nth_data: Linked list. (line 64)
* cfulist_num_entries: Linked list. (line 24)
* cfulist_pop: Linked list. (line 104)
* cfulist_pop_data: Linked list. (line 33)
* cfulist_pop_string: Linked list. (line 119)
* cfulist_push: Linked list. (line 102)
* cfulist_push_data: Linked list. (line 29)
* cfulist_push_string: Linked list. (line 117)
* cfulist_reset_each: Linked list. (line 68)
* cfulist_shift: Linked list. (line 108)
* cfulist_shift_data: Linked list. (line 41)
* cfulist_shift_string: Linked list. (line 124)
* cfulist_unshift: Linked list. (line 106)
* cfulist_unshift_data: Linked list. (line 37)
* cfulist_unshift_string: Linked list. (line 122)
* cfuopt_add_entry: Options. (line 25)
* cfuopt_destroy: Options. (line 37)
* cfuopt_get_help_str: Options. (line 33)
* cfuopt_new: Options. (line 20)
* cfuopt_parse: Options. (line 29)
* cfustring_append: Strings. (line 22)
* cfustring_c_str_split: Strings. (line 72)
* cfustring_clear: Strings. (line 18)
* cfustring_destroy: Strings. (line 50)
* cfustring_dup: Strings. (line 15)
* cfustring_dup_c_str: Strings. (line 53)
* cfustring_dup_c_str_n: Strings. (line 56)
* cfustring_get_buffer: Strings. (line 25)
* cfustring_get_buffer_copy: Strings. (line 31)
* cfustring_new: Strings. (line 7)
* cfustring_new_from_string: Strings. (line 11)
* cfustring_split: Strings. (line 37)
* cfustring_split_to_c_str: Strings. (line 45)
* cfustring_sprintf: Strings. (line 60)
* cfustring_sprintf_c_str: Strings. (line 67)
* cfustring_vsprintf: Strings. (line 64)
* cfuthread_queue_destroy: Thread queue. (line 40)
* cfuthread_queue_make_request: Thread queue. (line 34)
* cfuthread_queue_new: Thread queue. (line 17)
* cfuthread_queue_new_with_cleanup: Thread queue. (line 25)
* cfutime_begin: Timer. (line 10)
* cfutime_elapsed: Timer. (line 16)
* cfutime_end: Timer. (line 13)
* cfutime_free: Timer. (line 19)
* typedef <1>: Linked list. (line 8)
* typedef: Hash table. (line 8)

Tag Table:
Node: Top3327
Node: Data structures3837
Node: Hash table4065
Node: Linked list14625
Node: Strings19375
Node: Conf22220
Node: Options24608
Node: Thread queue25950
Node: Timer27721
Node: License28255
Node: Concept index29869
Node: Function index31103

End Tag Table

969
doc/libcfu.texi Normal file
View File

@@ -0,0 +1,969 @@
\input texinfo
@c %**start of header
@iftex
@afourpaper
@setchapternewpage off
@end iftex
@setfilename libcfu.info
@settitle Libcfu Programmers Guide
@c %**end of header
@include version.texi
Copyright @copyright{} 2005 Don Owens
This code is released under the BSD license:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of the author nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
OF THE POSSIBILITY OF SUCH DAMAGE.
@ifinfo
@dircategory Libraries
@direntry
* Libcfu: (libcfu). The cfu library.
@end direntry
@end ifinfo
@ifinfo
This manual describes the external interface to libcfu version @value{VERSION}
Copyright @copyright{} 2005 Don Owens
All rights reserved.
This code is released under the BSD license:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of the author nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
OF THE POSSIBILITY OF SUCH DAMAGE.
@end ifinfo
@titlepage
@title Libcfu Programmers Guide
@subtitle Version @value{VERSION}
@author Don Owens
@page
@vskip 0pt plus 1filll
Copyright @copyright{} 2005 Don Owens
All rights reserved.
This code is released under the BSD license:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of the author nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
OF THE POSSIBILITY OF SUCH DAMAGE.
@end titlepage
@node Top, Data structures, (dir), (dir)
@ifinfo
This manual describes the interface to libcfu version @value{VERSION}
Copyright @copyright{} 2005 Don Owens
@end ifinfo
@menu
* Data structures::
* Conf:: For reading configuration files
* Options:: For parsing command-line arguments
* Thread queue:: For queueing up requests for a separate thread
* Timer:: An easy to use timer
* License:: License under which libcfu is distributed
* Concept index::
* Function index::
@end menu
@node Data structures, , Top, Top
@chapter Data structures
@cindex data structures
@menu
* Hash table:: For key/value pairs
* Linked list:: For unordered data
* Strings:: For self-extending strings
@end menu
@node Hash table, Linked list, Data structures, Data structures
@section Hash table
@cindex hash tables
@defspec typedef u_int32_t (*cfuhash_function_t)(const void * @var{key}, size_t @var{length})
Prototype for a pointer to a hashing function.
@end defspec
@defspec typedef void (*cfuhash_free_fn_t)(void * @var{data})
Prototype for a pointer to a free function.
@end defspec
@defspec typedef int (*cfuhash_remove_fn_t)(void * @var{key}, size_t @var{key_size}, void * @var{data}, size_t @var{data_size}, void * @var{arg})
Prototype for a pointer to a function that determines whether or not to remove an entry from the hash.
@end defspec
@defspec typedef int (*cfuhash_foreach_fn_t)(void * @var{key}, size_t @var{key_size}, void * @var{data}, size_t @var{data_size}, void * @var{arg})
Prototype for a pointer to a function to be called foreach key/value
pair in the hash by cfuhash_foreach(). The return value should
normally be zero. A non-zero return value means to stop iterating
over the key/value pairs.
@end defspec
@deftypefun {cfuhash_table_t *} cfuhash_new (size_t @var{size}, u_int32_t @var{flags})
Creates a new hash table.
@end deftypefun
@deftypefun {cfuhash_table_t *} cfuhash_new_with_initial_size (size_t @var{size})
Creates a new hash table with the specified size (number of
buckets).
@end deftypefun
@deftypefun {cfuhash_table_t *} cfuhash_new_with_flags (u_int32_t @var{flags})
Creates a new hash table with the specified flags. Pass zero
for flags if you want the defaults.
@end deftypefun
@deftypefun {cfuhash_table_t *} cfuhash_new_with_free_fn (size_t @var{size}, u_int32_t @var{flags}, cfuhash_free_fn_t @var{ff})
Same as cfuhash_new() except automatically calls cfuhash_set_free_fn().
@end deftypefun
@deftypefun {int} cfuhash_copy (cfuhash_table_t * @var{src}, cfuhash_table_t * @var{dst})
Copies entries in src to dst
@end deftypefun
@deftypefun {cfuhash_table_t *} cfuhash_merge (cfuhash_table_t * @var{ht1}, cfuhash_table_t * @var{ht2}, u_int32_t @var{flags})
Returns a new hash containing entries from both hash tables.
For any entries with the same key, the one from ht2 wins.
@end deftypefun
@deftypefun {int} cfuhash_set_hash_function (cfuhash_table_t * @var{ht}, cfuhash_function_t @var{hf})
Sets the hashing function to use when computing which bucket to add
entries to. It should return a 32-bit unsigned integer. By
default, Perl's hashing algorithm is used.
@end deftypefun
@deftypefun {int} cfuhash_set_thresholds (cfuhash_table_t * @var{ht}, float @var{low}, float @var{high})
Sets the thresholds for when to rehash. The ratio
num_entries/buckets is compared against low and high. If it is
below 'low' or above 'high', the hash will shrink or grow,
respectively, unless the flags say to do otherwise.
@end deftypefun
@deftypefun {int} cfuhash_set_free_function (cfuhash_table_t * @var{ht}, cfuhash_free_fn_t @var{ff})
Sets the function to use when removing an entry from the hash,
i.e., when replacing an existing entry, deleting an entry, or
clearing the hash. It is passed the value of the entry as a
void *.
@end deftypefun
@deftypefun {u_int32_t} cfuhash_get_flags (cfuhash_table_t * @var{ht})
Returns the hash's flags. See below for flag definitions.
@end deftypefun
@deftypefun {u_int32_t} cfuhash_set_flag (cfuhash_table_t * @var{ht}, u_int32_t @var{flag})
Sets a flag.
@end deftypefun
@deftypefun {u_int32_t} cfuhash_clear_flag (cfuhash_table_t * @var{ht}, u_int32_t @var{new_flag})
Clears a flag.
@end deftypefun
@deftypefun {int} cfuhash_get_data (cfuhash_table_t * @var{ht}, const void * @var{key}, size_t @var{key_size}, void ** @var{data}, size_t * @var{data_size})
Returns the value for the entry with given key. If key_size is -1,
key is assumed to be a null-terminated string. If data_size is not
NULL, the size of the value is placed into data_size.
@end deftypefun
@deftypefun {int} cfuhash_exists_data (cfuhash_table_t * @var{ht}, const void * @var{key}, size_t @var{key_size})
Returns 1 if an entry with the given key exists in the hash, 0 otherwise.
@end deftypefun
@deftypefun {int} cfuhash_put_data (cfuhash_table_t * @var{ht}, const void * @var{key}, size_t @var{key_size}, void * @var{data}, size_t @var{data_size}, void ** @var{r})
Inserts the given data value into the hash and associates it with
key. If key_size is -1, key is assumed to be a null-terminated
string. If data_size is -1, it is assumed to be a null-terminated
string (it's length will be calculated using strlen). If
data_size is zero, it will be returned as zero when the value is
requested.
@end deftypefun
@deftypefun {void} cfuhash_clear (cfuhash_table_t * @var{ht})
Clears the hash table (deletes all entries).
@end deftypefun
@deftypefun {void *} cfuhash_delete_data (cfuhash_table_t * @var{ht}, const void * @var{key}, size_t @var{key_size})
Deletes the entry in the hash associated with key. If the entry
existed, it's value will be returned.
@end deftypefun
@deftypefun {void} **cfuhash_keys_data (cfuhash_table_t * @var{ht}, size_t * @var{num_keys}, size_t ** @var{key_sizes}, int @var{fast})
Returns all the keys from the hash. The number of keys is placed
into the value pointed to by num_keys. If key_sizes is not NULL,
it will be set to an array of key sizes. If fast is zero, copies
of the keys are returned. Otherwise, pointers to the real keys
will be returned.
@end deftypefun
@deftypefun {int} cfuhash_each_data (cfuhash_table_t * @var{ht}, void ** @var{key}, size_t * @var{key_size}, void ** @var{data}, size_t * @var{data_size})
Initializes a loop over all the key/value pairs in the hash. It
returns the first key/value pair (see cfuhash_next_data()). 1 is
returned if there are any entries in the hash. 0 is returned
otherwise.
@end deftypefun
@deftypefun {int} cfuhash_next_data (cfuhash_table_t * @var{ht}, void ** @var{key}, size_t * @var{key_size}, void ** @var{data}, size_t * @var{data_size})
Gets the next key/value pair from the hash. You must initialize
the loop using cfuhash_each_data() before calling this function.
If a entry is left to return, 1 is returned from the function. 0
is returned if there are no more entries in the hash.
@end deftypefun
@deftypefun {size_t} cfuhash_foreach_remove (cfuhash_table_t * @var{ht}, cfuhash_remove_fn_t @var{r_fn}, cfuhash_free_fn_t @var{ff}, void * @var{arg})
Iterates over the key/value pairs in the hash, passing each one
to r_fn, and removes all entries for which r_fn returns true.
If ff is not NULL, it is the passed the data to be freed. arg
is passed to r_fn.
@end deftypefun
@deftypefun {size_t} cfuhash_foreach (cfuhash_table_t * @var{ht}, cfuhash_foreach_fn_t @var{fe_fn}, void * @var{arg})
Iterates over the key/value pairs in the hash, passing each one
to fe_fn, along with arg. This locks the hash, so do not call
any operations on the hash from within fe_fn unless you really
know what you're doing.
If the return value from fe_fn() is not zero, the iteration stops.
@end deftypefun
@deftypefun {int} cfuhash_destroy (cfuhash_table_t * @var{ht})
Frees all resources allocated by the hash.
@end deftypefun
@deftypefun {int} cfuhash_destroy_with_free_fn (cfuhash_table_t * @var{ht}, cfuhash_free_fn_t @var{ff})
Frees all resources allocated by the hash. If ff is not NULL, it
is called for each hash entry with the value of the entry passed as
its only argument. If ff is not NULL, it overrides any function
set previously with cfuhash_set_free_function().
@end deftypefun
@deftypefun {int} cfuhash_rehash (cfuhash_table_t * @var{ht})
Rebuild the hash to better accomodate the number of entries. See
cfuhash_set_thresholds().
@end deftypefun
@deftypefun {size_t} cfuhash_num_entries (cfuhash_table_t * @var{ht})
Returns the number entries in the hash.
@end deftypefun
@deftypefun {size_t} cfuhash_num_buckets (cfuhash_table_t * @var{ht})
Returns the number of buckets allocated for the hash.
@end deftypefun
@deftypefun {size_t} cfuhash_num_buckets_used (cfuhash_table_t * @var{ht})
Returns the number of buckets actually used out of the total number
allocated for the hash.
@end deftypefun
@deftypefun {char *} cfuhash_bencode_strings (cfuhash_table_t * @var{ht})
Assumes all the keys and values are null-terminated strings and
returns a bencoded string representing the hash (see
http://www.bittorrent.com/protocol.html)
@end deftypefun
@deftypefun {int} cfuhash_lock (cfuhash_table_t * @var{ht})
Locks the hash. Use this with the each and next functions for
concurrency control. Note that the hash is locked automatically
when doing inserts and deletes, so if you lock the hash and then
try to insert something into it, you may get into a deadlock,
depending on your system defaults for how mutexes work.
@end deftypefun
@deftypefun {int} cfuhash_unlock (cfuhash_table_t * @var{ht})
Unlocks the hash. Use this with the each an next functions for
concurrency control. The caveat for cfuhash_lock() also applies to
this function.
@end deftypefun
@deftypefun {int} cfuhash_pretty_print (cfuhash_table_t * @var{ht}, FILE * @var{fp})
Pretty print the hash's key/value pairs to the stream fp. It is
assumed that all the keys and values are null-terminated strings.
@end deftypefun
These are like the _data versions of these functions, with the
following exceptions:
1) They assume that the key provided is a null-terminated string.
2) They don't worry about the size of the data.
3) Returned keys or values are the return value of the function.
@deftypefun {void *} cfuhash_get (cfuhash_table_t * @var{ht}, const char * @var{key})
@end deftypefun
@deftypefun int cfuhash_exists (cfuhash_table_t * @var{ht}, const char * @var{key});
@end deftypefun
@deftypefun {void *} cfuhash_put (cfuhash_table_t * @var{ht}, const char * @var{key}, void * @var{data});
@end deftypefun
@deftypefun {void *} cfuhash_delete (cfuhash_table_t * @var{ht}, const char * @var{key});
@end deftypefun
@deftypefun int cfuhash_each (cfuhash_table_t * @var{ht}, char ** @var{key}, void ** @var{data});
@end deftypefun
@deftypefun int cfuhash_next (cfuhash_table_t * @var{ht}, char ** @var{key}, void ** @var{data});
@end deftypefun
@deftypefun {void **} cfuhash_keys (cfuhash_table_t * @var{ht}, size_t * @var{num_keys}, int @var{fast});
@end deftypefun
Valid flags for cfuhash_new() or cfuhash_set_flag):
@defvr CFUHASH_NOCOPY_KEYS
Don't copy the key when adding an entry to the hash table.
@end defvr
@defvr CFUHASH_NO_LOCKING
Don't not use any mutexes. Beware that this flag makes the hash
table non thread-safe.
@end defvr
@defvr CFUHASH_FROZEN
Do not rehash (don't grow or shrink the number of buckets in the hash
table when the thresholds are reached).
@end defvr
@defvr CFUHASH_FROZEN_UNTIL_GROWS
Do not rehash until the upper threshold is reached the first time
(useful for preallocating a large hash to avoid rehashing while
filling it).
@end defvr
@defvr CFUHASH_FREE_DATA
Call free() on the values when cfuhash_destroy() is called.
@end defvr
@defvr CFUHASH_IGNORE_CASE
Treat the keys case-insensitively.
@end defvr
@node Linked list, Strings, Hash table, Data structures
@section Linked list
@cindex linked list
@cindex queues
@defspec typedef int (*cfulist_foreach_fn_t)(void * @var{data}, size_t @var{data_size}, void * @var{arg})
Function called for each element in the list when passed to
cfulist_foreach(). A non-zero return value means to stop iteration.
@end defspec
@defspec typedef {void *} (*cfulist_map_fn_t)(void *@var{data}, size_t @var{data_size}, void *@var{arg}, size_t *@var{new_data_size})
Function called for each element in the list when passed to
cfulist_map(). The return value is used to build a new list.
@end defspec
@defspec typedef void (*cfulist_free_fn_t)(void * @var{data})
Function called to free the data in an element.
@end defspec
@deftypefun {cfulist_t *} cfulist_new ();
Returns a new list.
@end deftypefun
@deftypefun {size_t} cfulist_num_entries (cfulist_t *@var{list})
Returns the number of entries in the list.
@end deftypefun
@deftypefun {int} cfulist_push_data (cfulist_t * @var{list}, void * @var{data}, size_t @var{data_size})
Push a value onto the end of the list.
@end deftypefun
@deftypefun {int} cfulist_pop_data (cfulist_t * @var{list}, void ** @var{data}, size_t * @var{data_size})
Pop a value from the end of the list (removing it from the list).
@end deftypefun
@deftypefun {int} cfulist_unshift_data (cfulist_t * @var{list}, void * @var{data}, size_t @var{data_size})
Add a value at the beginning of the list.
@end deftypefun
@deftypefun {int} cfulist_shift_data (cfulist_t * @var{list}, void ** @var{data}, size_t * @var{data_size})
Shift a value off the beginning of the list.
@end deftypefun
@deftypefun {int} cfulist_enqueue_data (cfulist_t * @var{list}, void * @var{data}, size_t @var{data_size})
Add a value at the end of the queue (equivalent to push)
@end deftypefun
@deftypefun {int} cfulist_dequeue_data (cfulist_t * @var{list}, void ** @var{data}, size_t * @var{data_size})
Remove the value at the beginning of the list (equivalent to shift).
@end deftypefun
@deftypefun int cfulist_first_data (cfulist_t * @var{list}, void ** @var{data}, size_t * @var{data_size});
Return the first entry from the list (without removing it from the list).
@end deftypefun
@deftypefun int cfulist_last_data (cfulist_t * @var{list}, void ** @var{data}, size_t * @var{data_size});
Return the last entry from the list (without removing it from the list).
@end deftypefun
@deftypefun int cfulist_nth_data (cfulist_t * @var{list}, void ** @var{data}, size_t * @var{data_size}, size_t @var{n});
Return the nth entry from the list (without removing it from the list). n starts at zero.
@end deftypefun
@deftypefun void cfulist_reset_each (cfulist_t * @var{list});
@end deftypefun
@deftypefun int cfulist_each_data (cfulist_t * @var{list}, void ** @var{data}, size_t * @var{data_size});
@end deftypefun
@deftypefun int cfulist_next_data (cfulist_t * @var{list}, void ** @var{data}, size_t * @var{data_size});
@end deftypefun
@deftypefun size_t cfulist_foreach (cfulist_t * @var{list}, cfulist_foreach_fn_t @var{fe_fn}, void * @var{arg});
Calls fe_fn() for each element in the list. Also passes arg on each
call. Do not try to manipulate the list inside fe_fn(), as the list
will be locked.
If fe_fn() returns a non-zero value, the iteration over the elements stops.
@end deftypefun
@deftypefun {cfulist_t *}cfulist_map (cfulist_t *@var{list}, cfulist_map_fn_t @var{map_fn}, void *@var{arg});
Creates a new list from the list passed in. Calls map_fn() on each
element in the list. The return value is placed in the corresponding
position in the new list.
@end deftypefun
@deftypefun {void} cfulist_destroy (cfulist_t * @var{list})
Free all resources used by the list.
@end deftypefun
@deftypefun {void} cfulist_destroy (cfulist_t * @var{list}, cfulist_free_fn_t @var{free_fn})
Free all resources used by the list. If free_fn is not NULL, call it
for each element of the list, passing the data to it as a void *.
@end deftypefun
When you don't care about the size of the data
@deftypefun {int} cfulist_push (cfulist_t * @var{list}, void * @var{data})
@end deftypefun
@deftypefun {void *} cfulist_pop (cfulist_t * @var{list});
@end deftypefun
@deftypefun {int} cfulist_unshift (cfulist_t * @var{list}, void * @var{data});
@end deftypefun
@deftypefun {void *} cfulist_shift (cfulist_t * @var{list});
@end deftypefun
@deftypefun {int} cfulist_enqueue (cfulist_t * @var{ist}, void * @var{data});
@end deftypefun
@deftypefun {void *} cfulist_dequeue (cfulist_t * @var{list});
@end deftypefun
Strings -- assume data is a null-terminated string -- size is calculated by strlen(data) + 1
@deftypefun {int} cfulist_push_string (cfulist_t * @var{list}, char * @var{data})
@end deftypefun
@deftypefun {char *} cfulist_pop_string (cfulist_t * @var{list});
@end deftypefun
@deftypefun {int} cfulist_unshift_string (cfulist_t * @var{list}, char * @var{data});
@end deftypefun
@deftypefun {char *} cfulist_shift_string (cfulist_t * @var{list});
@end deftypefun
@deftypefun {int} cfulist_enqueue_string (cfulist_t * @var{list}, char * @var{data});
@end deftypefun
@deftypefun {char *} cfulist_dequeue_string (cfulist_t * @var{list});
@end deftypefun
@deftypefun {char *} cfulist_join (cfulist_t * @var{list}, const char * @var{delimiter})
@end deftypefun
@node Strings, , Linked list, Data structures
@section Strings
@cindex strings
@cindex self-extending strings
@deftypefun {cfustring_t *} cfustring_new (size_t @var{initial_size})
Returns a new String.
@end deftypefun
@deftypefun {cfustring_t *} cfustring_new_from_string (const char * @var{string})
Returns a new String initalized with the given string.
@end deftypefun
@deftypefun {int} cfustring_dup (cfustring_t * @var{cfu_str}, const char * @var{string})
Overwrite anything currently in cfu_str with string.
@end deftypefun
@deftypefun {int} cfustring_clear (cfustring_t * @var{cfu_str})
Truncate the string.
@end deftypefun
@deftypefun {int} cfustring_append (cfustring_t * @var{cfu_str}, const char * @var{str})
Append str to the end of the buffer in cfu_str.
@end deftypefun
@deftypefun {char *} cfustring_get_buffer (cfustring_t * @var{cfu_str})
Get the buffer used to hold the string. Do not free() it, as it is
used directly by cfustring and will be destroyed when
cfustring_destroy() is called.
@end deftypefun
@deftypefun {char *} cfustring_get_buffer_copy (cfustring_t * @var{cfu_str})
Same as cfustring_get_buffer(), except return a copy of the string.
Caller is responsible for deallocating the buffer with free().
@end deftypefun
@deftypefun {cfustring_t **} cfustring_split (cfustring_t * @var{cfu_str}, size_t * @var{num_strings}, size_t @var{limit}, @var{...})
Split cfu_str on one or more delimiting strings, e.g.,
cfustring_split(cfu_str, 2, 0, "\r\n", "\n"). Use a limit > 0 if
you want to only get back a certain number of strings and ignore
any extra delimiters.
@end deftypefun
@deftypefun {char **} cfustring_split_to_c_str (cfustring_t * @var{cfu_str}, size_t * @var{num_strings}, size_t @var{limit}, @var{...})
Same as cfustring_split(), except return an array of C-strings.
Caller is responsible for deallocating the buffers.
@end deftypefun
@deftypefun {int} cfustring_destroy (cfustring_t * @var{cfu_str})
Free all resources allocated by cfu_str.
@end deftypefun
@deftypefun {char *} cfustring_dup_c_str (const char * @var{str})
Duplicate the C string str. Caller must free with free().
@end deftypefun
@deftypefun {char *} cfustring_dup_c_str_n (const char * @var{str}, size_t @var{n})
Same as cfustring_dup_c_str(), but only copy at most n chars
@end deftypefun
@deftypefun size_t cfustring_sprintf (cfustring_t * @var{cfu_str}, const char * @var{fmt}, @var{...});
Like sprintf(), but writes to a self-extending string.
@end deftypefun
@deftypefun size_t cfustring_vsprintf (cfustring_t * @var{cfu_str}, const char * @var{fmt}, va_list @var{ap});
Like vsprintf(), but writes to a self-extending string.
@end deftypefun
@deftypefun {char *} cfustring_sprintf_c_str (const char * @var{fmt}, @var{...})
Similar to sprintf(), but allocates a C string of the
appropriate size for you and returns it.
@end deftypefun
@deftypefun {char **} cfustring_c_str_split (const char * @var{c_str}, size_t * @var{num_strings}, size_t @var{limit}, @var{...})
Like cfustring_split_to_c_str(), but split a char * instead of a cfustring_t *.
@end deftypefun
@node Conf, Options, Top, Top
@chapter Conf
@cindex configuration file
@cindex apache configuration file
This needs to be better documented.
Apache-style conf files contain directives and containers.
Directives are simple one line specifications with or without
arguments, e.g.,
Doit
Expires On
LoadModule my_mod modules/my_mod.so
Containers have a type and a name associated with them and they
in turn contain directives and/or containers, e.g.,
<MyContainer test1>
Expires Off
<DB devdb>
DBHost db.example.com
DBUser test_user
</DB>
</MyContainer>
Values may be quoted, e.g.
DBUser "test user"
But must be specified on a single line. To escape quotes
within a quoted string, use the '\' character.
@deftypefun {int} cfuconf_parse_file (char * @var{file_path}, cfuconf_t ** @var{conf}, char ** @var{error})
Parse the apache-like conf file specified by file_path,
returning a pointer to a cfuconf_t structure in conf. Returns
zero on success, less than zero on error. If an error occurs
and error is not NULL, it will be set to an error message
(which must be free()'d by the caller).
@end deftypefun
@deftypefun {int} cfuconf_parse_buffer (char * @var{buffer}, cfuconf_t ** @var{conf}, char ** @var{error})
Same as cfuconf_parse_file(), except assume the contents of the
file are already in buffer.
@end deftypefun
@deftypefun {void} cfuconf_destroy (cfuconf_t * @var{conf})
Free all resources used by the cfuconf_t structure
@end deftypefun
@deftypefun {cfuhash_table_t *} cfuconf_get_containers (cfuconf_t * @var{conf})
Get a hash of containers at the top level of conf
@end deftypefun
@deftypefun {cfuhash_table_t *} cfuconf_get_directives (cfuconf_t * @var{conf})
Get a hash of directives at the to level
@end deftypefun
@deftypefun {int} cfuconf_get_directive_one_arg (cfuconf_t * @var{conf}, char * @var{directive}, char ** @var{rvalue})
Get the value of the given directive, assuming there is only one argument
@end deftypefun
@deftypefun {int} cfuconf_get_directive_two_args (cfuconf_t * @var{conf}, char * @var{directive}, char ** @var{rvalue}, char ** @var{rvalue2})
Get the value of the given directive, assuming there are two arguments
@end deftypefun
@deftypefun {int} cfuconf_get_directive_n_args (cfuconf_t * @var{conf}, char * @var{directive}, size_t @var{n}, @var{...})
Get the value of the given directives, with n arguments
@end deftypefun
@node Options, Thread queue, Conf, Top
@chapter Options
@cindex options
@cindex command-line arguments
@cindex arguments
Command-line arguments can be parsed with the following:
@verbatim
cfuopt_t *opt = cfuopt_new();
cfuopt_add_entry(opt, "verbose|v!", &verbose, "Verbosity", "");
cfuopt_add_entry(opt, "file|f:s", &file, "File to load", "FILE");
cfuopt_add_entry(opt, "count|c|n=i", &count, "Count to run", "COUNT");
cfuopt_add_entry(opt, "scale|s:f", &scale, "Scaling factor", "SCALE");
cfuopt_parse(opt, &argc, &argv, &error);
/* do stuff here with the options */
cfuopt_destroy(opt);
free(file);
@end verbatim
@deftypefun {cfuopt_t *}cfuopt_new ()
Returns a new options context.
@end deftypefun
@deftypefun void cfuopt_add_entry (cfuopt_t *@var{context}, const char *@var{opt_str}, void *@var{arg_data}, const char *@var{description}, const char *@var{arg_description})
Adds to the list of known options.
@end deftypefun
@deftypefun void cfuopt_parse (cfuopt_t *@var{context}, int *@var{argc}, char ***@var{argv}, char **@var{error})
Parses the command line and modifies argc and argv to account for left over arguments.
@end deftypefun
@deftypefun {char *}cfuopt_get_help_str (cfuopt_t *@var{context})
Returns a help string built from the entries added with cfuopt_add_entry().
@end deftypefun
@deftypefun void cfuopt_destroy (cfuopt_t *@var{context})
Frees up resources used by the option parser.
@end deftypefun
@node Thread queue, Timer, Options, Top
@chapter Thread queue
@cindex threading
@cindex thread queue
cfuthread_queue provides a way to serialize requests for a resource
where you want the resource to be accessed from a single thread only.
For instance, for a database connection where making calls in separate
threads does not work properly, you can use cfuthread_queue.
cfuthread_queue_new() creates a new thread that waits for something to
be added to the queue. Once something is added, the thread will
process the data by calling the function you pass as an argument to
the cfuthread_queue_new() function.
@deftypefun {cfuthread_queue_t *} cfuthread_queue_new (cfuthread_queue_fn_t @var{fn})
Creates a new thread queue structure that will run the given
function when a request is received.
@end deftypefun
@deftypefun {cfuthread_queue_t *} cfuthread_queue_new_with_cleanup (cfuthread_queue_fn_t @var{fn}, cfuthread_queue_init_t @var{init_fn}, void * @var{init_arg}, cfuthread_queue_cleanup_t @var{cleanup_fn}, void * @var{cleanup_arg})
Same as cfuthread_queue_new(), but with an initialization
function that gets called with the argument init_arg when the
thread is created, and a cleanup function that gets called with
the argument cleanup_arg when the thread exits, e.g., when
cfuthread_queue_destroy() is called.
@end deftypefun
@deftypefun {void *} cfuthread_queue_make_request (cfuthread_queue_t * @var{tq}, void * @var{data})
Add a request to the queue. data will get passed to the
function fn given to cfuthread_queue_new when it reaches the
front of the queue.
@end deftypefun
@deftypefun {void} cfuthread_queue_destroy (cfuthread_queue_t * @var{tq})
Free up resources used by the queue, in addition to canceling
the thread.
@end deftypefun
@node Timer, License, Thread queue, Top
@chapter Timer
@cindex timer
@deftypefun {cfutime_t} *cfutime_new ();
Return a new cfutime structure.
@end deftypefun
@deftypefun void cfutime_begin (cfutime_t *@var{time})
Start the timer.
@end deftypefun
@deftypefun {void} cfutime_end (cfutime_t * @var{time})
Stop the timer.
@end deftypefun
@deftypefun {double} cfutime_elapsed (cfutime_t * @var{time})
Return the number of seconds elapsed as a double.
@end deftypefun
@deftypefun {void} cfutime_free (cfutime_t * @var{time})
Deallocate resources allocated for time.
@end deftypefun
@node License, , Timer, Top
@unnumbered License
@cindex license
Copyright @copyright{} 2005 Don Owens
All rights reserved.
This code is released under the BSD license:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of the author nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
OF THE POSSIBILITY OF SUCH DAMAGE.
@node Concept index, Function index, Top, Top
@unnumbered Concept index
@printindex cp
@node Function index, , Concept index, Top
@unnumbered Function index
@printindex fn
@contents
@bye

133
doc/mdate-sh Executable file
View File

@@ -0,0 +1,133 @@
#!/bin/sh
# Get modification time of a file or directory and pretty-print it.
# Copyright (C) 1995, 1996, 1997, 2003 Free Software Foundation, Inc.
# written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, June 1995
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# Prevent date giving response in another language.
LANG=C
export LANG
LC_ALL=C
export LC_ALL
LC_TIME=C
export LC_TIME
save_arg1="$1"
# Find out how to get the extended ls output of a file or directory.
if ls -L /dev/null 1>/dev/null 2>&1; then
ls_command='ls -L -l -d'
else
ls_command='ls -l -d'
fi
# A `ls -l' line looks as follows on OS/2.
# drwxrwx--- 0 Aug 11 2001 foo
# This differs from Unix, which adds ownership information.
# drwxrwx--- 2 root root 4096 Aug 11 2001 foo
#
# To find the date, we split the line on spaces and iterate on words
# until we find a month. This cannot work with files whose owner is a
# user named `Jan', or `Feb', etc. However, it's unlikely that `/'
# will be owned by a user whose name is a month. So we first look at
# the extended ls output of the root directory to decide how many
# words should be skipped to get the date.
# On HPUX /bin/sh, "set" interprets "-rw-r--r--" as options, so the "x" below.
set - x`$ls_command /`
# Find which argument is the month.
month=
command=
until test $month
do
shift
# Add another shift to the command.
command="$command shift;"
case $1 in
Jan) month=January; nummonth=1;;
Feb) month=February; nummonth=2;;
Mar) month=March; nummonth=3;;
Apr) month=April; nummonth=4;;
May) month=May; nummonth=5;;
Jun) month=June; nummonth=6;;
Jul) month=July; nummonth=7;;
Aug) month=August; nummonth=8;;
Sep) month=September; nummonth=9;;
Oct) month=October; nummonth=10;;
Nov) month=November; nummonth=11;;
Dec) month=December; nummonth=12;;
esac
done
# Get the extended ls output of the file or directory.
set - x`eval "$ls_command \"\$save_arg1\""`
# Remove all preceding arguments
eval $command
# Get the month. Next argument is day, followed by the year or time.
case $1 in
Jan) month=January; nummonth=1;;
Feb) month=February; nummonth=2;;
Mar) month=March; nummonth=3;;
Apr) month=April; nummonth=4;;
May) month=May; nummonth=5;;
Jun) month=June; nummonth=6;;
Jul) month=July; nummonth=7;;
Aug) month=August; nummonth=8;;
Sep) month=September; nummonth=9;;
Oct) month=October; nummonth=10;;
Nov) month=November; nummonth=11;;
Dec) month=December; nummonth=12;;
esac
day=$2
# Here we have to deal with the problem that the ls output gives either
# the time of day or the year.
case $3 in
*:*) set `date`; eval year=\$$#
case $2 in
Jan) nummonthtod=1;;
Feb) nummonthtod=2;;
Mar) nummonthtod=3;;
Apr) nummonthtod=4;;
May) nummonthtod=5;;
Jun) nummonthtod=6;;
Jul) nummonthtod=7;;
Aug) nummonthtod=8;;
Sep) nummonthtod=9;;
Oct) nummonthtod=10;;
Nov) nummonthtod=11;;
Dec) nummonthtod=12;;
esac
# For the first six month of the year the time notation can also
# be used for files modified in the last year.
if (expr $nummonth \> $nummonthtod) > /dev/null;
then
year=`expr $year - 1`
fi;;
*) year=$3;;
esac
# The result.
echo $day $month $year

4
doc/stamp-vti Normal file
View File

@@ -0,0 +1,4 @@
@set UPDATED 4 September 2005
@set UPDATED-MONTH September 2005
@set EDITION 0.03
@set VERSION 0.03

6735
doc/texinfo.tex Normal file

File diff suppressed because it is too large Load Diff

4
doc/version.texi Normal file
View File

@@ -0,0 +1,4 @@
@set UPDATED 4 September 2005
@set UPDATED-MONTH September 2005
@set EDITION 0.03
@set VERSION 0.03