#! /bin/true /sh # [hp] dummy for editting
# for "lib4th", (C) 5/2001 berlin h-peter recktenwald <phpr@snafu.de>
# MK-hx-defs - included by MK-h and MK-x, after changeing to top-dir:
#	file and vari names, utilites, tests, common shell functions

# # # -------------------------------------------------------------- # # #

# $d, $u $hu $hr $xx and $PATH must be set prior to inclusion of this file
# optional ${ANSDIR}, for a link to dpans94 html documents.

# clear cognomina which might be def'd in the environment
unset a ac b bc c dc ds e EN f fu g
unset he hf hg hh hl hn hp hq ht hv hx hz i il k
unset l la lc m n ne o og ol om on oq ot oy p pf pn q
unset r s sn st su t tb tc tl tr v vc vs w wu x xr y
# frei: h j (q.)

# # # pre-requisites tests
# ------------------------

# package version
vs=$(relse.sh r.v.x.t)

# for l4 compressed html files storage
hz=;[ -d /hpg5/up-sna ]&&{ find $(pwd) -name html-gz|while read i;do [ -x ${i} ]&&hz=${i}&&break;done; }

# no other "language" required but, some unix utilities. checking:
w () { [ -n "$(which ${1})" ]||{ echo "\"${1}\" missing";exit 1; }; }
w basename
w cat
w cp
w cut
w find
w grep
w head
w pwd
w rm
w sed
w sort
w sync
w tac
w tail
w wc
unset w

# # # names & attributes for html output
# --------------------------------------

# package name
pn="lib4th"
wu="http://home.snafu.de/phpr/";	# text url, 'web', etc.
fu="http://home.snafu.de/phpr/";	# files url, ftp, etc.
# where the source package can be found
su="${fu}${pn}.src.tar.bz2";		# source package URL
sn="library";				# html link title
# inet text access
hf="lhpf8.html";			# lib4th page
hp="${wu}${hf}";			# l4 home page url
hn=${pn};				# html link title

# link to dpans94 index page
[ -n "${ANSDIR}" ]&&ad="|&nbsp;<a href=\"${ANSDIR}/dpansf.htm\">dpans94</a>&nbsp;]"

# colours & fount
tc='text="#FFFFDA"'
bc='bgcolor="#330033"'
lc='link="#FFCC00"'
vc='vlink="#CCCCCC"'
ac='alink="#FF99FF"'
st='style="font-family: lucida,helvetica,arial"'
ft='<font face="lucida">'
tf='</font>'

# # # names to working with
# -------------------------

# in
il=l4words.inc;		# ref. source: words' names, labels, annotations
pf="a-4th-design.inc";	# to fetching the explantion to naming conventions
# define ${s} such that it contains _all_ asm reference files, wrt ${d} -re above-
s="lib4th.asm $(find ${d}/src/ -name l4\*\.inc ! -name l4words\.inc -exec basename \{\} \;)"

# out
og=l4gls.html;		# asm source comments
ot=l4toc.html;		# alphabetic listing, sorted by words
oa=l4voc.html;		# alphabetic listing, sorted by wordlists
ol=l4lbl.html;		# labels and files reference
on=l4nte.html;		# annotations glossary
oq=l4xrf.html;		# cross-ref list
oy=l4tic.html;		# alphabetic listing, sorted by topic
om=l4gls-missing;	# words which weren't found
# dirs
dc=${d}/doc/
ds=${d}/src/
# dest & tmp
g=${dc}${og};		# glossary text
t=${dc}${ot};		# by words
a=${dc}${oa};		# by vocs
e=${dc}${om};		# missing words
i=${ds}${il};		# wordlist src-file
o=${dc}${on};		# nomenclatura:)
p=${dc}${pf};		# naming conventions
q=${dc}${oq};		# xref list
r=${dc}${il};		# wordlist work-file
x=${dc}${ol};		# labels src files ref
y=${dc}${oy};		# glossary by topic

# # # substitutes
# ---------------

# by "bash" text evaluation required substitutes
# ..X or, ..R which will be reverted after rsp lines' processing
X1R="\"'\"";		# tick
X2R="\"\['\]\"";	# compile-tick
X5R="\"kbd'\"";		# kbd'
X6X='\\';		# comment till <eof>
X8R='\';		# comment till <eol>
X7R="{'}";		# words which end w/ "{"

# char for substitution w/ <sed>
tb=$(echo -e "\t")

# # # auxilary shell functions
# ----------------------------

# links between pages
tr="<p>by&nbsp;\
[&nbsp;<a href=\"${ot}\">name</a>&nbsp;\
|&nbsp;<a href=\"${oy}\">topic</a>&nbsp;\
|&nbsp;<a href=\"${oa}\">voc</a>&nbsp;] \
[&nbsp;<a href=\"${og}\">glos</a>&nbsp;\
|&nbsp;<a href=\"${ol}\">files</a>&nbsp;\
|&nbsp;<a href=\"${oq}\">xref</a>&nbsp;] \
[&nbsp;<a href=\"${on}\">notation</a>&nbsp;\
${ad} [&nbsp;<a href=\"#bot\">bot</a>&nbsp;\
|&nbsp;<a href=\"#top\">top</a>&nbsp;]</p>"

# 8 blanks
bl8='&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'

# <table... and, for and instead of, (most often) not correctly processed <colgroup> tag
cg='<table width="95%">
<colgroup><col width="20%"><col width="20%"><col width="20%"><col></col></colgroup>
<tr><td width="20%"><tab to="i1">&nbsp;</td><td width="20%"><tab to="i3">&nbsp;</td><td width="20%"><tab to="i5">&nbsp;</td><td><tab to="i7">&nbsp;</td></tr>
'

# html header, w/ lynx specfic <tab> tags defn
hh () {
echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">
<!-- Copyright $(date +%Y) h-peter recktenwald Berlin -- See QT-License.html for license terms -->
<html>
<head>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\">
<title>lib4th ${vs} ${1}</title>
</head>
<body ${tc} ${bc} ${lc} ${vc} ${ac} ${st}>${ft}
<a name=\"top\"></a>
${tr}
<h3 align=\"center\">lib4th ${vs} ${1}</h3>
<center>Latest <a href=\"${su}\">${sn}</a> source -re- <a href=\"${hf}\">${hn}</a> <a href=\"${hp}\">homepage</a>.</center>
<hr width=\"100%\"><small>
<pre>
Text formatted for the <a href=\"http://lynx.browser.org\">lynx html-browser</a> and for plain text printing, 132 chars/line</small></br>
|<tab id=\"i0\">${bl8}<tab id=\"i1\">${bl8}<tab id=\"i2\">${bl8}<tab id=\"i3\">${bl8}<tab id=\"i4\">${bl8}<tab id=\"i5\">${bl8}<tab id=\"i6\">${bl8}<tab id=\"i7\">${bl8}<tab id=\"i8\">${bl8}<tab id=\"i9\">${bl8}<tab id=\"i10\">${bl8}<tab id=\"i11\">${bl8}<tab id=\"i12\">${bl8}<tab id=\"i13\">${bl8}118>|<br>
</pre>
<hr width=\"100%\">
"
}

# html trailer
he () { echo -e "${1}</blockquote>\n<hr width=\"100%\"><a name=\"bot\"></a>\n${tr}\n${tf}</body></html>"; }

# MK-hx-defs <eof>
