#!/bin/bash

vers="0.12.1"
dir="functions"
dirx="functions2"

output_copyright() {

echo ''
echo '<table border=0 cellspacing=0 cellpadding=0 width=50%><tr>'
echo '<td><font size=-1>The documentation, source code, and derived compilations are<br>'
echo '<b>Copyright &copy; 2000 by Philip Howard</b>.'
echo '<br><pre>'
echo 'This library is free software; you can redistribute it and/or'
echo -n 'modify it under the terms of the <a href="http://www.gnu.org/">GNU</a>'
echo ' <a href="http://www.gnu.org/copyleft/lesser.html">Lesser General Public'
echo 'License</a> as published by the Free Software Foundation; either'
echo 'version 2.1 of the License, or (at your option) any later version.'
echo ''
echo 'This library is distributed in the hope that it will be useful,'
echo 'but <b>WITHOUT ANY WARRANTY</b>; without even the implied warranty of'
echo -n '<b>MERCHANTABILITY</b> or <b>FITNESS FOR A PARTICULAR PURPOSE</b>.'
echo '  See the <a href="http://www.gnu.org/">GNU</a>'
echo '<a href="http://www.gnu.org/copyleft/lesser.html">Lesser General Public License</a> for more details.'
echo ''
echo -n 'You should have received a copy of the <a href="http://www.gnu.org/">GNU</a>'
echo ' <a href="http://www.gnu.org/copyleft/lesser.html">Lesser General Public'
echo 'License</a> along with this library; if not, write to the <a href="http://www.fsf.org/">Free Software'
echo 'Foundation, Inc.</a>, 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA'
echo '</pre></font></td></tr></table>'
echo ''
echo '</body>'
echo '</html>'

}

output_commands() {

td='double';			cd='scalar';
tld='long double';		cld='scalar';

tsi='signed int';		csi='scalar';
tui='unsigned int';		cui='scalar';
tsl='signed long';		csl='scalar';
tul='unsigned long';		cul='scalar';
tsll='signed long long';	csll='scalar';
tull='unsigned long long';	cull='scalar';

tptr='void *';			cptr='scalar';

tca='char';			cca='array';
tcs='char';			ccs='string';
tstr='char';			cstr='string';

tsca='signed char';		csca='array';
tscs='signed char';		cscs='string';
tuca='unsigned char';		cuca='array';
tucs='unsigned char';		cucs='string';

tssa='signed short';		cssa='array';
tsss='signed short';		csss='string';
tusa='unsigned short';		cusa='array';
tuss='unsigned short';		cuss='string';

tsia='signed int';		csia='array';
tsis='signed int';		csis='string';
tuia='unsigned int';		cuia='array';
tuis='unsigned int';		cuis='string';

tsla='signed long';		csla='array';
tsls='signed long';		csls='string';
tula='unsigned long';		cula='array';
tuls='unsigned long';		culs='string';

tslla='signed long long';	cslla='array';
tslls='signed long long';	cslls='string';
tulla='unsigned long long';	culla='array';
tulls='unsigned long long';	culls='string';

echo '#!/bin/bash'
echo "rm -f functions/data_functions.html functions/key_functions.html functions/keydata_functions.html"
echo "rm -fr ${dirx}"
echo "mkdir ${dirx}"
echo "chmod 755 ${dirx}"

echo "cat <<EOF >index2.html"
echo "<html>"
echo "<head><title>avlmap-${vers} documentation: function index</title></head>"
echo '<body bgcolor="#ffffff" link="#0000ff" alink="#ff0000" vlink="#0000ee">'
echo -n '<a name="top"><table border=0 cellspacing=0 cellpadding=0 width=100%>'
echo '<tr><td align=left><font face="Times New Roman,Times" size=7><b>function index</b></font></td>'
echo -n '<td align=right><font face="Times New Roman,Times" size=7>'
echo '<b><i>library: </i> avlmap</b></font></td></tr>'
echo -n '<tr><td colspan=2 bgcolor="#cccccc"><hr noshade size=6 width=100%></td></tr>'
echo '</table><ul>'
echo 'EOF'

for pass in each
do

if [ "${pass}" = "key" ]; then
	echo "cat <<EOF >${dir}/${pass}_functions.html"
	echo "<html>"
	echo "<head><title>avlmap-${vers} documentation: key functions</title></head>"
	echo '<body bgcolor="#ffffff" link="#0000ff" alink="#ff0000" vlink="#0000ee">'
	echo -n '<a name="top"><table border=0 cellspacing=0 cellpadding=0 width=100%>'
	echo '<tr><td align=left><font face="Times New Roman,Times" size=7>'
	echo -n '<b>key functions</b></font></td>'
	echo -n '<td align=right><font face="Times New Roman,Times" size=7>'
	echo '<b><i>library: </i> avlmap</b></font></td></tr>'
	echo -n '<tr><td colspan=2 bgcolor="#cccccc"><hr noshade size=6 width=100%></td></tr>'
	echo '</table>'
	dokey=1
	dodata=0
	kda=key
	kdb=key
fi

if [ "${pass}" = "data" ]; then
	echo "cat <<EOF >${dir}/${pass}_functions.html"
	echo "<html>"
	echo "<head><title>avlmap-${vers} documentation: data functions</title></head>"
	echo '<body bgcolor="#ffffff" link="#0000ff" alink="#ff0000" vlink="#0000ee">'
	echo -n '<a name="top"><table border=0 cellspacing=0 cellpadding=0 width=100%>'
	echo '<tr><td align=left><font face="Times New Roman,Times" size=7>'
	echo -n '<b>data functions</b></font></td>'
	echo -n '<td align=right><font face="Times New Roman,Times" size=7>'
	echo '<b><i>library: </i> avlmap</b></font></td></tr>'
	echo -n '<tr><td colspan=2 bgcolor="#cccccc"><hr noshade size=6 width=100%></td></tr>'
	echo '</table>'
	dokey=0
	dodata=1
	kda=data
	kdb=data
fi

if [ "${pass}" = "keydata" ]; then
	echo "cat <<EOF >${dir}/${pass}_functions.html"
	echo "<html>"
	echo "<head><title>avlmap-${vers} documentation: key and data functions</title></head>"
	echo '<body bgcolor="#ffffff" link="#0000ff" alink="#ff0000" vlink="#0000ee">'
	echo -n '<a name="top"><table border=0 cellspacing=0 cellpadding=0 width=100%>'
	echo '<tr><td align=left><font face="Times New Roman,Times" size=7>'
	echo -n '<b>key and data functions</b></font></td>'
	echo -n '<td align=right><font face="Times New Roman,Times" size=7>'
	echo '<b><i>library: </i> avlmap</b></font></td></tr>'
	echo -n '<tr><td colspan=2 bgcolor="#cccccc"><hr noshade size=6 width=100%></td></tr>'
	echo '</table>'
	dokey=1
	dodata=1
	kda=key
	kdb=data
fi

for n in si ui sl ul sll ull str ca cs sca scs uca ucs ssa sss usa uss sia sis uia uis sla sls ula uls d ld ptr slla slls ulla ulls
do

eval 't="${t'"${n}"'}"'
eval 'c="${c'"${n}"'}"'

dt="${t}"
sd="${t}"
if [ "${c}" = "scalar" ]; then
	if [ "${t}" = "void *" ]; then
		sd="generic pointer";
	fi
	l="new insert insert_dup store"
	l="${l} find find_exact find_exact_lo find_lo_or_near find_exact_hi find_hi_or_near fetch key"
	ca="${dt}, ${dt}"
	ke="${dt} <b>key</b>"
	da="${dt} <b>data</b>"
fi
if [ "${c}" = "array" ]; then
	dt="${t} *";
	sd="array of ${t}"
	l="new insert insert_dup store store_share"
	l="${l} find find_exact find_exact_lo find_lo_or_near find_exact_hi find_hi_or_near"
	l="${l} fetch_ptr fetch_dup fetch_copy fetch_len key_ptr key_dup key_copy key_len"
	ca="${dt},size_t,${dt},size_t"
	ke="${dt} <b>key</b>, size_t <b>keylen</b>"
	da="${dt} <b>data</b>, size_t <b>datalen</b>"
fi
if [ "${c}" = "string" ]; then
	dt="${t} *";
	sd="string of ${t}"
	l="new insert insert_dup store store_share"
	l="${l} find find_exact find_exact_lo find_lo_or_near find_exact_hi find_hi_or_near"
	l="${l} fetch_ptr fetch_dup fetch_copy fetch_len key_ptr key_dup key_copy key_len"
	ca="${dt},size_t,${dt},size_t"
	ke="${dt} <b>key</b>"
	da="${dt} <b>data</b>"
fi

kd_new=key
kd_find=key
kd_find_exact=key
kd_find_exact_lo=key
kd_find_lo_or_near=key
kd_find_exact_hi=key
kd_find_hi_or_near=key
kd_insert=key
kd_insert_dup=key
kd_key=key
kd_key_ptr=key
kd_key_dup=key
kd_key_copy=key
kd_key_len=key
kd_store=data
kd_store_share=data
kd_fetch=data
kd_fetch_ptr=data
kd_fetch_dup=data
kd_fetch_copy=data
kd_fetch_len=data

desc_new="creates a new mapping with a key type of ${sd} (${dt})"
desc_find="finds a member of a mapping with a key type of ${sd} (${dt})"
desc_find_exact="finds the fastest exact member of a mapping with a key type of ${sd} (${dt})"
desc_find_exact_lo="finds the lowest exact member of a mapping with a key type of ${sd} (${dt})"
desc_find_lo_or_near="finds the lowest or nearest lower member of a mapping with a key type of ${sd} (${dt})"
desc_find_exact_hi="finds the highest exact member of a mapping with a key type of ${sd} (${dt})"
desc_find_hi_or_near="finds the highest or nearest higher member of a mapping with a key type of ${sd} (${dt})"
desc_insert="inserts (or finds) a member in a mapping with a key type of ${sd} (${dt})"
desc_insert_dup="inserts a possibly duplicate member in a mapping with a key type of ${sd} (${dt})"
desc_key="returns the key of the selected member of a mapping with a key type of ${sd} (${dt})"
desc_key_ptr="returns a pointer to the key of the selected member of a mapping with a key type of ${sd} (${dt})"
desc_key_dup="returns a duplicate of the key of the selected member of a mapping with a key type of ${sd} (${dt})"
desc_key_copy="makes a copy of the key of the selected member of a mapping with a key type of ${sd} (${dt})"
desc_key_len="returns the length of the key of the selected member of a mapping with a key type of ${sd} (${dt})"
desc_store="stores a data value of type ${sd} (${dt}) in the selected member of a mapping"
desc_store_share="stores a shared data value of type ${sd} (${dt}) in the selected member of a mapping"
desc_fetch="returns the data value of type ${sd} (${dt}) from the selected member of a mapping"
desc_fetch_ptr="returns a pointer to the data value of type ${sd} (${dt}) from the selected member of a mapping"
desc_fetch_dup="returns a duplicate of the data value of type ${sd} (${dt}) from the selected member of a mapping"
desc_fetch_copy="makes a copy of the data value of type ${sd} (${dt}) from the selected member of a mapping"
desc_fetch_len="returns the length of a data value of type ${sd} (${dt}) from the selected member of a mapping"

const=""
if [ "${c}" = "array" -o "${c}" = "string" ]; then
	const="const "
fi
syn_new="MAP <b>map_${n}_new(</b> (int (*)(${ca})) <b>compare_function</b> | <b>NULL )</b>"
syn_find="int <b>map_${n}_find(</b> MAP <b>mapping</b>, ${const}${ke}, int <b>direction )</b>"
syn_find_exact="int <b>map_${n}_find_exact(</b> MAP <b>mapping</b>, ${const}${ke} <b>)</b>"
syn_find_exact_lo="int <b>map_${n}_find_exact_lo(</b> MAP <b>mapping</b>, ${const}${ke} <b>)</b>"
syn_find_lo_or_near="int <b>map_${n}_find_lo_or_near(</b> MAP <b>mapping</b>, ${const}${ke} <b>)</b>"
syn_find_exact_hi="int <b>map_${n}_find_exact_hi(</b> MAP <b>mapping</b>, ${const}${ke} <b>)</b>"
syn_find_hi_or_near="int <b>map_${n}_find_hi_or_near(</b> MAP <b>mapping</b>, ${const}${ke} <b>)</b>"
syn_insert="int <b>map_${n}_insert(</b> MAP <b>mapping</b>, ${const}${ke} <b>)</b>"
syn_insert_dup="int <b>map_${n}_insert_dup(</b> MAP <b>mapping</b>, ${const}${ke} <b>)</b>"
syn_key="${dt} <b>map_${n}_key(</b> MAP <b>mapping )</b>"
syn_key_ptr="const ${dt} <b>map_${n}_key_ptr(</b> MAP <b>mapping</b>, size_t * <b>keylen_dst )</b>"
syn_key_dup="${dt} <b>map_${n}_key_dup(</b> MAP <b>mapping</b>, size_t * <b>keylen_dst )</b>"
syn_key_copy="size_t <b>map_${n}_key_copy(</b> MAP <b>mapping</b>, ${dt} * <b>key_dst</b>, size_t <b>max_len )</b>"
syn_key_len="size_t <b>map_${n}_key_len(</b> MAP <b>mapping )</b>"
syn_store="int <b>map_${n}_store(</b> MAP <b>mapping</b>, ${const}${da} <b>)</b>"
syn_store_share="int <b>map_${n}_store_share(</b> MAP <b>mapping</b>, ${da} <b>)</b>"
syn_fetch="${dt} <b>map_${n}_fetch(</b> MAP <b>mapping )</b>"
syn_fetch_ptr="const ${dt} <b>map_${n}_fetch_ptr(</b> MAP <b>mapping</b>, size_t * <b>datalen_dst )</b>"
syn_fetch_dup="${dt} <b>map_${n}_fetch_dup(</b> MAP <b>mapping</b>, size_t * <b>datalen_dst )</b>"
syn_fetch_copy="size_t <b>map_${n}_fetch_copy(</b> MAP <b>mapping</b>, ${dt} * <b>data_dst</b>, size_t <b>max_len )</b>"
syn_fetch_len="size_t <b>map_${n}_fetch_len(</b> MAP <b>mapping )</b>"

for f in $l
do

eval 'desc="${desc_'"${f}"'}"'

fn="map_${n}_${f}"

if [ "${pass}" = "each" ]; then
	echo "cat <<EOF >>index2.html"
	echo '<li><a href="'"${dirx}/${fn}"'.html">'"${fn}</a> - ${desc}<br>"
	echo 'EOF'

	echo "cat <<EOF >${dirx}/${fn}.html"
	echo "<html>"
	echo "<head><title>avlmap-${vers} documentation: function ${fn}</title></head>"
	echo '<body bgcolor="#ffffff" link="#0000ff" alink="#ff0000" vlink="#0000ee">'

	echo -n '<a name="top"><table border=0 cellspacing=0 cellpadding=0 width=100%>'
	echo -n '<tr><td align=left><font face="Times New Roman,Times" size=7>'
	echo -n "<b><i>function: </i> ${fn}</b></font></td>"
	echo -n '<td align=right><font face="Times New Roman,Times" size=7>'
	echo -n '<b><i>library: </i> avlmap</b></font></td></tr>'
	echo -n '<tr><td colspan=2 bgcolor="#cccccc"><hr noshade size=6 width=100%></td></tr>'
	echo '</table>'
fi

eval 'kd="${kd_'"${f}"'}"'
if [ "${kda}" = "${kd}" -o "${kdb}" = "${kd}" -o "${pass}" = "each" -o "${pass}" = "${f}" ]; then

#===================================================================================================
echo -n '<a name="'"${fn}"'_name"><p><font face="Times New Roman,Times" size=5><b>Name</b></font>'
echo "<blockquote><b>${fn}</b></blockquote></p>"

#===================================================================================================
eval 'syn="${syn_'"${f}"'}"'
echo -n '<a name="'"${fn}"'_synopsis"><p><font face="Times New Roman,Times" size=5>'
echo "<b>Synopsis</b></font><blockquote><tt><pre>${syn}</pre></tt></blockquote></p>"

#===================================================================================================
echo -n '<a name="'"${fn}"'_description"><p><font face="Times New Roman,Times" size=5><b>Description</b></font><blockquote>'
if [ "${n}" = "str" ]; then
	echo -n "<b>${fn}</b> is an alias for "
	echo -n '<a href="map_cs_'"${f}"'.html"><b>map_cs_'"${f}"'</b></a>.<br><br>'
fi
if [ "${f}" = "new" ]; then
	echo -n "<b>${fn}</b> creates a new instance of a mapping which has a key type of ${sd}, "
	echo -n 'and returns the handle for that mapping.'
fi
if [ "${f}" = "find" ]; then
	echo -n "<b>${fn}</b> finds a member of a mapping that matches or nearly matches a given key "
	echo -n "of type ${sd}, and selects that member to become the active member of this mapping. "
fi
if [ "${f}" = "find_exact" ]; then
	echo -n "<b>${fn}</b> finds a member of a mapping that exactly matches a given key of type ${sd}. "
	echo -n "Among duplicates in the mapping, any member may be matched. "
	echo -n "This implementation matches whichever member is encountered first in the underlying tree. "
fi
if [ "${f}" = "find_exact_lo" ]; then
	echo -n "<b>${fn}</b> finds a member of a mapping that exactly matches a given key of type ${sd}. "
	echo -n "Among duplicates in the mapping, the lowest member will be matched. "
fi
if [ "${f}" = "find_lo_or_near" ]; then
	echo -n "<b>${fn}</b> finds a member of a mapping that exactly matches a given key of type ${sd}, "
	echo -n "or if there is no exact match, matches the nearest lower member. "
	echo -n "Among exactly matching duplicates, the lowest member will be matched. "
fi
if [ "${f}" = "find_exact_hi" ]; then
	echo -n "<b>${fn}</b> finds a member of a mapping that exactly matches a given key of type ${sd}. "
	echo -n "Among duplicates in the mapping, the highest member will be matched. "
fi
if [ "${f}" = "find_hi_or_near" ]; then
	echo -n "<b>${fn}</b> finds a member of a mapping that exactly matches a given key of type ${sd}, "
	echo -n "or if there is no exact match, matches the nearest higher member. "
	echo -n "Among exactly matching duplicates, the highest member will be matched. "
fi
if [ "${f}" = "insert" ]; then
	echo -n "<b>${fn}</b> inserts a new member in a mapping with a key type of ${sd}, "
	echo -n "unless an exactly matching member already exists in this mapping. "
	echo -n "If a new member is inserted, it becomes the active member, is initialized with no data, "
	echo -n "is made ready to be assigned data, and its (no type) data type is returned. "
	echo -n "If an existing member is found, it becomes the active member, "
	echo -n "and its data type is returned. "
fi
if [ "${f}" = "insert_dup" ]; then
	echo -n "<b>${fn}</b> inserts a new member in a mapping with a key type of ${sd}, "
	echo -n "even if an exactly matching member already exists in this mapping. "
	echo -n "The new member becomes the active member, is initialized with no data, "
	echo -n "and is made ready to be assigned data. "
fi
if [ "${f}" = "insert_find" ]; then
	echo -n "<b>${fn}</b> inserts a new member in a mapping with a key type of ${sd}, "
	echo -n "or finds an existing member already in the mapping. "
	echo -n "The new or found member becomes the active member, "
	echo -n "is initialized with no data if it was a new member, "
	echo -n "and is made ready to be assigned data. "
fi
if [ "${f}" = "key" ]; then
	echo -n "<b>${fn}</b> returns the key value of the active member of a mapping of key type ${sd}. "
	echo -n "If there is no currently active member of the mapping, a value of (${dt}) 0 is returned. "
	echo -n "To reliably determine if there is an active member, call "
	echo -n '<a href="../functions/map_data_type.html"><b>map_data_type</b></a>. '
fi
if [ "${f}" = "key_ptr" ]; then
	echo -n "<b>${fn}</b> returns the pointer to the array/string key of the active member of a mapping "
	echo -n "of key type ${sd}. "
	echo -n "The length of the key is also stored where pointed to by the 2nd argument, if given. "
fi
if [ "${f}" = "key_dup" ]; then
	echo -n "<b>${fn}</b> makes a duplicate array/string of the key of the active member of a mapping "
	echo -n "of key type ${sd}, and returns a pointer to it. "
	echo -n "The length of the key is also stored where pointed to by the 2nd argument, if given. "
fi
if [ "${f}" = "key_copy" ]; then
	echo -n "<b>${fn}</b> copies the array/string key of the active member of a mapping of key type ${sd} "
	echo -n "to the location pointed to by the 2nd argument, up to but not more than one element less "
	echo -n "than the number of elements specified in the 3rd argument. "
	echo -n "The length of the actual key is returned as the function value. "
fi
if [ "${f}" = "key_len" ]; then
	echo -n "<b>${fn}</b> returns the length of the array/string key of the active member of a mapping "
	echo -n "of key type ${sd}. The key pointer or value is not returned. "
fi
if [ "${f}" = "store" ]; then
	echo -n "<b>${fn}</b> stores a data value of type ${sd} in the active member of a mapping. "
	echo -n "The previous data value, if any, is replaced. "
	if [ "${c}" = "array" -o "${c}" = "string" ]; then
		echo -n "The string/array contents of the data value is duplicated, so the original "
		echo -n "data value given may be altered after this call without affecting the value "
		echo -n "stored in this member. "
	fi
fi
if [ "${f}" = "store_share" ]; then
	echo -n "<b>${fn}</b> stores a data value of type ${sd} in the active member of a mapping "
	echo -n "using the original pointer so that any modifications to the original memory location "
	echo -n "will effectively modify the stored data value. "
	echo -n "The length of the ${c} may not be modified in this way. "
	echo -n "The purpose for using this function is not to provide a means to modify the data in "
	echo -n "place, but instead, to avoid the overhead of duplicating the data when the calling "
	echo -n "program will be leaving the stored data intact (in particular, not freeing it). "
fi
if [ "${f}" = "fetch" ]; then
	echo -n "<b>${fn}</b> returns the data value of type ${sd} of the active member of a mapping. "
	echo -n "If there is no currently active member of the mapping, a value of (${dt}) 0 is returned. "
fi
if [ "${f}" = "fetch_ptr" ]; then
	echo -n "<b>${fn}</b> returns the pointer to the array/string data value of type ${sd} of the "
	echo -n "active member of a mapping. "
	echo -n "The length of the data is also stored where pointed to by the 2nd argument, if given. "
fi
if [ "${f}" = "fetch_dup" ]; then
	echo -n "<b>${fn}</b> makes a duplicate array/string of the data value of type ${sd} of the "
	echo -n "active member of a mapping. "
	echo -n "The length of the data is also stored where pointed to by the 2nd argument, if given. "
fi
if [ "${f}" = "fetch_copy" ]; then
	echo -n "<b>${fn}</b> copies the array/string data value of type ${sd} of the active member of "
	echo -n "a mapping, to the location pointed to by the 2nd argument, up to but not more than one "
	echo -n "element less than the number of elements specified in the 3rd argument. "
	echo -n "The length of the actual data value is returned as the function value. "
fi
if [ "${f}" = "fetch_len" ]; then
	echo -n "<b>${fn}</b> returns the length of the array/string data value of the active member "
	echo -n "of a mapping. The data pointer or value is not returned. "
fi
echo '</blockquote></p>'

#===================================================================================================
echo '<a name="'"${fn}"'_args"><p><font face="Times New Roman,Times" size=5><b>Arguments</b></font><ol>'
if [ "${f}" = "new" ]; then
	echo -n "<li> <b>compare_function</b> is an optional function pointer to allow specialized "
	echo -n 'collation of the key. '
	echo 'Providing the <b>NULL</b> value uses the standard comparison and collation. '
fi
if [ "${f}" = "find" ]; then
	echo "<li> <b>mapping</b> is the handle of the specified mapping."
	if [ "${c}" = "array" ]; then
		echo "<li> <b>key</b> is the pointer to the key array to search for"
		echo -n "<li> <b>keylen</b> is the length of the key array, "
		echo 'or the value <b>~0</b> to figure the length as a string'
	fi
	if [ "${c}" = "string" ]; then
		echo "<li> <b>key</b> is the pointer to the key string to search for"
	fi
	if [ "${c}" = "scalar" ]; then
		echo "<li> <b>key</b> is the key value to search for"
	fi
	echo "<li> <b>direction</b> is the indication of the search orientation to apply:<ul>"
	echo "<li>-2 : match the lowest exact, or nearest lower key"
	echo "<li>-1 : match the lowest exact key only"
	echo "<li>0 : match any exact key"
	echo "<li>1 : match the highest exact key only"
	echo "<li>2 : match the highest exact, or nearest higher key"
	echo "</ul>"
fi
if [ "${f}" = "find_exact" -o "${f}" = "find_exact_lo" -o "${f}" = "find_lo_or_near" -o "${f}" = "find_exact_hi" -o "${f}" = "find_hi_or_near" ]; then
	echo "<li> <b>mapping</b> is the handle of the specified mapping."
	if [ "${c}" = "array" ]; then
		echo "<li> <b>key</b> is the pointer to the key array to search for"
		echo -n "<li> <b>keylen</b> is the length of the key array, "
		echo 'or the value <b>~0</b> to figure the length as a string'
	fi
	if [ "${c}" = "string" ]; then
		echo "<li> <b>key</b> is the pointer to the key string to search for"
	fi
	if [ "${c}" = "scalar" ]; then
		echo "<li> <b>key</b> is the key value to search for"
	fi
fi
if [ "${f}" = "insert" -o "${f}" = "insert_dup" ]; then
	echo "<li> <b>mapping</b> is the handle of the specified mapping."
	if [ "${c}" = "array" ]; then
		echo "<li> <b>key</b> is the pointer to the key array to insert"
		echo -n "<li> <b>keylen</b> is the length of the key array, "
		echo 'or the value <b>~0</b> to figure the length as a string'
	fi
	if [ "${c}" = "string" ]; then
		echo "<li> <b>key</b> is the pointer to the key string to insert"
	fi
	if [ "${c}" = "scalar" ]; then
		echo "<li> <b>key</b> is the key value to insert"
	fi
fi
if [ "${f}" = "key" ]; then
	echo "<li> <b>mapping</b> is the handle of the specified mapping."
fi
if [ "${f}" = "key_ptr" -o "${f}" = "key_dup" ]; then
	echo "<li> <b>mapping</b> is the handle of the specified mapping."
	echo "<li> <b>keylen_dst</b> is where to store key length."
fi
if [ "${f}" = "key_copy" ]; then
	echo "<li> <b>mapping</b> is the handle of the specified mapping."
	echo "<li> <b>key_dst</b> is where to store key."
	echo "<li> <b>max_len</b> is the maximum length of the destination space."
fi
if [ "${f}" = "key_len" ]; then
	echo "<li> <b>mapping</b> is the handle of the specified mapping."
fi
if [ "${f}" = "store" -o "${f}" = "store_share" ]; then
	echo "<li> <b>mapping</b> is the handle of the specified mapping."
	echo "<li> <b>data</b> is the value to store."
	if [ "${c}" = "array" ]; then
		echo "<li> <b>datalen</b> is the length of the data array."
	fi
fi
if [ "${f}" = "fetch" -o "${f}" = "fetch_len" ]; then
	echo "<li> <b>mapping</b> is the handle of the specified mapping."
fi
if [ "${f}" = "fetch_ptr" -o "${f}" = "fetch_dup" ]; then
	echo "<li> <b>mapping</b> is the handle of the specified mapping."
	echo "<li> <b>datalen_dst</b> is where to store data length."
fi
if [ "${f}" = "fetch_copy" ]; then
	echo "<li> <b>mapping</b> is the handle of the specified mapping."
	echo "<li> <b>data_dst</b> is where to store data."
	echo "<li> <b>max_len</b> is the maximum length of the destination space."
fi
echo '</ol></p>'

#===================================================================================================
echo '<a name="'"${fn}"'_return"><p><font face="Times New Roman,Times" size=5><b>Return values</b></font><ul>'
if [ "${f}" = "new" ]; then
	echo '<li><b>new mapping handle pointer</b> = the new mapping instance was created successfully'
	echo '<li><b>NULL</b> = an error occurred that prevented creation of the mapping instance'
fi
if [ "${f}" = "find" -o "${f}" = "find_exact" -o "${f}" = "find_exact_lo" -o "${f}" = "find_lo_or_near" -o "${f}" = "find_exact_hi" -o "${f}" = "find_hi_or_near" ]; then
	echo '<li><b>-2</b> = error, no map, bad type'
	echo '<li><b>-1</b> = no node found'
	echo '<li><b>0</b> = node found with no data'
	echo '<li><b>data type</b> = node found with this data type'
fi
if [ "${f}" = "insert" ]; then
	echo '<li><b>-2</b> = error, no map, bad type'
	echo '<li><b>0</b> = node inserted or found with no data type'
	echo '<li><b>data type</b> = node found with this data type'
fi
if [ "${f}" = "insert_dup" ]; then
	echo '<li><b>-2</b> = error, no map, bad type'
	echo '<li><b>-1</b> = not inserted, already exists'
	echo '<li><b>1</b> = new unique member inserted'
	echo '<li><b>2</b> = duplicate member inserted'
fi
if [ "${f}" = "key" ]; then
	echo '<li><b>key value</b> = the returned key value'
	echo '<li><b>0</b> = no active member, error, no map, bad type'
fi
if [ "${f}" = "key_ptr" ]; then
	echo '<li><b>key pointer</b> = pointer to shared key'
	echo '<li><b>NULL</b> = no active member, error, no map, bad type'
fi
if [ "${f}" = "key_dup" ]; then
	echo '<li><b>key pointer</b> = pointer to duplicated key'
	echo '<li><b>NULL</b> = no active member, error, no map, bad type'
fi
if [ "${f}" = "key_copy" ]; then
	echo '<li><b>length</b> = length of actual key even if not all copied'
	echo '<li><b>~0</b> = no active member, error, no map, bad type'
fi
if [ "${f}" = "key_len" ]; then
	echo '<li><b>length</b> = length of key'
	echo '<li><b>~0</b> = no active member, error, no map, bad type'
fi
if [ "${f}" = "store" ]; then
	echo '<li><b>-2</b> = error, no map, bad type'
	echo '<li><b>0</b> = success, data stored'
fi
if [ "${f}" = "store_share" ]; then
	echo '<li><b>-2</b> = error, no map, bad type'
	echo '<li><b>0</b> = success, data stored shared with caller'
fi
if [ "${f}" = "fetch" ]; then
	echo '<li><b>data value</b> = the returned data value'
	echo '<li><b>0</b> = no active member, error, no map, bad type'
fi
if [ "${f}" = "fetch_ptr" ]; then
	echo '<li><b>data pointer</b> = pointer to shared data'
	echo '<li><b>NULL</b> = no active member, error, no map, bad type'
fi
if [ "${f}" = "fetch_dup" ]; then
	echo '<li><b>data pointer</b> = pointer to duplicated data'
	echo '<li><b>NULL</b> = no active member, error, no map, bad type'
fi
if [ "${f}" = "fetch_copy" ]; then
	echo '<li><b>length</b> = length of actual data even if not all copied'
	echo '<li><b>NULL</b> = no active member, error, no map, bad type'
fi
if [ "${f}" = "fetch_len" ]; then
	echo '<li><b>length</b> = length of data'
	echo '<li><b>NULL</b> = no active member, error, no map, bad type'
fi
echo '</ul></p>'

#===================================================================================================
echo '<a name="'"${fn}"'_errors"><p><font face="Times New Roman,Times" size=5><b>Errors</b></font><blockquote>'
if [ "${f}" = "new" ]; then
	echo 'The <b>errno</b> value is set by system functions when an error occurs.'
fi
if [ "${f}" = "find" ]; then
	echo 'The <b>errno</b> value is set by system functions when an error occurs.'
fi
if [ "${f}" = "find_exact" ]; then
	echo 'The <b>errno</b> value is set by system functions when an error occurs.'
fi
if [ "${f}" = "find_exact_lo" ]; then
	echo 'The <b>errno</b> value is set by system functions when an error occurs.'
fi
if [ "${f}" = "find_lo_or_near" ]; then
	echo 'The <b>errno</b> value is set by system functions when an error occurs.'
fi
if [ "${f}" = "find_exact_hi" ]; then
	echo 'The <b>errno</b> value is set by system functions when an error occurs.'
fi
if [ "${f}" = "find_hi_or_near" ]; then
	echo 'The <b>errno</b> value is set by system functions when an error occurs.'
fi
if [ "${f}" = "insert" ]; then
	echo 'The <b>errno</b> value is set by system functions when an error occurs.'
fi
if [ "${f}" = "insert_dup" ]; then
	echo 'The <b>errno</b> value is set by system functions when an error occurs.'
fi
if [ "${f}" = "key" ]; then
	echo 'The <b>errno</b> value is set by system functions when an error occurs.'
fi
if [ "${f}" = "key_ptr" ]; then
	echo 'The <b>errno</b> value is set by system functions when an error occurs.'
fi
if [ "${f}" = "key_dup" ]; then
	echo 'The <b>errno</b> value is set by system functions when an error occurs.'
fi
if [ "${f}" = "key_copy" ]; then
	echo 'The <b>errno</b> value is set by system functions when an error occurs.'
fi
if [ "${f}" = "key_len" ]; then
	echo 'The <b>errno</b> value is set by system functions when an error occurs.'
fi
if [ "${f}" = "store" ]; then
	echo 'The <b>errno</b> value is set by system functions when an error occurs.'
fi
if [ "${f}" = "store_share" ]; then
	echo 'The <b>errno</b> value is set by system functions when an error occurs.'
fi
if [ "${f}" = "fetch" ]; then
	echo 'The <b>errno</b> value is set by system functions when an error occurs.'
fi
if [ "${f}" = "fetch_ptr" ]; then
	echo 'The <b>errno</b> value is set by system functions when an error occurs.'
fi
if [ "${f}" = "fetch_dup" ]; then
	echo 'The <b>errno</b> value is set by system functions when an error occurs.'
fi
if [ "${f}" = "fetch_copy" ]; then
	echo 'The <b>errno</b> value is set by system functions when an error occurs.'
fi
if [ "${f}" = "fetch_len" ]; then
	echo 'The <b>errno</b> value is set by system functions when an error occurs.'
fi
echo '</blockquote></p>'

#===================================================================================================
echo '<a name="'"${fn}"'_seealso"><p><font face="Times New Roman,Times" size=5><b>See also</b></font><blockquote>'
if [ "${f}" = "new" ]; then
	echo '<a href="../../index.html">avlmap index page</a>'
fi
if [ "${f}" = "find" ]; then
	echo '<a href="../../index.html">avlmap index page</a>'
fi
if [ "${f}" = "find_exact" ]; then
	echo '<a href="../../index.html">avlmap index page</a>'
fi
if [ "${f}" = "find_exact_lo" ]; then
	echo '<a href="../../index.html">avlmap index page</a>'
fi
if [ "${f}" = "find_lo_or_near" ]; then
	echo '<a href="../../index.html">avlmap index page</a>'
fi
if [ "${f}" = "find_exact_hi" ]; then
	echo '<a href="../../index.html">avlmap index page</a>'
fi
if [ "${f}" = "find_hi_or_near" ]; then
	echo '<a href="../../index.html">avlmap index page</a>'
fi
if [ "${f}" = "insert" ]; then
	echo '<a href="../../index.html">avlmap index page</a>'
fi
if [ "${f}" = "insert_dup" ]; then
	echo '<a href="../../index.html">avlmap index page</a>'
fi
if [ "${f}" = "key" ]; then
	echo '<a href="../../index.html">avlmap index page</a>'
fi
if [ "${f}" = "key_ptr" ]; then
	echo '<a href="../../index.html">avlmap index page</a>'
fi
if [ "${f}" = "key_dup" ]; then
	echo '<a href="../../index.html">avlmap index page</a>'
fi
if [ "${f}" = "key_copy" ]; then
	echo '<a href="../../index.html">avlmap index page</a>'
fi
if [ "${f}" = "key_len" ]; then
	echo '<a href="../../index.html">avlmap index page</a>'
fi
if [ "${f}" = "store" ]; then
	echo '<a href="../../index.html">avlmap index page</a>'
fi
if [ "${f}" = "store_share" ]; then
	echo '<a href="../../index.html">avlmap index page</a>'
fi
if [ "${f}" = "fetch" ]; then
	echo '<a href="../../index.html">avlmap index page</a>'
fi
if [ "${f}" = "fetch_ptr" ]; then
	echo '<a href="../../index.html">avlmap index page</a>'
fi
if [ "${f}" = "fetch_dup" ]; then
	echo '<a href="../../index.html">avlmap index page</a>'
fi
if [ "${f}" = "fetch_copy" ]; then
	echo '<a href="../../index.html">avlmap index page</a>'
fi
if [ "${f}" = "fetch_len" ]; then
	echo '<a href="../../index.html">avlmap index page</a>'
fi
echo '</blockquote></p>'

#===================================================================================================
echo '<hr noshade size=2 width=100%>'

fi

if [ "${pass}" = "each" ]; then
	output_copyright
	echo "EOF"
	echo "chmod 644 ${dirx}/${fn}.html"
	echo "ls -ld ${dirx}/${fn}.html"
fi

done
done

if [ "${pass}" = "key" -o "${pass}" = "data" -o "${pass}" = "keydata" ]; then
	output_copyright
	echo "EOF"
	echo "chmod 644 ${dir}/${pass}_functions.html"
	echo "ls -ld ${dir}/${pass}_functions.html"
fi

done

echo "cat <<EOF >>index2.html"
echo '</ul>'
echo '<hr noshade size=2 width=100%>'
output_copyright
echo 'EOF'
echo "ls -ld index2.html"

}

output_commands | sh
exit $?
