--- lynx-cur-2.8.6.orig/CHANGES
+++ lynx-cur-2.8.6/CHANGES
@@ -1,6 +1,314 @@
 Changes since Lynx 2.8 release
 ===============================================================================
 
+2005-01-05 (2.8.6dev.11)
+* add presentation type for application/xml and text/xml mime types as per
+    http://www.w3.org/TR/xhtml-media-types/
+    http://www.w3.org/TR/2002/NOTE-xhtml-media-types-20020801
+  which states that they may be used, though application/xhtml+xml is the
+  preferred media type (Debian #184482) -TD
+* remove an extra free() introduced in fixes from dev.10 for leak-checking
+  (reports by Thorsten Glaser, FLWM) -TD
+
+2005-01-02 (2.8.6dev.10)
+* correct final sed command in help_files.sed which was not a basic regular
+  expression, left some links ending with .gz.gz -TD
+* update config.guess, config.sub
+* modify configure script to check for Intel compiler 8.0 -TD
+* modify ifdef's for USE_DEFAULT_COLORS, disabling it if the
+  use_default_colors() function is not found -TD
+* modify to allow compiling with C++ compiler, e.g., rename conflicting
+  keywords such as new, class, template (suggested by Nelson Beebe) -TD
+* remove leading/trailing blanks from suggested title string for ADD_BOOKMARK
+  (request by Walter Ian Kaye) -TD
+* add tags rules to makefile.in's -TD
+* repair fix for Debian #171312 by ensuring that it is only invoked if a URL
+  fragment was found in the getfile() call (report by PG) -TD
+* correct leak-checking for result of LYAddHilite(), which was not freeing
+  the associated strings -TD
+* correct leak-checking for result of LYcommandList(), which was not freeing
+  the associated strings -TD
+* correct pointer initialization in LYCheckForProxyURL() broken by fix for
+  Debian #240237 (reported by GV, Stef Caunter) -TD
+
+2004-12-30 (2.8.6dev.9)
+* remove fixed limit on history[] array (report by Richard Eyre) -TD
+* improve logic for highlighting links which extend to multiple lines by
+  ensuring that if they cover a blank line that the following lines of the
+  link will be highlighted rather than the blank line (report Hataguchi
+  Takeshi).
+* replace most instances of exit() by exit_immediately(), except those needed
+  for the leak-checking code, to add an ifdef'd call to _nc_freeall() which
+  simplifies testing with valgrind -TD
+* fix definition of put_clip(), to compile in Windows environment (Hataguchi
+  Takeshi).
+* update da.po, et.po, hu.po, nl.po, sv.po, tr.po from
+    http://www.iro.umontreal.ca/translation/maint/lynx/
+* fix for mouse versus network I/O -GV
+  Building the djgpp version with S-Lang and mouse-support causes network I/O
+  to stop when Lynx is idle waiting for key/mouse events.  This patch adds a
+  djgpp_idle_loop() function that does what getxkey() used to do; calls
+  tcp_tick() to finish off closed sockets and reply to pings etc.  Tested with
+  PD-curses 2.6 too, but I couldn't get mouse to work under DOS.  Not sure
+  that's possible at all.
+* add "Anonymous FTP Password" to Options menu, to allow user to override use
+  of personal email address as the anonymous ftp password (Debian #137480) -TD
+* modify LYCheckForProxyURL() to check if a colon follows a slash, which would
+  make the colon not part of a URL (report/patch by Matt Kraal, Debian
+  #240237).
+* add test/special_urls.html -TD
+* minor fixes/update test/iso8859-1.html from
+	http://www.ramsch.org/martin/uni/fmi-hp/iso8859-1.html
+* add check for broken WU_FTPD 2.6.2-12, e.g., at ftp://ftp.pppl.gov/, and
+  disable EPSV.  This is ifdef'd with BROKEN_WU_FTPD and checks version (Debian
+  #66560, as well as April 2003 reports by HN, PW) -TD
+* modify getfile(), etc., to ensure that following a link consisting of a
+  fragment will move the cursor to the link containing the target rather than
+  simply ensuring that it is visible (Debian #171312) -TD
+* modify ShowInfo() to list the rendered size in bytes if the Content-Length
+  is not available (Debian #61085) -TD
+* modify print_wwwfile_to_fd() and void print_crawl_to_fd() to ensure that no
+  trailing blanks are written (Debian #204515) -TD
+* modify behavior when user attempts to toggle a radiobutton off, to make the
+  message that one radio button must be selected only in novice mode (Debian
+  #121520) -TD
+* make the maximum number of cookies configurable in lynx.cfg, added
+  MAX_COOKIES_DOMAIN, MAX_COOKIES_GLOBAL and MAX_COOKIES_BUFFER (Debian
+  #152810) -TD
+* reduce embedded blanks in button labels to single blanks -TD
+* reduce embedded blanks in title strings to single blanks (Debian #284679) -TD
+* add command-line option (-syslog-urls) and lynx.cfg settings (SYSLOG_TEXT,
+  SYSLOG_REQUESTED_URLS) to allow syslog'ing of URLs to be optional.  This
+  cannot be set from the options menu (Debian #282739) -TD
+* modify HTParse() to restore a slash which may be removed during
+  simplification of URLs such as "file://localhost/tmp/..".  The
+  LYFillLocalFileURL() function would then append the current directory to the
+  URL rather than the expected "/".  This case which happens in DIRED, was
+  caused by 2.8.5dev.15 changes (Debian #285140) -TD
+
+2004-11-07 (2.8.6dev.8)
+* improve def7_uni.tbl substitutions for the symbols beginning at U+2600
+  (patch by Tim Larson <Tim.Larson@conagrafoods.com>).
+* update nl.po, sv.po from
+    http://www.iro.umontreal.ca/translation/maint/lynx/
+* add clean.com -TD
+* scripting fixes to make OpenVMS/IA64 platform build/work -TD
+* several changes to use const, prompted by VMS compiler warnings -TD
+* remove build-slang.com -TD
+* simplify libmake.com -TD
+* modify build.com, making its second parameter a comma-separated list of the
+  special libraries which may be used, e.g., bzlib, slang, ssl and zlib -TD
+* some cleanup using non_empty() macro -TD
+* limit TEXTAREA columns to the screen width, and rows to 3 times the screen
+  height (report by FLWM) -TD
+
+2004-10-17 (2.8.6dev.7)
+* update de.po, et.po from
+    http://www.iro.umontreal.ca/translation/maint/lynx
+* clarification in manpage description of "-pseudo_inlines" option (Dan
+  Jacobson).
+* correct parsing of embedded URLs which have parameters but no path, e.g.,
+  base
+    http://wj55.org/Minutes.php
+  and embedded
+    ?date_meeting=2004-08-31
+  (Debian #274619, report/analysis by Liam K Morland) -TD
+* improve description of --assume-local-charset option (Debian #270915).
+* revise configure script check whether _POSIX_C_SOURCE should be defined,
+  taking into account the _POSIX_SOURCE definition (report by PG) -TD
+* add --with-system-type option to configure script to simplify testing the
+  case-statements involving $host_os -TD
+* fix a memory leak in IPv6 version of HTGetAddrInfo() -TD
+* modify HTCompressed() to choose the last viewer in the list with the best
+  quality.  User-defined viewers appear after the built-in viewers, and by
+  choosing the last, lynx allows one to override the built-in defaults -TD
+* add "deflate" to the encoding types which lynx implements.  This consists
+  of several parts (report by Thorsten Glaser) -TD
+  + adapted logic from w3m's inflate.c to construct an internal "deflate"
+    decompressor.  Tested this with
+      http://carsten.codimi.de/gzip.yaws/
+  + simplify VMS-specific logic for trimming version in HTLoadFile().
+  + combined VMS- and Unix logic for decompression in HTLoadFile() as a new
+    function decompressAndParse() to eliminate clutter.  As a side-effect,
+    eliminate some memory leaks in cases where the file is not loaded properly.
+  + add/use new function HTEncodingToCompressType() to eliminate clutter.
+  + add "deflate" to the options menu.
+  + modify logic that builds "Accept-Encoding" value to omit encodings which
+    have no external decompressor associated.  The effect of this change is to
+    allow lynx to behave as it did before adding the (possibly incomplete)
+    "inflate" support.
+  + add INFLATE_PATH to lynx.cfg, to optionally specify an external program
+    which can be used to decompress deflated files.  For testing, a shell
+    script using w3m's utility, e.g., /usr/lib/w3m/inflate, sufficed.
+    NOTE: As currently implemented, lynx requires the external decompression
+    programs to be specified even if it can decompress using library calls.
+  + use ".zz" for suffix of downloaded (but not inflated) deflated files,
+    mapped to application/deflate and application/x-deflate.
+* fix LYSetConfigValue(), which did not properly handle the CONF_PRG case which
+  is used to allow user configuring the program paths -TD
+* fix content_is_compressed() function, which was checking for the absence only
+  of some nonstandard encodings (8bit, 7bit, binary) rather than for the
+  presence of the encodings as specified in RFC 2068 (gzip, compress, etc).
+  This makes lynx able to view a site
+  which puts the charset as the Content-Type (report by FLWM) -TD
+* fix configure script:  top-level makefile uses $(TAR), which was not defined
+  if --without-dired option was used (report by Gabor Z Papp) -TD
+
+2004-10-10 (2.8.6dev.6)
+* highlight the target and pause for 20 milliseconds when selecting a link with
+  the mouse -GV
+* improve layout of options-menu and info-page for multibyte character sets by
+  computing the extent of the labels.  This works only for wide-character
+  curses (this addresses part of Debian #240069) -TD
+* improve check in LYstartPopup() for case where a window would be created too
+  far right to be entirely visible.  ncurses changes in 20040417 to allow
+  windows to extend beyond the terminal limits exposed this problem (which may
+  have occurred with other versions of curses).  Older versions of ncurses
+  would return an error in this case (forcing lynx to do the proper layout),
+  obscuring the actual problem.  Noticed that the same problem applies to slang
+  configuration, and applied a comparable fix there too -TD
+* modify HTConfirmCookie() to ensure the translator's note is copied into the
+  lynx.pot file, by adding a gettext("Y/N/A/V") call after the comment -TD
+* remove references in makefile.in to the "intl" subdirectory since that is no
+  longer packaged with lynx -TD
+* modify column limits, allowing text to be written to the last column on the
+  screen.  This allows users to view text which is formatted for 80 columns
+  without the last character of each line wrapping to the next line -TD
+* minor fixes to fr.po (Debian #119751, and aspell) -TD
+* remove newline from format in lookup_reject(), fixes a bug introduced in
+  2.8.5dev.2 which caused traversal reject-lookups to fail -TD
+* minor fixes to fr.po, cs.po and pt_BR.po to eliminate fatal errors as
+  reported by "msgfmt -c -v" -TD
+* minor fix to fr.po (Debian #271048, report/patch by Arnaud Giersch).
+* update URL for "HTML Quick Reference Guide" in lynx_help_main.html (report
+  by Jim Jackson).
+* update hu.po from
+	http://www.iro.umontreal.ca/translation/maint/lynx
+* remove a "defined(gettext)" from the ifdef's in HTConfirmCookie(), since
+  recent GNU gettext, e.g., 0.13.1, introduced an incompatible/undocumented
+  change to make the function a macro which is defined in terms of dgettext()
+  (Debian #204994, report by Mattias Ostergren).
+* modify pumpData() in HTMIME.c to improve recovery when a charset is found
+  that cannot be translated.  Before this change, the charset was not stripped
+  from the format string, e.g.,
+	text/html; charset=big5
+  and since there would be no match for the format, lynx would offer to simply
+  download the page (if interactive), or refuse to format (for dumps).
+  Although the content of the page is unusable, the user can still navigate
+  the page using the links which may be there (Debian #254603) -TD
+* add -nonumbers option, which modifies the output of -dump to suppress the
+  link-numbering (Debian #255571) -TD
+* add -listonly option, which modifies the output of -dump to show only the
+  list of links (Debian #255571) -TD
+* modify treatment of symbolic links for ftp-URLs to show the link target, as
+  with the local directory editor -TD
+* correct sort-order of local directory listing, using the target of a symbolic
+  link to determine whether it is grouped with files or directories (adapted
+  from patch by Kees Cook) -TD
+* modify template for temporary-directory name, adding "lynx" prefix (Debian
+  #267356) -TD
+* fixes for configure script macros used for --enable-nls when --srcdir is
+  used (from bug report for dialog by Mike Castle) -TD
+* improve configure script macro CF_XOPEN_SOURCE, ensuring that _POSIX_C_SOURCE
+  is defined with a value (comment on comp.sys.stratus newsgroup) -TD
+* reduce TRST_MAXROWSPAN and TRST_MAXCOLSPAN to 200, which is more plausible
+  than 10000 by 1000 (discussion on lynx-dev related to report by Edgard
+  Pineda) -TD
+* modify LYShowInfo.c to entify most strings, and provide for alignment of
+  fields in different locales -TD
+
+2004-06-30 (2.8.6dev.5)
+* use LYEnsureAbsoluteURL() on the value passed to handle_LYK_HELP() in case
+  it is of the form file:///path rather than file://localhost/path -DK
+* add configure check for ncurses' curses_version() function, using that in
+  the "-version" output.  Add comparable ifdef's for PDCurses and slang -TD
+* Some patches to enable IPv6 on Windows (tested with MingW and MSVC6).  Some
+  minor cleanups also -GV
+  + LYutils.c; fixed extraction of module/system error strings.
+  + Xsystem.c; use <io.h> for mktemp() prototype.
+  + HTTCP.c; don't use global host[], fixed call-convention of thread- function
+    (must be __stdcall).  Sets pending WSAHOST_NOT_FOUND error status.
+  + HTTP.c; _thread_func() wasn't __stdcall.
+  + LYexit.c; avoid redeclaring error of exit() in <process.h>.  IMHO it's very
+    bad to shadow ANSI functions like this.  Should call LYexit() explicitly.
+  + www_tcp.h; cleanup for MSVC and IPv6 headers and macros.  Increase
+    MAXHOSTNAMELEN to 128.
+* updated po files (da.po, et.po, hu.po, sv.po, tr.po) from
+  http://www.iro.umontreal.ca/translation/domains/
+* change HTDOS_wwwName() and HTVMS_wwwName() to return a const value (report
+  by Serge B) -TD
+* update configure script macros CF_XOPEN_SOURCE (fixes Debian #238057) and
+  CF_X_ATHENA (from xterm).
+* update config.guess (2004-06-24) and config.sub (2004-06-24)
+* modified mailcap command and testcommand substitutions to provide for
+  running the testcommand's after program initialization (prompted by review
+  of Debian #167200, which gave as example a mailcap using %{charset} in the
+  test commands) -TD
+* add (ifdef'd with EXP_HTTP_HEADERS) code in HTMIME.c to collect and in
+  LYShowInfo.c to display the full text of the HTTP headers -TD
+* correct command-line options table for "-get_data" and "-post_data" which
+  were processed twice, thereby discarding the value (Debian #132674) -TD
+* lynx accepts multiple URLs on the command line; all are added to G)oto
+  history.  Documented this in manpage (Debian #177062) -TD
+* modify logic for -dump so it can dump all pages listed on the command line
+  (Debian #199131) -TD
+* add presentation type for application/xhtml+xml mime type as per RFC 3236
+  (report by Elimar Riesebieter) -TD
+
+2004-05-23 (2.8.6dev.4)
+* use puts() rather than printf() in some messages to avoid chance of "%" in
+  the translation -TD
+* add experimental option --enable-japanese-utf8 for using libiconv for
+  Japanese and UTF-8 -TH, TD
+* update makelynx.bat -Victor Schneider
+* modify configure script CF_ADD_CFLAGS to put definitions of quoted strings
+  in EXTRA_CPPFLAGS -TD
+* fixes from Thorsten Glaser:
+  + check for arc4random as a possible random function.
+  + modify configure script CF_CHECK_CACHE to look for config.guess in
+    $ac_aux_dir if it is not in the source directory.
+* fix naming conflict with AS_cmp() function when NOT_ASCII is defined -PG
+* read user's ".newsauth" file for news-server authentication information
+  (prompted by A R Vener request) -TD
+* modify HTSaveAndExecute() to check first for result from HTFileSuffix()
+  before choosing between BIN_SUFFIX and HTML_SUFFIX.  This allows the PDF
+  viewer on OS X to get the proper suffix (.pdf) rather than .bin -PG, TD
+* filter out extra screen-repainting when a charset change is made -IZ
+* update README and other documentation to reflect new mailing list -TD
+* add PREFERRED_ENCODING to lynx.cfg, along with an options-menu selection for
+  this, to set "Accept-Encoding:" string -TD
+* add PREFERRED_MEDIA_TYPES to lynx.cfg, corresponding to the option for
+  HTFilterPresentations().  A minimal set of media types is used by default,
+  though the old behavior can be selected -TD
+* modify HTFilterPresentations() to use new option menu entry for specifying
+  what parts of the user- and system-mailcap data to use in Accept's.  The
+  intent is to provide easily managed subsets of the Accept string, to work
+  with servers that do not accept long Accept strings (prompted by discussion
+  on lynx-dev mailing list) -TD
+* Remove logic from HTFilterPresentations() which reduced the Accept strings
+  based on wildcards since RFC 2616 says wildcards are lower precedance than
+  other settings -TD
+* improve matching for mailcap test-commands in HTInit.c by eliminating
+  unnecessary whitespace with TrimCommand() -TD
+* remove obsolete note about SSL patches in lynx_url_support.html -TD
+
+2004-05-06 (2.8.6dev.3)
+* add scripts/indent.sh, use this to reindent C source files -TD
+* bump version in makefile.in to 2.8.6 -TD
+
+2004-04-27 (2.8.6dev.2)
+* modify CF_NCURSES_LIBS to only look for -lmytinfo when building with ncurses.
+  This works around FreeBSD's broken linker semantics when configuring for
+  ncursesw -TD
+* update CF_GNUTLS macro to look for -lgnutls-openssl as well as the older
+  -lgnutls-extra library -TD
+* fix a spurious match of <openssl/ssl.h> when --with-ssl=path option provides
+  enough information to ensure that the test would be incorrect -TD
+* update config.guess (2004-02-16), config.sub (2004-02-23)
+* fixes to src/chrtrans/makefile.in, e.g., for building PDCurses version,
+  broken by dev.1 changes for cross-compiling -TD
+* remove macros such as ARGS1, NOPARM which supported K&R compilers -TD
+
 2004-04-19 (2.8.6dev.1)
 * correct ifdef in LYgetattrs() to ensure that getattrs() is used only if the
   configure script actually found it (report/patch by Paul Gilmartin).
@@ -46,7 +354,7 @@
   + use $ac_config_sub variable in CF_CHECK_CACHE macro.
   + add case in CF_XOPEN_SOURCE macro to prevent defining _XOPEN_SOURCE
   + use $(MKINSTALLDIRS) variable in generated makefile.
-  + correct comment in lynx.cfg for the default value of FTP_PASSIVE 
+  + correct comment in lynx.cfg for the default value of FTP_PASSIVE
   + increase pattern length for mkdtemp() call.
 * add command-line & menu option/config variables to replace the compile-time
   UNDERLINE_LINKS definition (suggested by BL) -TD
@@ -73,7 +381,7 @@
   Metzler) -TD
 * remove intl subdirectory (gettext-0.10.35), since some of the ".po" files
   have been modified to rely upon newer features of gettext.  Modified
-  configure script macro to report this properly -TD 
+  configure script macro to report this properly -TD
 * add SSL_CERT_DIR, SSL_CERT_FILE to lynx.man (suggested by Stef Caunter) -TD
 * documentation updates for DJGPP -DK, LP, FLWM
 * update address for Free Software Foundation in COPYHEADER and COPYING
@@ -254,7 +562,7 @@
     port-numbers from comparison).
   + fix a few typos & compiler-warnings.
 * add PT154 charset support.  See
-  http://www.iana.org/assignments/charset-reg/PTCP154 for more information. 
+  http://www.iana.org/assignments/charset-reg/PTCP154 for more information.
   (patch by Timur Birsh <birsh@mail.kz>)
 * integrate some improvements for configure script in CF_BUNDLED_INTL and
   CF_OUR_MESSAGES from tin and dialog -TD
@@ -334,7 +642,7 @@
   Links properly deleted when reparsing the document -LP
 * Use less memory for documents with many anchors:  most anchors are never
   visited, just stored for the reference.  So fill in adult_table[] with
-  HTParentAnchor0 (36 bytes size) instead of full HTParentAnchor (~200 bytes). 
+  HTParentAnchor0 (36 bytes size) instead of full HTParentAnchor (~200 bytes).
   HTParentAnchor now allocated on demand, nearly 1:1 to HText.  [more comments
   in HTAnchor.h, changes located in HTAnchor.c] -LP
 * HTParentAnchor0 stores its hash value, to avoid calling HASH_FUNCTION twice
@@ -410,7 +718,7 @@
   the table.  On my system with 128M memory, this leads to only 4M of the
   process space swapped.
 * add case LYK_TO_CLIPBOARD to HTCheckForInterrupt (not a good place), to allow
-  COPY command to work during download (copying the location to clipboard). 
+  COPY command to work during download (copying the location to clipboard).
   The best thing would be to get the location *after* redirects, but this will
   require some additional work -IZ
 * add popen-based support for cut/paste.  This is a slightly reworked patch to
@@ -424,7 +732,7 @@
 * fix HTLoadFinger() which was miscasting const data -TD
 * update Subir Grewal's Lynx links URL to the newest location
   http://www.subir.com/lynx.html -TD
-* add configure option --with-gnutls, to allow lynx to be built with gnutls. 
+* add configure option --with-gnutls, to allow lynx to be built with gnutls.
   Used gnutls 0.8.6 on Redhat 8.0 to login at yahoo (gnutls is not very
   portable, so this is an experimental option) -TD
 * modify loop in HTInitProgramPaths() to convert enum ProgramPaths to an
@@ -433,13 +741,13 @@
   internal URL types such as lynxprog (report by P.J.Walsh) -TD
 * modified ifdef's to enable -connect_timeout option for DJGPP -GV
   In particular, in LYUtils.c, undef "select" in case Lynx is compiled with
-  curses (and not S-Lang).  Watt-32's select_s cannot be used on a 
+  curses (and not S-Lang).  Watt-32's select_s cannot be used on a
   stdin handle, so one must undef it and use DJGPP's select().
 * modify ifdef in HTCheckForInterrupt() to work with MingW and PDcurses -GV
 * add version information for the macros in aclocal.m4 (request by Lars
   Hecking) -TD
 * modify file-upload to use actual binary-data rather than base64-format -TD
-* generate unique boundary for multipart data in HText_SubmitForm() -TD 
+* generate unique boundary for multipart data in HText_SubmitForm() -TD
 * reorganize HText_SubmitForm(), maintaining post data using bstring's -TD
 * modify HText_SubmitForm() to add field name for the fake coordinate pair
   when formatting a multipart submit (report by Peter Pilsl
@@ -787,7 +1095,7 @@
 * add environment variable LYNX_LOCALEDIR to simplify configuration on OS/2
   EMX (from discussion with Michel Such) -TD
 * add alias for charsets "ISO-8859-8-I" and "ISO-8859-8-E" to "iso-8859-8"
-  (request by Atsuhito Kohda) -TD
+  (Debian #152441, request by Atsuhito Kohda) -TD
 * modify handling of HTML_SUP to always append '^'.  It was checking if the
   preceding character was a valid hexadecimal code (reported by HN and Steve
   White <swhite@zipcon.net>) -TD
--- lynx-cur-2.8.6.orig/INSTALLATION
+++ lynx-cur-2.8.6/INSTALLATION
@@ -400,6 +400,9 @@
   --enable-ipv6         		(define ENABLE_IPV6)
 	use experimental IPV6 (with IPV4) logic.
 
+  --enable-japanese-utf8		(define EXP_JAPANESEUTF8_SUPPORT)
+	use experimental Japanese UTF-8 logic.
+
   --enable-justify-elts			(define EXP_JUSTIFY_ELTS)
 	use experimental element-justification logic.
 
--- lynx-cur-2.8.6.orig/LYMessages_en.h
+++ lynx-cur-2.8.6/LYMessages_en.h
@@ -4,6 +4,7 @@
  *   (c) Copyright 1992, 1993, 1994 University of Kansas
  *	 1995-1999: GNU General Public License
  */
+
 #ifndef LYMESSAGES_EN_H
 #define LYMESSAGES_EN_H
 
@@ -207,7 +208,6 @@
 #define NOT_IN_TEXTAREA_NOEDIT gettext("Not in a TEXTAREA; cannot use external editor.")
 #define NOT_IN_TEXTAREA gettext("Not in a TEXTAREA; cannot use command.")
 
-
 #define FILE_ACTIONS_DISALLOWED gettext("file: ACTIONs are disallowed!")
 #define FILE_SERVED_LINKS_DISALLOWED \
  gettext("file: URLs via served links are disallowed!")
--- lynx-cur-2.8.6.orig/PROBLEMS
+++ lynx-cur-2.8.6/PROBLEMS
@@ -164,7 +164,7 @@
     video attributes but then the arrow keys are messed up. - Donald S.
     Teiser (dsteis01@homer.louisville.edu)
     NOTE: If HP fixes the problem or you come up with a better workaround,
-          notify the lynx-dev@sig.net list.
+          notify the lynx-dev@nongnu.org list.
     Updated NOTE (1996-09-02):  A patch reportedly is available from HP to
           fix the select() problem, so that "-lc" is no longer needed, but
 	  the curses glitch is not yet fixed, and you should still include
--- lynx-cur-2.8.6.orig/README
+++ lynx-cur-2.8.6/README
@@ -123,31 +123,16 @@
 
 LYNX-DEV MAILING LIST
 
-   To subscribe to lynx-dev, send email to <URL: mailto:majordomo@sig.net>
-   with only the following message in the body:
-
-      SUBSCRIBE LYNX-DEV address
-
-   where inclusion of your email address is optional if it can be obtained,
-   correctly, from the mail headers of your subscription request.
+   To subscribe to lynx-dev, send email to
+   <URL: mailto:lynx-dev-request@nongnu.org>
+   with "subscribe" for a subject line.
 
    If you wish to unsubscribe from lynx-dev, send email to
-   <URL: mailto:majordomo@sig.net> with only the following message in the body:
-
-      UNSUBSCRIBE LYNX-DEV address
-
-   where inclusion of your email address is optional if it can be obtained,
-   correctly, from the mail headers of your request.
-
-   Also, to get a list of useful majordomo commands, send email to
-   <URL: mailto:majordomo@sig.net> with the following command:
-                ^^^^^^^^^
-      HELP
-
-   PLEASE!!! do not send commands to the lynx-dev mailing list itself.
+   <URL: mailto:lynx-dev-request@nongnu.org> 
+   with "unsubscribe" for a subject line.
 
    Any messages you wish to post should be sent to
-   <URL: mailto:lynx-dev@sig.net>.
+   <URL: mailto:lynx-dev@nongnu.org>.
    PLEASE use the lynx-dev list, NOT private email to the developers,
    for questions or discussion about Lynx, or contributions of patches.
    Patches should use the unified diff format (diff -u), which can be
@@ -160,4 +145,4 @@
    will send a carbon copy to you.  View the archives at:
 
 		    "lynx-dev Mailing list archives"
-		<URL:http://www.flora.org/lynx-dev/html/>
+		<URL:http://mail.gnu.org/mailman/listinfo/lynx-dev/>
--- lynx-cur-2.8.6.orig/WWW/Library/vms/libmake.com
+++ lynx-cur-2.8.6/WWW/Library/vms/libmake.com
@@ -1,8 +1,11 @@
-$ v = 'f$verify(0)'
+$ v0 = 0
+$ v = f$verify(v0)
 $!			LIBMAKE.COM
 $!
 $!   Command file to build the WWWLibrary on VMS systems.
 $!
+$!   23-Oct-2004	T.Dickey
+$!	cleanup, remove duplication, etc.
 $!   08-Oct-1997	F.Macrides		macrides@sci.wfeb.edu
 $!	Added comments and minor tweaks for convenient addition of
 $!	compiler definitions and compiler and linker options.
@@ -35,7 +38,14 @@
 $!	list with a lead comma, e.g., ",HAVE_FOO_H,DO_BLAH".  They
 $!	will apply only to the libwww-FM modules. - FM
 $!
-$ extra = ""
+$ extra_defs = ",ACCESS_AUTH"
+$!
+$!	Include-paths can be added here as a comma separated
+$!	list with a lead comma, e.g., ",foo".
+$!
+$ extra_incs = ""
+$!
+$ extra_libs = ""
 $!
 $!	If no TCP/IP agent is specified (as the first argument),
 $!	prompt for a number from the list.   Note that the agent
@@ -64,15 +74,50 @@
 $ if agent .eq. 6 .or. p1 .eqs. "TCPWARE" then transport = "TCPWARE"
 $ if agent .eq. 7 .or. p1 .eqs. "DECNET" then transport = "DECNET"
 $!
-$ if transport .eqs. "SOCKETSHR_TCP" then extra = extra + ",_DECC_V4_SOURCE"
-$ if transport .eqs. "TCPWARE" then extra = extra + ",UCX"
+$ if transport .eqs. "SOCKETSHR_TCP" then extra_defs = extra_defs + ",_DECC_V4_SOURCE"
+$ if transport .eqs. "TCPWARE" then extra_defs = extra_defs + ",UCX"
 $!
-$ if p2 .nes. ""
+$ if P2 .nes. ""
 $ then
-$   ssl_arg = "openssl"
-$   extra = extra + ",USE_SSL,USE_OPENSSL_INCL"
-$ else
-$   ssl_arg = ""
+$   count_parm = 0
+$ parse_p2:
+$   value_parm = f$element('count_parm, ",", "''p2'")
+$   if value_parm .nes. ","
+$   then
+$      if value_parm .eqs. "BZLIB"
+$      then
+$         write sys$output "** adding BZlib to build."
+$         extra_defs = extra_defs + ",USE_BZLIB"
+$         extra_incs = extra_incs + "," + BZLIB_INC
+$         extra_libs = extra_libs + "," + BZLIB_LIB + "libbz2/LIB"
+$      endif
+$      if value_parm .eqs. "SLANG"
+$      then
+$         write sys$output "** adding SLang to build."
+$         extra_defs = extra_defs + ",USE_SLANG"
+$         extra_incs = extra_incs + "," + SLANG_INC
+$         extra_libs = extra_libs + "," + SLANG_LIB + "slang.olb/lib"
+$      endif
+$      if value_parm .eqs. "SSL"
+$      then
+$         write sys$output "** adding SSL to build."
+$         extra_defs = extra_defs + ",USE_SSL,USE_OPENSSL_INCL"
+$         extra_libs = extra_libs + "," + SSL_LIB + "libssl/LIB," + SSL_LIB + "libcrypto/LIB"
+$!
+$!	The "#include <openssl/ssl.h>" requires a logical variable "openssl".
+$!
+$         define/nolog openssl 'SSL_INC
+$      endif
+$      if value_parm .eqs. "ZLIB"
+$      then
+$         write sys$output "** adding Zlib to build."
+$         extra_defs = extra_defs + ",USE_ZLIB"
+$         extra_incs = extra_incs + "," + ZLIB_INC
+$         extra_libs = extra_libs + "," + ZLIB_LIB + "libz/LIB"
+$      endif
+$      count_parm = count_parm + 1
+$      goto parse_p2
+$   endif
 $ endif
 $!
 $!	Compiler options can be specified here.  If there was
@@ -82,76 +127,43 @@
 $ cc_opts = ""
 $ if p3 .nes. "" then cc_opts = cc_opts + "/DEBUG/NOOPT"
 $!
-$ IF f$trnlnm("VAXCMSG") .eqs. "DECC$MSG" .or. -
+$ all_defs = transport + extra_defs
+$ all_incs = "[-.Implementation],[---.src],[---.src.chrtrans],[---]" + extra_incs
+$!
+$ IF f$getsyi("ARCH_NAME") .eqs. "Alpha" .or. -
+     f$getsyi("ARCH_NAME") .eqs. "IA64" .or. -
+     f$trnlnm("VAXCMSG") .eqs. "DECC$MSG" .or. -
      f$trnlnm("DECC$CC_DEFAULT") .eqs. "/DECC" .or. -
      f$trnlnm("DECC$CC_DEFAULT") .eqs. "/VAXC"
 $ THEN
-$  v1 = f$verify(1)
 $! DECC:
-$  v1 = 'f$verify(0)'
 $  If transport .eqs. "UCX" .or. transport .eqs. "TCPWARE"
 $  Then
-$  v1 = f$verify(1)
-$!
-$ cc/decc/prefix=all /nomember 'cc_opts'-
-    /warning=(disable=implicitfunc)-
-    /DEFINE=(ACCESS_AUTH,'transport''extra',VC="""2.14""")-
-    /INCLUDE=([-.Implementation],[---.src],[---.src.chrtrans],[---]) -
-    [-.Implementation]HTString.c
-$!
-$ cc := cc/decc/prefix=all /nomember 'cc_opts'-
+$    cc := cc/decc/prefix=all /nomember 'cc_opts'-
 	  /warning=(disable=implicitfunc)-
-	  /DEFINE=(ACCESS_AUTH,'transport''extra')-
-	  /INCLUDE=([-.Implementation],[---.src],[---.src.chrtrans],[---])
-$!
-$  v1 = 'f$verify(0)'
+	  /DEFINE=('all_defs) -
+	  /INCLUDE=('all_incs)
 $  Else
-$  if transport .eqs. "MULTINET" then -
-	extra = extra + ",_DECC_V4_SOURCE,__SOCKET_TYPEDEFS"
-$  v1 = f$verify(1)
-$!
-$ cc/decc/prefix=all /nomember 'cc_opts'-
-    /warning=(disable=implicitfunc)-
-    /DEFINE=(ACCESS_AUTH,'transport''extra',VC="""2.14""")-
-    /INCLUDE=([-.Implementation],[---.src],[---.src.chrtrans],[---]) -
-    [-.Implementation]HTString.c
-$!
-$ cc := cc/decc/prefix=all /nomember 'cc_opts'-
+$    if transport .eqs. "MULTINET" then -
+	extra_defs = extra_defs + ",_DECC_V4_SOURCE,__SOCKET_TYPEDEFS"
+$    cc := cc/decc/prefix=all /nomember 'cc_opts'-
 	  /warning=(disable=implicitfunc)-
-	  /DEFINE=(ACCESS_AUTH,'transport''extra')-
-	  /INCLUDE=([-.Implementation],[---.src],[---.src.chrtrans],[---])
-$!
-$  v1 = 'f$verify(0)'
+	  /DEFINE=('all_defs) -
+	  /INCLUDE=('all_incs)
 $  EndIf
 $ ELSE
 $  IF f$search("gnu_cc:[000000]gcclib.olb") .nes. ""
 $  THEN
-$   v1 = f$verify(1)
 $! GNUC:
-$!
-$   gcc/DEFINE=(ACCESS_AUTH,'transport''extra',VC="""2.14""") 'cc_opts'-
-       /INCLUDE=([-.Implementation],[---.src],[---.src.chrtrans],[---]) -
-       [-.Implementation]HTString.c
-$!
-$   cc := gcc/DEFINE=(ACCESS_AUTH,'transport''extra') 'cc_opts'-
-	     /INCLUDE=([-.Implementation],[---.src],[---.src.chrtrans],[---])
-$!
-$   v1 = 'f$verify(0)'
+$    cc := gcc/DEFINE=('all_defs) 'cc_opts' /INCLUDE=('all_incs)
 $  ELSE
-$   v1 = f$verify(1)
 $! VAXC:
-$!
-$   cc/DEFINE=(ACCESS_AUTH,'transport''extra',VC="""2.14""") 'cc_opts'-
-      /INCLUDE=([-.Implementation],[---.src],[---.src.chrtrans],[---]) -
-      [-.Implementation]HTString.c
-$!
-$   cc := cc/DEFINE=(ACCESS_AUTH,'transport''extra') 'cc_opts'-
-	    /INCLUDE=([-.Implementation],[---.src],[---.src.chrtrans],[---])
-$!
-$   v1 = 'f$verify(0)'
+$    cc := cc/DEFINE=('all_defs) 'cc_opts' /INCLUDE=('all_incs)
 $  ENDIF
 $ ENDIF
 $ v1 = f$verify(1)
+$ show sym cc
+$ cc [-.Implementation]HTString.c
 $ cc [-.Implementation]HTParse.c
 $ cc [-.Implementation]HTAccess.c
 $ cc [-.Implementation]HTTP.c
@@ -188,12 +200,13 @@
 $ cc [-.Implementation]HTVMS_WaisUI.c
 $ cc [-.Implementation]HTVMS_WaisProt.c
 $!
-$ If f$search("[-.Implementation]WWWLib_''transport'.olb") .eqs. "" Then -
-    LIBRARY/Create [-.Implementation]WWWLib_'transport'.olb
-$ LIBRARY/Replace [-.Implementation]WWWLib_'transport'.olb *.obj
+$ result = "[-.Implementation]WWWLib_''transport'.olb"
+$ If f$search("''result'") .eqs. "" Then -
+    LIBRARY/Create 'result
+$ LIBRARY/Replace 'result *.obj
 $ Delete/nolog/noconf *.obj;*
 $!
-$ v1 = 'f$verify(0)'
+$ v1 = f$verify(v0)
 $ CLEANUP:
 $    v1 = f$verify(v)
 $exit
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/HTFinger.h
+++ lynx-cur-2.8.6/WWW/Library/Implementation/HTFinger.h
@@ -1,7 +1,7 @@
 /* Finger protocol module for the WWW library */
 /* History:
-**      21 Apr 94       Andrew Brooks
-*/
+ *      21 Apr 94       Andrew Brooks
+ */
 
 #ifndef HTFINGER_H
 #define HTFINGER_H
@@ -9,16 +9,22 @@
 #include <HTAccess.h>
 #include <HTAnchor.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
 #ifdef GLOBALREF_IS_MACRO
-extern GLOBALREF (HTProtocol, HTFinger);
+    extern GLOBALREF (HTProtocol, HTFinger);
+
 #else
-GLOBALREF HTProtocol HTFinger;
-#endif /* GLOBALREF_IS_MACRO */
+    GLOBALREF HTProtocol HTFinger;
+#endif				/* GLOBALREF_IS_MACRO */
 
-extern int HTLoadFinger PARAMS((
-	CONST char *		arg,
-	HTParentAnchor *	anAnchor,
-	HTFormat		format_out,
-	HTStream *		stream));
+    extern int HTLoadFinger(const char *arg,
+			    HTParentAnchor *anAnchor,
+			    HTFormat format_out,
+			    HTStream *stream);
 
-#endif /* HTFINGER_H */
+#ifdef __cplusplus
+}
+#endif
+#endif				/* HTFINGER_H */
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/HTFinger.c
+++ lynx-cur-2.8.6/WWW/Library/Implementation/HTFinger.c
@@ -1,29 +1,29 @@
 /*			FINGER ACCESS				HTFinger.c
-**			=============
-** Authors:
-**  ARB  Andrew Brooks
-**
-** History:
-**	21 Apr 94   First version (ARB, from HTNews.c by TBL)
-**	12 Mar 96   Made the URL and command buffering secure from
-**		     stack modifications, beautified the HTLoadFinger()
-**		     and response() functions, and added support for the
-**		     following URL formats for sending a "", "/w",
-**		     "username[@host]", or "/w username[@host]" command
-**		     to the server:
-**			finger://host
-**			finger://host/
-**			finger://host/%2fw
-**			finger://host/%2fw%20username[@host]
-**			finger://host/w/username[@host]
-**			finger://host/username[@host]
-**			finger://host/username[@host]/w
-**			finger://username@host
-**			finger://username@host/
-**			finger://username@host/w
-**	15 Mar 96   Added support for port 79 gtype 0 gopher URLs
-**		     relayed from HTLoadGopher. - FM
-*/
+ *			=============
+ * Authors:
+ *  ARB  Andrew Brooks
+ *
+ * History:
+ *	21 Apr 94   First version (ARB, from HTNews.c by TBL)
+ *	12 Mar 96   Made the URL and command buffering secure from
+ *		     stack modifications, beautified the HTLoadFinger()
+ *		     and response() functions, and added support for the
+ *		     following URL formats for sending a "", "/w",
+ *		     "username[@host]", or "/w username[@host]" command
+ *		     to the server:
+ *			finger://host
+ *			finger://host/
+ *			finger://host/%2fw
+ *			finger://host/%2fw%20username[@host]
+ *			finger://host/w/username[@host]
+ *			finger://host/username[@host]
+ *			finger://host/username[@host]/w
+ *			finger://username@host
+ *			finger://username@host/
+ *			finger://username@host/w
+ *	15 Mar 96   Added support for port 79 gtype 0 gopher URLs
+ *		     relayed from HTLoadGopher. - FM
+ */
 
 #include <HTUtils.h>
 
@@ -50,101 +50,97 @@
 #define FREE_TARGET (*targetClass._free)(target)
 #define NEXT_CHAR HTGetCharacter()
 
-
 /*	Module-wide variables
 */
-PRIVATE int finger_fd;				/* Socket for FingerHost */
+static int finger_fd;		/* Socket for FingerHost */
 
 struct _HTStructured {
-	CONST HTStructuredClass * isa;		/* For gopher streams */
-	/* ... */
+    const HTStructuredClass *isa;	/* For gopher streams */
+    /* ... */
 };
 
-PRIVATE HTStructured * target;			/* The output sink */
-PRIVATE HTStructuredClass targetClass;		/* Copy of fn addresses */
+static HTStructured *target;	/* The output sink */
+static HTStructuredClass targetClass;	/* Copy of fn addresses */
 
 /*	Initialisation for this module
-**	------------------------------
-*/
-PRIVATE BOOL initialized = NO;
-PRIVATE BOOL initialize NOARGS
+ *	------------------------------
+ */
+static BOOL initialized = NO;
+static BOOL initialize(void)
 {
-  finger_fd = -1;		/* Disconnected */
-  return YES;
+    finger_fd = -1;		/* Disconnected */
+    return YES;
 }
 
-
-
 /*	Start anchor element
-**	--------------------
-*/
-PRIVATE void start_anchor ARGS1(CONST char *,  href)
+ *	--------------------
+ */
+static void start_anchor(const char *href)
 {
-    BOOL		present[HTML_A_ATTRIBUTES];
-    CONST char*		value[HTML_A_ATTRIBUTES];
+    BOOL present[HTML_A_ATTRIBUTES];
+    const char *value[HTML_A_ATTRIBUTES];
 
     {
 	int i;
-	for(i=0; i<HTML_A_ATTRIBUTES; i++)
-	    present[i] = (BOOL) (i==HTML_A_HREF);
+
+	for (i = 0; i < HTML_A_ATTRIBUTES; i++)
+	    present[i] = (BOOL) (i == HTML_A_HREF);
     }
-    ((CONST char **)value)[HTML_A_HREF] = href;
-    (*targetClass.start_element)(target, HTML_A, present,
-				 (CONST char **)value, -1, 0);
+    ((const char **) value)[HTML_A_HREF] = href;
+    (*targetClass.start_element) (target, HTML_A, present,
+				  (const char **) value, -1, 0);
 
 }
 
 /*	Send Finger Command line to remote host & Check Response
-**	--------------------------------------------------------
-**
-** On entry,
-**	command	points to the command to be sent, including CRLF, or is null
-**		pointer if no command to be sent.
-** On exit,
-**	Negative status indicates transmission error, socket closed.
-**	Positive status is a Finger status.
-*/
-
-
-PRIVATE int response ARGS5(
-	char *,			command,
-	char *,			sitename,
-	HTParentAnchor *,	anAnchor,
-	HTFormat,		format_out,
-	HTStream*,		sink)
+ *	--------------------------------------------------------
+ *
+ * On entry,
+ *	command	points to the command to be sent, including CRLF, or is null
+ *		pointer if no command to be sent.
+ * On exit,
+ *	Negative status indicates transmission error, socket closed.
+ *	Positive status is a Finger status.
+ */
+
+static int response(char *command,
+		    char *sitename,
+		    HTParentAnchor *anAnchor,
+		    HTFormat format_out,
+		    HTStream *sink)
 {
     int status;
     int length = strlen(command);
     int ch, i;
-    char line[BIG], *l, *cmd=NULL;
-    char *p = line, *href=NULL;
+    char line[BIG], *l, *cmd = NULL;
+    char *p = line, *href = NULL;
 
     if (length == 0)
-	return(-1);
+	return (-1);
 
     /* Set up buffering.
-    */
+     */
     HTInitInput(finger_fd);
 
     /* Send the command.
-    */
+     */
     CTRACE((tfp, "HTFinger command to be sent: %s", command));
-    status = NETWRITE(finger_fd, (char *)command, length);
+    status = NETWRITE(finger_fd, (char *) command, length);
     if (status < 0) {
 	CTRACE((tfp, "HTFinger: Unable to send command. Disconnecting.\n"));
 	NETCLOSE(finger_fd);
 	finger_fd = -1;
 	return status;
-    } /* if bad status */
-
+    }
+    /* if bad status */
     /* Make a hypertext object with an anchor list.
-    */
+     */
     target = HTML_new(anAnchor, format_out, sink);
     targetClass = *target->isa;	/* Copy routine entry points */
 
     /* Create the results report.
-    */
-    CTRACE((tfp,"HTFinger: Reading finger information\n"));
+     */
+    CTRACE((tfp, "HTFinger: Reading finger information\n"));
     START(HTML_HTML);
     PUTC('\n');
     START(HTML_HEAD);
@@ -182,17 +178,18 @@
     PUTC('\n');
     START(HTML_PRE);
 
-    while ((ch=NEXT_CHAR) != EOF) {
+    while ((ch = NEXT_CHAR) != EOF) {
 
 	if (interrupted_in_htgetcharacter) {
-	    CTRACE((tfp, "HTFinger: Interrupted in HTGetCharacter, apparently.\n"));
-	    _HTProgress (CONNECTION_INTERRUPTED);
+	    CTRACE((tfp,
+		    "HTFinger: Interrupted in HTGetCharacter, apparently.\n"));
+	    _HTProgress(CONNECTION_INTERRUPTED);
 	    goto end_html;
 	}
 
 	if (ch != LF) {
-	    *p = (char) ch;      /* Put character in line */
-	    if (p < &line[BIG-1]) {
+	    *p = (char) ch;	/* Put character in line */
+	    if (p < &line[BIG - 1]) {
 		p++;
 	    }
 	} else {
@@ -235,7 +232,7 @@
     NETCLOSE(finger_fd);
     finger_fd = -1;
 
-end_html:
+  end_html:
     END(HTML_PRE);
     PUTC('\n');
     END(HTML_BODY);
@@ -243,48 +240,46 @@
     END(HTML_HTML);
     PUTC('\n');
     FREE_TARGET;
-    return(0);
+    return (0);
 }
 
-
 /*		Load by name					HTLoadFinger
-**		============
-*/
-PUBLIC int HTLoadFinger ARGS4(
-	CONST char *,		arg,
-	HTParentAnchor *,	anAnchor,
-	HTFormat,		format_out,
-	HTStream*,		stream)
+ *		============
+ */
+int HTLoadFinger(const char *arg,
+		 HTParentAnchor *anAnchor,
+		 HTFormat format_out,
+		 HTStream *stream)
 {
     char *username, *sitename, *colon;	/* Fields extracted from URL */
-    char *slash, *at_sign;		/* Fields extracted from URL */
+    char *slash, *at_sign;	/* Fields extracted from URL */
     char *command, *str, *param;	/* Buffers */
-    int port;				/* Port number from URL */
-    int status;				/* tcp return */
+    int port;			/* Port number from URL */
+    int status;			/* tcp return */
     int result = HT_LOADED;
     BOOL IsGopherURL = FALSE;
-    CONST char * p1 = arg;
+    const char *p1 = arg;
 
     CTRACE((tfp, "HTFinger: Looking for %s\n", (arg ? arg : "NULL")));
 
     if (!(arg && *arg)) {
 	HTAlert(COULD_NOT_LOAD_DATA);
-	return HT_NOT_LOADED;			/* Ignore if no name */
+	return HT_NOT_LOADED;	/* Ignore if no name */
     }
 
     if (!initialized)
 	initialized = initialize();
     if (!initialized) {
-	HTAlert (gettext("Could not set up finger connection."));
+	HTAlert(gettext("Could not set up finger connection."));
 	return HT_NOT_LOADED;	/* FAIL */
     }
 
     /*  Set up the host and command fields.
-    */
+     */
     if (!strncasecomp(arg, "finger://", 9)) {
-	p1 = arg + 9;  /* Skip "finger://" prefix */
+	p1 = arg + 9;		/* Skip "finger://" prefix */
     } else if (!strncasecomp(arg, "gopher://", 9)) {
-	p1 = arg + 9;  /* Skip "gopher://" prefix */
+	p1 = arg + 9;		/* Skip "gopher://" prefix */
 	IsGopherURL = TRUE;
     }
 
@@ -323,7 +318,7 @@
 
     if (*sitename == '\0') {
 	HTAlert(gettext("Could not load data (no sitename in finger URL)"));
-	result = HT_NOT_LOADED;		/* Ignore if no name */
+	result = HT_NOT_LOADED;	/* Ignore if no name */
     } else if ((colon = strchr(sitename, ':')) != NULL) {
 	*colon++ = '\0';
 	port = atoi(colon);
@@ -335,12 +330,12 @@
 
     if (result == HT_LOADED) {
 	/* Load the string for making a connection/
-	*/
+	 */
 	str = 0;
 	HTSprintf0(&str, "lose://%s/", sitename);
 
 	/* Load the command for the finger server.
-	*/
+	 */
 	command = 0;
 	if (at_sign && slash) {
 	    if (*slash == 'w' || *slash == 'W') {
@@ -351,20 +346,20 @@
 	} else if (at_sign) {
 	    HTSprintf0(&command, "%s%c%c", username, CR, LF);
 	} else if (*username == '/') {
-	    if ((slash = strchr((username+1), '/')) != NULL) {
+	    if ((slash = strchr((username + 1), '/')) != NULL) {
 		*slash = ' ';
 	    }
 	    HTSprintf0(&command, "%s%c%c", username, CR, LF);
 	} else if ((*username == 'w' || *username == 'W') &&
-		   *(username+1) == '/') {
-	    if (*username+2 != '\0') {
-		*(username+1) = ' ';
+		   *(username + 1) == '/') {
+	    if (*username + 2 != '\0') {
+		*(username + 1) = ' ';
 	    } else {
-		*(username+1) = '\0';
+		*(username + 1) = '\0';
 	    }
 	    HTSprintf0(&command, "/%s%c%c", username, CR, LF);
 	} else if ((*username == 'w' || *username == 'W') &&
-		   *(username+1) == '\0') {
+		   *(username + 1) == '\0') {
 	    HTSprintf0(&command, "/%s%c%c", username, CR, LF);
 	} else if ((slash = strchr(username, '/')) != NULL) {
 	    *slash++ = '\0';
@@ -378,16 +373,17 @@
 	}
 
 	/* Now, let's get a stream setup up from the FingerHost:
-	** CONNECTING to finger host
-	*/
+	 * CONNECTING to finger host
+	 */
 	CTRACE((tfp, "HTFinger: doing HTDoConnect on '%s'\n", str));
 	status = HTDoConnect(str, "finger", FINGER_PORT, &finger_fd);
 	CTRACE((tfp, "HTFinger: Done DoConnect; status %d\n", status));
 
 	if (status == HT_INTERRUPTED) {
 	    /* Interrupt cleanly */
-	    CTRACE((tfp, "HTFinger: Interrupted on connect; recovering cleanly.\n"));
-	    HTProgress (CONNECTION_INTERRUPTED);
+	    CTRACE((tfp,
+		    "HTFinger: Interrupted on connect; recovering cleanly.\n"));
+	    HTProgress(CONNECTION_INTERRUPTED);
 	    result = HT_NOT_LOADED;
 	} else if (status < 0) {
 	    NETCLOSE(finger_fd);
@@ -399,7 +395,7 @@
 	    CTRACE((tfp, "HTFinger: Connected to finger host '%s'.\n", str));
 
 	    /* Send the command, and process response if successful.
-	    */
+	     */
 	    if (response(command, sitename, anAnchor, format_out, stream) != 0) {
 		HTAlert(gettext("No response from finger server."));
 		result = HT_NOT_LOADED;
@@ -414,9 +410,10 @@
 
 #ifdef GLOBALDEF_IS_MACRO
 #define _HTFINGER_C_1_INIT { "finger", HTLoadFinger, NULL }
-GLOBALDEF (HTProtocol, HTFinger, _HTFINGER_C_1_INIT);
+GLOBALDEF(HTProtocol, HTFinger, _HTFINGER_C_1_INIT);
 #else
-GLOBALDEF PUBLIC HTProtocol HTFinger = { "finger", HTLoadFinger, NULL };
+GLOBALDEF HTProtocol HTFinger =
+{"finger", HTLoadFinger, NULL};
 #endif /* GLOBALDEF_IS_MACRO */
 
 #endif /* not DISABLE_FINGER */
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/LYexit.h
+++ lynx-cur-2.8.6/WWW/Library/Implementation/LYexit.h
@@ -19,40 +19,41 @@
 /*
  *	Required includes
  */
+#ifdef _WINDOWS
+#include <process.h>		/* declares exit() */
+#endif
 
 #ifndef HTUTILS_H
 #include <HTUtils.h>
 #endif
 
+#ifdef __cplusplus
+extern "C" {
+#endif
 /*
  *	Constant defines
  */
 #ifdef exit
 #undef exit
-#endif /* _WINDOWS */
-
+#endif
 #define exit(code) LYexit(code)
-
 #define atexit LYatexit
 #define ATEXITSIZE 50
-
 /*
  *	Data structures
- */
+ *//*
+   * Global variable declarations
+ *//*
+   * Macros
+ *//*
+   * Function declarations
+ */ extern void outofmem(const char *fname, const char *func);
+    extern void reset_signals(void);
+    extern void exit_immediately(int status) GCC_NORETURN;
+    extern void LYexit(int status) GCC_NORETURN;
+    extern int LYatexit(void (*function) (void));
 
-/*
- *	Global variable declarations
- */
-
-/*
- *	Macros
- */
-
-/*
- *	Function declarations
- */
-extern void exit_immediately PARAMS((int status)) GCC_NORETURN;
-extern void LYexit PARAMS((int status)) GCC_NORETURN;
-extern int LYatexit PARAMS((void (*function)(void)));
-
-#endif /* __LYEXIT_H */
+#ifdef __cplusplus
+}
+#endif
+#endif				/* __LYEXIT_H */
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/HTVMS_WaisUI.h
+++ lynx-cur-2.8.6/WWW/Library/Implementation/HTVMS_WaisUI.h
@@ -1,9 +1,9 @@
 /*							HTVMS_WAISUI.h
-**
-**	Adaptation for Lynx by F.Macrides (macrides@sci.wfeb.edu)
-**
-**	31-May-1994 FM	Initial version.
-*/
+ *
+ *	Adaptation for Lynx by F.Macrides (macrides@sci.wfeb.edu)
+ *
+ *	31-May-1994 FM	Initial version.
+ */
 
 #ifndef HTVMSWAIS_H
 #define HTVMSWAIS_H
@@ -12,56 +12,58 @@
 #include <HTUtils.h>
 #endif
 
-void	log_write PARAMS((char *));
+#ifdef __cplusplus
+extern "C" {
+#endif
+    void log_write(char *);
 
 /*
-**	Routines originally from Panic.h -- FM
-**
-**----------------------------------------------------------------------*/
+ *	Routines originally from Panic.h -- FM
+ *
+ *----------------------------------------------------------------------*/
 
-void	panic (char* format,...);
+    void panic(char *format,...);
 
 /*----------------------------------------------------------------------*/
 
-
 /*
-**	Routines originally from CUtil.h -- FM
-**
-**----------------------------------------------------------------------*/
+ *	Routines originally from CUtil.h -- FM
+ *
+ *----------------------------------------------------------------------*/
 
 /* types and constants */
 
 #ifndef boolean
 #define boolean unsigned long
-#endif /* boolean */
+#endif				/* boolean */
 
 #ifndef true
 #define true	(boolean)1L
-#endif /* true */
+#endif				/* true */
 
 #ifndef false
-#define false	(boolean)0L   /* used to be (!true), but broke
-				 some compilers */
-#endif /* false */
+#define false	(boolean)0L	/* used to be (!true), but broke
+				   some compilers */
+#endif				/* false */
 
 #ifndef TRUE
 #define TRUE	true
-#endif /* TRUE */
+#endif				/* TRUE */
 
 #ifndef FALSE
 #define FALSE	false
-#endif /* FALSE */
+#endif				/* FALSE */
 
 /*----------------------------------------------------------------------*/
 /* functions */
 
 /* enhanced memory handling functions - don't call them directly, use the
    macros below */
-void	fs_checkPtr PARAMS((void* ptr));
-void*	fs_malloc PARAMS((size_t size));
-void*	fs_realloc PARAMS((void* ptr,size_t size));
-void	fs_free PARAMS((void* ptr));
-char*	fs_strncat PARAMS((char* dst,char* src,size_t maxToAdd,size_t maxTotal));
+    void fs_checkPtr(void *ptr);
+    void *fs_malloc(size_t size);
+    void *fs_realloc(void *ptr, size_t size);
+    void fs_free(void *ptr);
+    char *fs_strncat(char *dst, char *src, size_t maxToAdd, size_t maxTotal);
 
 /* macros for memory functions.  call these in your program.  */
 #define s_checkPtr(ptr)		fs_checkPtr(ptr)
@@ -70,29 +72,27 @@
 #define s_free(ptr)		{ fs_free((char*)ptr); ptr = NULL; }
 #define s_strncat(dst,src,maxToAdd,maxTotal)	fs_strncat((dst),(src),(maxToAdd),(maxTotal))
 
-char*	s_strdup PARAMS((char* s));
+    char *s_strdup(char *s);
 
 #define IS_DELIMITER	1
 #define	NOT_DELIMITER	!IS_DELIMITER
 
-char char_downcase PARAMS((unsigned long ch));
-char *string_downcase PARAMS((char* word));
+    char char_downcase(unsigned long ch);
+    char *string_downcase(char *word);
 
 /*----------------------------------------------------------------------*/
 
-
-
 /*
-**	Routines originally from ZUtil.c -- FM
-**
-**----------------------------------------------------------------------*/
+ *	Routines originally from ZUtil.c -- FM
+ *
+ *----------------------------------------------------------------------*/
 
 /* Data types / constants */
 
 /* bytes to leave for the header size info */
 #define HEADER_LEN	(size_t)2
 
-typedef long pdu_type;
+    typedef long pdu_type;
 
 #define	initAPDU			(pdu_type)20
 #define	initResponseAPDU		(pdu_type)21
@@ -107,14 +107,14 @@
 #define	resourceControlAPDU		(pdu_type)30
 #define	resourceControlResponseAPDU	(pdu_type)31
 
-typedef struct any {	/* an any is a non-ascii string of characters */
-	unsigned long	size;
-	char*			bytes;
-	} any;
+    typedef struct any {	/* an any is a non-ascii string of characters */
+	unsigned long size;
+	char *bytes;
+    } any;
 
-typedef any	bit_map;	/* a bit_map is a group of packed bits */
+    typedef any bit_map;	/* a bit_map is a group of packed bits */
 
-typedef unsigned long data_tag;
+    typedef unsigned long data_tag;
 
 #define DT_PDUType			(data_tag)1
 #define	DT_ReferenceID			(data_tag)2
@@ -165,14 +165,14 @@
 /* number of bytes required to represent the following sizes in compressed
    integer format
  */
-#define CompressedInt1Byte	128		/* 2 ^ 7 */
-#define CompressedInt2Byte	16384		/* 2 ^ 14 */
+#define CompressedInt1Byte	128	/* 2 ^ 7 */
+#define CompressedInt2Byte	16384	/* 2 ^ 14 */
 #define CompressedInt3Byte	2097152		/* 2 ^ 21 */
 /* others may follow ... */
 
 /* types of query */
-#define QT_0	"0"	/* query whose non-standard format has been agreed upon
-			   client and server */
+#define QT_0	"0"		/* query whose non-standard format has been agreed upon
+				   client and server */
 /* values for InitAPDU option element */
 #define	WILL_USE		TRUE
 #define WILL_NOT_USE		FALSE
@@ -184,7 +184,7 @@
 #define REJECT	FALSE
 
 /* values for SearchResponseAPDU search status element */
-#define	SUCCESS	0 /* intuitive huh? */
+#define	SUCCESS	0		/* intuitive huh? */
 #define FAILURE	1
 
 /* values for SearchResponseAPDU result set status element */
@@ -198,16 +198,16 @@
 #define PARTIAL_2	2
 #define PARTIAL_3	3
 #define PARTIAL_4	4
-#define PS_NONE		5 /* can't use NONE since it was used by result
-			     set status */
+#define PS_NONE		5	/* can't use NONE since it was used by result
+				   set status */
 
 #define DIAGNOSTIC_CODE_SIZE	(size_t)3
 
-typedef struct diagnosticRecord
- { boolean	SURROGATE;
-   char		DIAG[DIAGNOSTIC_CODE_SIZE];
-   char*	ADDINFO;
- } diagnosticRecord;
+    typedef struct diagnosticRecord {
+	boolean SURROGATE;
+	char DIAG[DIAGNOSTIC_CODE_SIZE];
+	char *ADDINFO;
+    } diagnosticRecord;
 
 #define D_PermanentSystemError	       "S1"
 #define D_TemporarySystemError         "S2"
@@ -251,7 +251,7 @@
 
 /* for internal error handling */
 
-extern char* readErrorPosition;		/* pos where buf stoped making sense */
+    extern char *readErrorPosition;	/* pos where buf stoped making sense */
 
 /* the following are macros so that they can return OUT of the function
    which calls them
@@ -259,7 +259,7 @@
 
 #define RETURN_ON_NULL(var)					\
 	if (var == NULL)					\
-	  return(NULL); /* jump out of caller */
+	  return(NULL);		/* jump out of caller */
 
 #define REPORT_READ_ERROR(pos)					\
 	{ readErrorPosition = (pos);				\
@@ -277,79 +277,78 @@
 
 /*----------------------------------------------------------------------*/
 
-diagnosticRecord* makeDiag PARAMS((boolean surrogate,char* code,char* addInfo));
-void freeDiag PARAMS((diagnosticRecord* diag));
-char* writeDiag PARAMS((diagnosticRecord* diag,char* buffer,long* len));
-char* readDiag PARAMS((diagnosticRecord** diag,char* buffer));
-
-char* writeCompressedInteger PARAMS((unsigned long num,char* buf,long* len));
-char* readCompressedInteger PARAMS((unsigned long *num,char* buf));
-char* writeCompressedIntWithPadding PARAMS((unsigned long num,unsigned long size,
-					 char* buffer,long* len));
-unsigned long writtenCompressedIntSize PARAMS((unsigned long num));
-
-char* writeTag PARAMS((data_tag tag,char* buf,long* len));
-char* readTag PARAMS((data_tag* tag,char* buf));
-data_tag peekTag PARAMS((char* buf));
-unsigned long writtenTagSize PARAMS((data_tag tag));
-
-any* makeAny PARAMS((unsigned long size,char* data));
-void freeAny PARAMS((any* a));
-any* duplicateAny PARAMS((any* a));
-char* writeAny PARAMS((any* a,data_tag tag,char* buffer,long* len));
-char* readAny PARAMS((any** anAny,char* buffer));
-unsigned long writtenAnySize PARAMS((data_tag tag,any* a));
-
-any* stringToAny PARAMS((char* s));
-char* anyToString PARAMS((any* a));
-unsigned long writtenStringSize PARAMS((data_tag tag,char* s));
-
-any* longToAny PARAMS((long Num));
-long anyToLong PARAMS((any* a));
-
-char* writeString PARAMS((char* s,data_tag tag,char* buffer,long* len));
-char* readString PARAMS((char** s,char* buffer));
-
-bit_map* makeBitMap (unsigned long numBits,...);
-
-void freeBitMap PARAMS((bit_map* bm));
-boolean bitAtPos PARAMS((unsigned long pos,bit_map* bm));
-char* writeBitMap PARAMS((bit_map* bm,data_tag tag,char* buffer,long* len));
-char* readBitMap PARAMS((bit_map** bm,char* buffer));
-
-char* writeByte PARAMS((unsigned long byte,char* buf,long* len));
-char* readByte PARAMS((unsigned char* byte,char* buf));
-
-char* writeBoolean PARAMS((boolean flag,char* buf,long* len));
-char* readBoolean PARAMS((boolean* flag,char* buf));
-
-char* writePDUType PARAMS((pdu_type pduType,char* buf,long* len));
-char* readPDUType PARAMS((pdu_type* pduType,char* buf));
-pdu_type peekPDUType PARAMS((char* buf));
-
-char* writeBinaryInteger PARAMS((long num,unsigned long size,
-			      char* buf,long* len));
-char* readBinaryInteger PARAMS((long* num,unsigned long size,char* buf));
-unsigned long writtenCompressedBinIntSize PARAMS((long num));
-
-char* writeNum PARAMS((long num,data_tag tag,char* buffer,long* len));
-char* readNum PARAMS((long* num,char* buffer));
-unsigned long  writtenNumSize PARAMS((data_tag tag,long num));
-
-void doList PARAMS((void** list,void (*func)(void *)));
-
-char* writeProtocolVersion PARAMS((char* buf,long* len));
-char* defaultImplementationID PARAMS((void));
-char* defaultImplementationName PARAMS((void));
-char* defaultImplementationVersion PARAMS((void));
+    diagnosticRecord *makeDiag(boolean surrogate, char *code, char *addInfo);
+    void freeDiag(diagnosticRecord * diag);
+    char *writeDiag(diagnosticRecord * diag, char *buffer, long *len);
+    char *readDiag(diagnosticRecord ** diag, char *buffer);
+
+    char *writeCompressedInteger(unsigned long num, char *buf, long *len);
+    char *readCompressedInteger(unsigned long *num, char *buf);
+    char *writeCompressedIntWithPadding(unsigned long num, unsigned long size,
+					char *buffer, long *len);
+    unsigned long writtenCompressedIntSize(unsigned long num);
+
+    char *writeTag(data_tag tag, char *buf, long *len);
+    char *readTag(data_tag *tag, char *buf);
+    data_tag peekTag(char *buf);
+    unsigned long writtenTagSize(data_tag tag);
+
+    any *makeAny(unsigned long size, char *data);
+    void freeAny(any *a);
+    any *duplicateAny(any *a);
+    char *writeAny(any *a, data_tag tag, char *buffer, long *len);
+    char *readAny(any **anAny, char *buffer);
+    unsigned long writtenAnySize(data_tag tag, any *a);
+
+    any *stringToAny(char *s);
+    char *anyToString(any *a);
+    unsigned long writtenStringSize(data_tag tag, char *s);
+
+    any *longToAny(long Num);
+    long anyToLong(any *a);
+
+    char *writeString(char *s, data_tag tag, char *buffer, long *len);
+    char *readString(char **s, char *buffer);
+
+    bit_map *makeBitMap(unsigned long numBits,...);
+
+    void freeBitMap(bit_map *bm);
+    boolean bitAtPos(unsigned long pos, bit_map *bm);
+    char *writeBitMap(bit_map *bm, data_tag tag, char *buffer, long *len);
+    char *readBitMap(bit_map **bm, char *buffer);
+
+    char *writeByte(unsigned long byte, char *buf, long *len);
+    char *readByte(unsigned char *byte, char *buf);
+
+    char *writeBoolean(boolean flag, char *buf, long *len);
+    char *readBoolean(boolean *flag, char *buf);
+
+    char *writePDUType(pdu_type pduType, char *buf, long *len);
+    char *readPDUType(pdu_type *pduType, char *buf);
+    pdu_type peekPDUType(char *buf);
+
+    char *writeBinaryInteger(long num, unsigned long size,
+			     char *buf, long *len);
+    char *readBinaryInteger(long *num, unsigned long size, char *buf);
+    unsigned long writtenCompressedBinIntSize(long num);
+
+    char *writeNum(long num, data_tag tag, char *buffer, long *len);
+    char *readNum(long *num, char *buffer);
+    unsigned long writtenNumSize(data_tag tag, long num);
+
+    void doList(void **list, void (*func) (void *));
+
+    char *writeProtocolVersion(char *buf, long *len);
+    char *defaultImplementationID(void);
+    char *defaultImplementationName(void);
+    char *defaultImplementationVersion(void);
 
 /*----------------------------------------------------------------------*/
 
-
 /*
-**	Routines originally from ZType1.c -- FM
-**
-**----------------------------------------------------------------------*/
+ *	Routines originally from ZType1.c -- FM
+ *
+ *----------------------------------------------------------------------*/
 
 /* This file implements the type 1 query defined in appendices B & C
    of the SR 1 spec.
@@ -363,65 +362,65 @@
 #define DT_Term			(data_tag)45
 #define DT_Operator		(data_tag)46
 
-#define QT_BooleanQuery	"1"		/* standard boolean query */
+#define QT_BooleanQuery	"1"	/* standard boolean query */
 
 /* general attribute code - use in place of any attribute */
-#define IGNORE	"ig"
+#define IGNORE			"ig"
 
 /* use value codes */
-#define	UV_ISBN	"ub"
-#define	CORPORATE_NAME	"uc"
-#define	ISSN	"us"
-#define	PERSONAL_NAME	"up"
-#define	SUBJECT	"uj"
-#define	TITLE	"ut"
-#define	GEOGRAPHIC_NAME	"ug"
-#define	CODEN	"ud"
+#define	UV_ISBN			"ub"
+#define	CORPORATE_NAME		"uc"
+#define	ISSN			"us"
+#define	PERSONAL_NAME		"up"
+#define	SUBJECT			"uj"
+#define	TITLE			"ut"
+#define	GEOGRAPHIC_NAME		"ug"
+#define	CODEN			"ud"
 #define	SUBJECT_SUBDIVISION	"ue"
-#define	SERIES_TITLE	"uf"
+#define	SERIES_TITLE		"uf"
 #define	MICROFORM_GENERATION	"uh"
 #define	PLACE_OF_PUBLICATION	"ui"
-#define	NUC_CODE	"uk"
-#define	LANGUAGE	"ul"
+#define	NUC_CODE		"uk"
+#define	LANGUAGE		"ul"
 #define	COMBINATION_OF_USE_VALUES	"um"
 #define	SYSTEM_CONTROL_NUMBER	"un"
-#define	DATE	"uo"
+#define	DATE			"uo"
 #define	LC_CONTROL_NUMBER	"ur"
 #define	MUSIC_PUBLISHERS_NUMBER	"uu"
 #define	GOVERNMENT_DOCUMENTS_NUMBER	"uv"
 #define	SUBJECT_CLASSIFICATION	"uw"
-#define	RECORD_TYPE	"uy"
+#define	RECORD_TYPE		"uy"
 
 /* relation value codes */
-#define	EQUAL	"re"
-#define	GREATER_THAN	"rg"
+#define	EQUAL			"re"
+#define	GREATER_THAN		"rg"
 #define	GREATER_THAN_OR_EQUAL	"ro"
-#define	LESS_THAN	"rl"
+#define	LESS_THAN		"rl"
 #define	LESS_THAN_OR_EQUAL	"rp"
-#define	NOT_EQUAL	"rn"
+#define	NOT_EQUAL		"rn"
 
 /* position value codes */
-#define	FIRST_IN_FIELD	"pf"
+#define	FIRST_IN_FIELD		"pf"
 #define	FIRST_IN_SUBFIELD	"ps"
 #define	FIRST_IN_A_SUBFIELD	"pa"
 #define	FIRST_IN_NOT_A_SUBFIELD	"pt"
 #define	ANY_POSITION_IN_FIELD	"py"
 
 /* structure value codes */
-#define	PHRASE	"sp"
-#define	WORD	"sw"
-#define	KEY	"sk"
-#define	WORD_LIST	"sl"
+#define	PHRASE			"sp"
+#define	WORD			"sw"
+#define	KEY			"sk"
+#define	WORD_LIST		"sl"
 
 /* truncation value codes */
-#define	NO_TRUNCATION	"tn"
+#define	NO_TRUNCATION		"tn"
 #define	RIGHT_TRUNCATION	"tr"
 #define	PROC_NUM_INCLUDED_IN_SEARCH_ARG	"ti"
 
 /* completeness value codes */
 #define	INCOMPLETE_SUBFIELD	"ci"
 #define	COMPLETE_SUBFIELD	"cs"
-#define	COMPLETEFIELD	"cf"
+#define	COMPLETEFIELD		"cf"
 
 /* operator codes */
 #define AND	"a"
@@ -431,224 +430,235 @@
 /* term types */
 #define TT_Attribute		1
 #define	TT_ResultSetID		2
-#define	TT_Operator			3
+#define	TT_Operator		3
 
 #define ATTRIBUTE_SIZE		3
 #define OPERATOR_SIZE		2
 
-typedef struct query_term {
-  /* type */
-  long	TermType;
-  /* for term */
-  char	Use[ATTRIBUTE_SIZE];
-  char	Relation[ATTRIBUTE_SIZE];
-  char	Position[ATTRIBUTE_SIZE];
-  char	Structure[ATTRIBUTE_SIZE];
-  char	Truncation[ATTRIBUTE_SIZE];
-  char	Completeness[ATTRIBUTE_SIZE];
-  any*	Term;
-  /* for result set */
-  any*	ResultSetID;
-  /* for operator */
-  char	Operator[OPERATOR_SIZE];
-} query_term;
+    typedef struct query_term {
+	/* type */
+	long TermType;
+	/* for term */
+	char Use[ATTRIBUTE_SIZE];
+	char Relation[ATTRIBUTE_SIZE];
+	char Position[ATTRIBUTE_SIZE];
+	char Structure[ATTRIBUTE_SIZE];
+	char Truncation[ATTRIBUTE_SIZE];
+	char Completeness[ATTRIBUTE_SIZE];
+	any *Term;
+	/* for result set */
+	any *ResultSetID;
+	/* for operator */
+	char Operator[OPERATOR_SIZE];
+    } query_term;
 
 /*----------------------------------------------------------------------*/
 /* functions */
 
-query_term* makeAttributeTerm PARAMS((
-        char* use,char* relation,char* position,char* structure,
-	char* truncation,char* completeness,any* term));
-query_term* makeResultSetTerm PARAMS((any* resultSet));
-query_term* makeOperatorTerm PARAMS((char* operatorCode));
-void freeTerm PARAMS((void* qt));
-char* writeQueryTerm PARAMS((query_term* qt,char* buffer,long* len));
-char* readQueryTerm PARAMS((query_term** qt,char* buffer));
-any* writeQuery PARAMS((query_term** terms));
-query_term** readQuery PARAMS((any* info));
+    query_term *makeAttributeTerm(char *use, char *relation, char *position, char *structure,
+				  char *truncation, char *completeness, any *term);
+    query_term *makeResultSetTerm(any *resultSet);
+    query_term *makeOperatorTerm(char *operatorCode);
+    void freeTerm(void *qt);
+    char *writeQueryTerm(query_term *qt, char *buffer, long *len);
+    char *readQueryTerm(query_term **qt, char *buffer);
+    any *writeQuery(query_term **terms);
+    query_term **readQuery(any *info);
 
 /*----------------------------------------------------------------------*/
 
-
 /*
-**	Routines originally from UI.c -- FM
-**
-**----------------------------------------------------------------------*/
-
-char *
-generate_retrieval_apdu PARAMS((char *buff,
-			     long *buff_len,
-			     any *docID,
-			     long chunk_type,
-			     long start_line, long end_line,
-			     char *type,
-			     char *database_name));
-
-
-long
-interpret_message PARAMS((char *request_message,
-		       long request_length,
-		       char *response_message,
-		       long response_buffer_length, /* length of the buffer (modified)*/
-		       long connection,
-		       boolean verbose));
-
-char *trim_junk PARAMS((char *headline));
-
+ *	Routines originally from UI.c -- FM
+ *
+ *----------------------------------------------------------------------*/
+
+    char *generate_retrieval_apdu(char *buff,
+				  long *buff_len,
+				  any *docID,
+				  long chunk_type,
+				  long start_line, long end_line,
+				  char *type,
+				  char *database_name);
+
+    long interpret_message(char *request_message,
+			   long request_length,
+			   char *response_message,
+			   long response_buffer_length,		/* length of the buffer (modified) */
+			   long connection,
+			   boolean verbose);
 
+    char *trim_junk(char *headline);
 
 /*
-**	Routines originally from ZProt.c -- FM
-**
-**----------------------------------------------------------------------*/
+ *	Routines originally from ZProt.c -- FM
+ *
+ *----------------------------------------------------------------------*/
 
 /* APDU types */
 
-typedef struct InitAPDU {
-	pdu_type		PDUType;
-	boolean			willSearch,willPresent,willDelete;
-	boolean			supportAccessControl,supportResourceControl;
-	long			PreferredMessageSize;
-	long			MaximumRecordSize;
-	char*			IDAuthentication;
-	char*			ImplementationID;
-	char*			ImplementationName;
-	char*			ImplementationVersion;
-	any*			ReferenceID;
-	void*			UserInformationField;
-	} InitAPDU;
-
-typedef struct InitResponseAPDU {
-	pdu_type		PDUType;
-	boolean			Result;
-	boolean			willSearch,willPresent,willDelete;
-	boolean			supportAccessControl,supportResourceControl;
-	long			PreferredMessageSize;
-	long			MaximumRecordSize;
-	char*			IDAuthentication;
-	char*			ImplementationID;
-	char*			ImplementationName;
-	char*			ImplementationVersion;
-	any*			ReferenceID;
-	void*			UserInformationField;
-	} InitResponseAPDU;
-
-typedef struct SearchAPDU {
-	pdu_type		PDUType;
-	long			SmallSetUpperBound;
-	long			LargeSetLowerBound;
-	long			MediumSetPresentNumber;
-	boolean			ReplaceIndicator;
-	char*			ResultSetName;
-	char**			DatabaseNames;
-	char*			QueryType;
-	char**			ElementSetNames;
-	any*			ReferenceID;
-	void*			Query;
-	} SearchAPDU;
-
-typedef struct SearchResponseAPDU {
-	pdu_type		PDUType;
-	long			SearchStatus;
-	long			ResultCount;
-	long			NumberOfRecordsReturned;
-	long			NextResultSetPosition;
-	long			ResultSetStatus;
-	long			PresentStatus;
-	any*			ReferenceID;
-	void*			DatabaseDiagnosticRecords;
-	} SearchResponseAPDU;
-
-typedef struct PresentAPDU {
-	pdu_type		PDUType;
-	long			NumberOfRecordsRequested;
-	long			ResultSetStartPosition;
-	char*			ResultSetID;
-	char*			ElementSetNames;
-	any*			ReferenceID;
-	void*			PresentInfo;
-	} PresentAPDU;
-
-typedef struct PresentResponseAPDU {
-	pdu_type		PDUType;
-	boolean			PresentStatus;
-	long			NumberOfRecordsReturned;
-	long			NextResultSetPosition;
-	any*			ReferenceID;
-	void*			DatabaseDiagnosticRecords;
-	} PresentResponseAPDU;
+    typedef struct InitAPDU {
+	pdu_type PDUType;
+	boolean willSearch, willPresent, willDelete;
+	boolean supportAccessControl, supportResourceControl;
+	long PreferredMessageSize;
+	long MaximumRecordSize;
+	char *IDAuthentication;
+	char *ImplementationID;
+	char *ImplementationName;
+	char *ImplementationVersion;
+	any *ReferenceID;
+	void *UserInformationField;
+    } InitAPDU;
+
+    typedef struct InitResponseAPDU {
+	pdu_type PDUType;
+	boolean Result;
+	boolean willSearch, willPresent, willDelete;
+	boolean supportAccessControl, supportResourceControl;
+	long PreferredMessageSize;
+	long MaximumRecordSize;
+	char *IDAuthentication;
+	char *ImplementationID;
+	char *ImplementationName;
+	char *ImplementationVersion;
+	any *ReferenceID;
+	void *UserInformationField;
+    } InitResponseAPDU;
+
+    typedef struct SearchAPDU {
+	pdu_type PDUType;
+	long SmallSetUpperBound;
+	long LargeSetLowerBound;
+	long MediumSetPresentNumber;
+	boolean ReplaceIndicator;
+	char *ResultSetName;
+	char **DatabaseNames;
+	char *QueryType;
+	char **ElementSetNames;
+	any *ReferenceID;
+	void *Query;
+    } SearchAPDU;
+
+    typedef struct SearchResponseAPDU {
+	pdu_type PDUType;
+	long SearchStatus;
+	long ResultCount;
+	long NumberOfRecordsReturned;
+	long NextResultSetPosition;
+	long ResultSetStatus;
+	long PresentStatus;
+	any *ReferenceID;
+	void *DatabaseDiagnosticRecords;
+    } SearchResponseAPDU;
+
+    typedef struct PresentAPDU {
+	pdu_type PDUType;
+	long NumberOfRecordsRequested;
+	long ResultSetStartPosition;
+	char *ResultSetID;
+	char *ElementSetNames;
+	any *ReferenceID;
+	void *PresentInfo;
+    } PresentAPDU;
+
+    typedef struct PresentResponseAPDU {
+	pdu_type PDUType;
+	boolean PresentStatus;
+	long NumberOfRecordsReturned;
+	long NextResultSetPosition;
+	any *ReferenceID;
+	void *DatabaseDiagnosticRecords;
+    } PresentResponseAPDU;
 
 /*----------------------------------------------------------------------*/
 /* Functions */
 
-InitAPDU* makeInitAPDU PARAMS((boolean search,boolean present,boolean deleteIt,
-			    boolean accessControl,boolean resourceControl,
-			    long prefMsgSize,long maxMsgSize,
-			    char* auth,char* id,char* name, char* version,
-			    any* refID,void* userInfo));
-void freeInitAPDU PARAMS((InitAPDU* init));
-char* writeInitAPDU PARAMS((InitAPDU* init,char* buffer,long* len));
-char* readInitAPDU PARAMS((InitAPDU** init,char* buffer));
-
-InitResponseAPDU* makeInitResponseAPDU PARAMS((boolean result,
-					    boolean search,boolean present,boolean deleteIt,
-					    boolean accessControl,boolean resourceControl,
-					    long prefMsgSize,long maxMsgSize,
-					    char* auth,char* id,char* name, char* version,
-					    any* refID,void* userInfo));
-void freeInitResponseAPDU PARAMS((InitResponseAPDU* init));
-char* writeInitResponseAPDU PARAMS((InitResponseAPDU* init,char* buffer,long* len));
-char* readInitResponseAPDU PARAMS((InitResponseAPDU** init,char* buffer));
-InitResponseAPDU* replyToInitAPDU PARAMS((InitAPDU* init,boolean result,void* userInfo));
-
-SearchAPDU* makeSearchAPDU PARAMS((long small,long large, long medium,
-				boolean replace,char* name,char** databases,
-				char* type,char** elements,any* refID,void* queryInfo));
-void freeSearchAPDU PARAMS((SearchAPDU* query));
-char* writeSearchAPDU PARAMS((SearchAPDU* query,char* buffer,long* len));
-char* readSearchAPDU PARAMS((SearchAPDU** query,char* buffer));
-
-SearchResponseAPDU* makeSearchResponseAPDU PARAMS((long result,long count,
-						long recordsReturned,long nextPos,
-						long resultStatus,long presentStatus,
-						any* refID,void* records));
-void freeSearchResponseAPDU PARAMS((SearchResponseAPDU* queryResponse));
-char* writeSearchResponseAPDU PARAMS((SearchResponseAPDU* queryResponse,char* buffer,long* len));
-char* readSearchResponseAPDU PARAMS((SearchResponseAPDU** queryResponse,char* buffer));
-
-PresentAPDU* makePresentAPDU PARAMS((long recsReq, long startPos,
-				  char* resultID,any* refID,void* info));
-void freePresentAPDU PARAMS((PresentAPDU* present));
-char* writePresentAPDU PARAMS((PresentAPDU* present,char* buffer,long* len));
-char* readPresentAPDU PARAMS((PresentAPDU** present,char* buffer));
-
-PresentResponseAPDU* makePresentResponseAPDU PARAMS((boolean status,long recsRet,
-						  long nextPos,any* refID,
-						  void* records));
-void freePresentResponseAPDU PARAMS((PresentResponseAPDU* present));
-char* writePresentResponseAPDU PARAMS((PresentResponseAPDU* present,char* buffer,long* len));
-char* readPresentResponseAPDU PARAMS((PresentResponseAPDU** present,char* buffer));
+    InitAPDU *makeInitAPDU(boolean search, boolean present, boolean deleteIt,
+			   boolean accessControl, boolean resourceControl, long prefMsgSize,
+			   long maxMsgSize,
+			   char *auth,
+			   char *id,
+			   char *name,
+			   char *version,
+			   any *refID,
+			   void *userInfo);
+    void freeInitAPDU(InitAPDU * init);
+    char *writeInitAPDU(InitAPDU * init, char *buffer, long *len);
+    char *readInitAPDU(InitAPDU ** init, char *buffer);
+
+    InitResponseAPDU *makeInitResponseAPDU(boolean result,
+					   boolean search,
+					   boolean present,
+					   boolean deleteIt,
+					   boolean accessControl,
+					   boolean resourceControl,
+					   long prefMsgSize,
+					   long maxMsgSize,
+					   char *auth,
+					   char *id,
+					   char *name,
+					   char *version,
+					   any *refID,
+					   void *userInfo);
+    void freeInitResponseAPDU(InitResponseAPDU *init);
+    char *writeInitResponseAPDU(InitResponseAPDU *init, char *buffer, long *len);
+    char *readInitResponseAPDU(InitResponseAPDU **init, char *buffer);
+    InitResponseAPDU *replyToInitAPDU(InitAPDU * init, boolean result, void *userInfo);
+
+    SearchAPDU *makeSearchAPDU(long small, long large, long medium,
+			       boolean replace, char *name, char **databases,
+			       char *type, char **elements, any *refID, void *queryInfo);
+    void freeSearchAPDU(SearchAPDU *query);
+    char *writeSearchAPDU(SearchAPDU *query, char *buffer, long *len);
+    char *readSearchAPDU(SearchAPDU **query, char *buffer);
+
+    SearchResponseAPDU *makeSearchResponseAPDU(long result, long count,
+					       long recordsReturned, long nextPos,
+					       long resultStatus, long presentStatus,
+					       any *refID, void *records);
+    void freeSearchResponseAPDU(SearchResponseAPDU *queryResponse);
+    char *writeSearchResponseAPDU(SearchResponseAPDU *queryResponse, char
+				  *buffer, long *len);
+    char *readSearchResponseAPDU(SearchResponseAPDU **queryResponse, char *buffer);
+
+    PresentAPDU *makePresentAPDU(long recsReq, long startPos,
+				 char *resultID, any *refID, void *info);
+    void freePresentAPDU(PresentAPDU * present);
+    char *writePresentAPDU(PresentAPDU * present, char *buffer, long *len);
+    char *readPresentAPDU(PresentAPDU ** present, char *buffer);
+
+    PresentResponseAPDU *makePresentResponseAPDU(boolean status, long recsRet,
+						 long nextPos, any *refID,
+						 void *records);
+    void freePresentResponseAPDU(PresentResponseAPDU * present);
+    char *writePresentResponseAPDU(PresentResponseAPDU * present, char
+				   *buffer, long *len);
+    char *readPresentResponseAPDU(PresentResponseAPDU ** present, char *buffer);
 
 /*----------------------------------------------------------------------*/
 /* user extension hooks: */
 
-extern char* writeInitInfo PARAMS((InitAPDU* init,char* buffer,long* len));
-extern char* readInitInfo PARAMS((void** info,char* buffer));
+    extern char *writeInitInfo(InitAPDU * init, char *buffer, long *len);
+    extern char *readInitInfo(void **info, char *buffer);
 
-extern char* writeInitResponseInfo PARAMS((InitResponseAPDU* init,char* buffer,long* len));
-extern char* readInitResponseInfo PARAMS((void** info,char* buffer));
+    extern char *writeInitResponseInfo(InitResponseAPDU *init, char *buffer, long *len);
+    extern char *readInitResponseInfo(void **info, char *buffer);
 
-extern char* writeSearchInfo PARAMS((SearchAPDU* query,char* buffer,long* len));
-extern char* readSearchInfo PARAMS((void** info,char* buffer));
+    extern char *writeSearchInfo(SearchAPDU *query, char *buffer, long *len);
+    extern char *readSearchInfo(void **info, char *buffer);
 
-extern char* writeSearchResponseInfo PARAMS((SearchResponseAPDU* query,char* buffer,long* len));
-extern char* readSearchResponseInfo PARAMS((void** info,char* buffer));
+    extern char *writeSearchResponseInfo(SearchResponseAPDU *query, char
+					 *buffer, long *len);
+    extern char *readSearchResponseInfo(void **info, char *buffer);
 
-extern char* writePresentInfo PARAMS((PresentAPDU* present,char* buffer,long* len));
-extern char* readPresentInfo PARAMS((void** info,char* buffer));
+    extern char *writePresentInfo(PresentAPDU * present, char *buffer, long *len);
+    extern char *readPresentInfo(void **info, char *buffer);
 
-extern char* writePresentResponseInfo PARAMS((PresentResponseAPDU* present,char* buffer,long* len));
-extern char* readPresentResponseInfo PARAMS((void** info,char* buffer));
+    extern char *writePresentResponseInfo(PresentResponseAPDU * present, char
+					  *buffer, long *len);
+    extern char *readPresentResponseInfo(void **info, char *buffer);
 
-
-#endif /* HTVMSWAIS_H */
+#ifdef __cplusplus
+}
+#endif
+#endif				/* HTVMSWAIS_H */
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/HTVMS_WaisUI.c
+++ lynx-cur-2.8.6/WWW/Library/Implementation/HTVMS_WaisUI.c
@@ -1,21 +1,21 @@
 /*							HTVMS_WAISUI.c
-**
-**	Adaptation for Lynx by F.Macrides (macrides@sci.wfeb.edu)
-**
-**	30-May-1994 FM	Initial version.
-**
-**----------------------------------------------------------------------*/
+ *
+ *	Adaptation for Lynx by F.Macrides (macrides@sci.wfeb.edu)
+ *
+ *	30-May-1994 FM	Initial version.
+ *
+ *----------------------------------------------------------------------*/
 
 /*
-**	Routines originally from UI.c -- FM
-**
-**----------------------------------------------------------------------*/
+ *	Routines originally from UI.c -- FM
+ *
+ *----------------------------------------------------------------------*/
 /* WIDE AREA INFORMATION SERVER SOFTWARE:
-   No guarantees or restrictions.  See the readme file for the full standard
-   disclaimer.
-
-   Brewster@think.com
-*/
+ * No guarantees or restrictions.  See the readme file for the full standard
+ * disclaimer.
+ *
+ * Brewster@think.com
+ */
 
 /*
  * this is a simple ui toolkit for building other ui's on top.
@@ -36,18 +36,19 @@
  */
 
 #include <HTUtils.h>
+
+#ifdef VMS
 #include <HTVMS_WaisUI.h>
 #include <HTVMS_WaisProt.h>
 #include <HTTCP.h>
 
-#undef MAXINT	/* we don't need it here, and www_tcp.h may conflict */
+#undef MAXINT			/* we don't need it here, and www_tcp.h may conflict */
 #include <math.h>
 
 #include <LYexit.h>
 #include <LYLeaks.h>
 
-void
-log_write(char *s GCC_UNUSED)
+void log_write(char *s GCC_UNUSED)
 {
     return;
 }
@@ -57,51 +58,51 @@
 /* returns a pointer in the buffer of the first free byte.
    if it overflows, then NULL is returned
  */
-char *
-generate_search_apdu(
-char* buff,     /* buffer to hold the apdu */
-long *buff_len,    /* length of the buffer changed to reflect new data written */
-char *seed_words,    /* string of the seed words */
-char *database_name,
-DocObj** docobjs,
-long maxDocsRetrieved)
-{
-  /* local variables */
-
-  SearchAPDU *search3;
-  char  *end_ptr;
-  static char *database_names[2] = {"", 0};
-  any refID;
-  WAISSearch *query;
-  refID.size = 1;
-  refID.bytes = "3";
-
-  database_names[0] = database_name;
-  query = makeWAISSearch(seed_words,
-                         docobjs, /* DocObjsPtr */
-                         0,
-                         1,     /* DateFactor */
-                         0,     /* BeginDateRange */
-                         0,     /* EndDateRange */
-                         maxDocsRetrieved
-                         );
-
-  search3 = makeSearchAPDU(30,
-			   5000, /* should be large */
-			   30,
-                           1,	/* replace indicator */
-                           "",	/* result set name */
-                           database_names, /* database name */
-                           QT_RelevanceFeedbackQuery, /* query_type */
-                           0,   /* element name */
-                           NULL, /* reference ID */
-                           query);
-
-  end_ptr = writeSearchAPDU(search3, buff, buff_len);
-
-  CSTFreeWAISSearch(query);
-  freeSearchAPDU(search3);
-  return(end_ptr);
+char *generate_search_apdu(char *buff,	/* buffer to hold the apdu */
+			   long *buff_len,	/* length of the buffer changed to reflect new data written */
+			   char *seed_words,	/* string of the seed words */
+			   char *database_name,
+			   DocObj **docobjs,
+			   long maxDocsRetrieved)
+{
+    /* local variables */
+
+    SearchAPDU *search3;
+    char *end_ptr;
+    static char *database_names[2] =
+    {"", 0};
+    any refID;
+    WAISSearch *query;
+
+    refID.size = 1;
+    refID.bytes = "3";
+
+    database_names[0] = database_name;
+    query = makeWAISSearch(seed_words,
+			   docobjs,	/* DocObjsPtr */
+			   0,
+			   1,	/* DateFactor */
+			   0,	/* BeginDateRange */
+			   0,	/* EndDateRange */
+			   maxDocsRetrieved
+	);
+
+    search3 = makeSearchAPDU(30,
+			     5000,	/* should be large */
+			     30,
+			     1,	/* replace indicator */
+			     "",	/* result set name */
+			     database_names,	/* database name */
+			     QT_RelevanceFeedbackQuery,		/* query_type */
+			     0,	/* element name */
+			     NULL,	/* reference ID */
+			     query);
+
+    end_ptr = writeSearchAPDU(search3, buff, buff_len);
+
+    CSTFreeWAISSearch(query);
+    freeSearchAPDU(search3);
+    return (end_ptr);
 }
 
 /*----------------------------------------------------------------------*/
@@ -110,63 +111,61 @@
    if it overflowed, then NULL is returned
  */
 
-char *
-generate_retrieval_apdu(
-char *buff,
-long *buff_len,    /* length of the buffer changed to reflect new data written */
-any *docID,
-long chunk_type,
-long start,
-long end,
-char *type,
-char *database_name)
-{
-  SearchAPDU *search;
-  char  *end_ptr;
-
-  static char *database_names[2];
-  static char *element_names[3];
-  any refID;
-
-  DocObj *DocObjs[2];
-  any *query;			/* changed from char* by brewster */
-
-  if(NULL == type)
-    type = s_strdup("TEXT");
-
-  database_names[0] = database_name;
-  database_names[1] = NULL;
-
-  element_names[0] = " ";
-  element_names[1] = ES_DocumentText;
-  element_names[2] = NULL;
-
-  refID.size = 1;
-  refID.bytes = "3";
-
-  switch(chunk_type){
-  case CT_line:
-    DocObjs[0] = makeDocObjUsingLines(docID, type, start, end);
-    break;
-  case CT_byte:
-    DocObjs[0] = makeDocObjUsingBytes(docID, type, start, end);
-    break;
-  }
-  DocObjs[1] = NULL;
-
-  query = makeWAISTextQuery(DocObjs);
-  search = makeSearchAPDU( 10, 16, 15,
-			  1,	/* replace indicator */
-			  "FOO", /* result set name */
-			  database_names, /* database name */
-			  QT_TextRetrievalQuery, /* query_type */
-			  element_names, /* element name */
-			  &refID, /* reference ID */
-			  query);
-  end_ptr = writeSearchAPDU(search, buff, buff_len);
-  CSTFreeWAISTextQuery(query);
-  freeSearchAPDU(search);
-  return(end_ptr);
+char *generate_retrieval_apdu(char *buff,
+			      long *buff_len,	/* length of the buffer changed to reflect new data written */
+			      any *docID,
+			      long chunk_type,
+			      long start,
+			      long end,
+			      char *type,
+			      char *database_name)
+{
+    SearchAPDU *search;
+    char *end_ptr;
+
+    static char *database_names[2];
+    static char *element_names[3];
+    any refID;
+
+    DocObj *DocObjs[2];
+    any *query;			/* changed from char* by brewster */
+
+    if (NULL == type)
+	type = s_strdup("TEXT");
+
+    database_names[0] = database_name;
+    database_names[1] = NULL;
+
+    element_names[0] = " ";
+    element_names[1] = ES_DocumentText;
+    element_names[2] = NULL;
+
+    refID.size = 1;
+    refID.bytes = "3";
+
+    switch (chunk_type) {
+    case CT_line:
+	DocObjs[0] = makeDocObjUsingLines(docID, type, start, end);
+	break;
+    case CT_byte:
+	DocObjs[0] = makeDocObjUsingBytes(docID, type, start, end);
+	break;
+    }
+    DocObjs[1] = NULL;
+
+    query = makeWAISTextQuery(DocObjs);
+    search = makeSearchAPDU(10, 16, 15,
+			    1,	/* replace indicator */
+			    "FOO",	/* result set name */
+			    database_names,	/* database name */
+			    QT_TextRetrievalQuery,	/* query_type */
+			    element_names,	/* element name */
+			    &refID,	/* reference ID */
+			    query);
+    end_ptr = writeSearchAPDU(search, buff, buff_len);
+    CSTFreeWAISTextQuery(query);
+    freeSearchAPDU(search);
+    return (end_ptr);
 }
 
 /*----------------------------------------------------------------------*/
@@ -176,183 +175,181 @@
  * to those trying to modify the transport code to use non-UNIX streams:
  *  This is the function to modify!
  */
-PRIVATE long read_from_stream(int d, char *buf, long nbytes)
+static long read_from_stream(int d, char *buf, long nbytes)
 {
-  long didRead;
-  long toRead = nbytes;
-  long totalRead = 0;		/* paranoia */
-
-  while (toRead > 0){
-    didRead = NETREAD (d, buf, (int)toRead);
-    if(didRead == HT_INTERRUPTED)
-      return(HT_INTERRUPTED);
-    if(didRead == -1)		/* error*/
-      return(-1);
-    if(didRead == 0)		/* eof */
-      return(-2);		/* maybe this should return 0? */
-    toRead -= didRead;
-    buf += didRead;
-    totalRead += didRead;
-  }
-  if(totalRead != nbytes)	/* we overread for some reason */
-    return(- totalRead);	/* bad news */
-  return(totalRead);
+    long didRead;
+    long toRead = nbytes;
+    long totalRead = 0;		/* paranoia */
+
+    while (toRead > 0) {
+	didRead = NETREAD(d, buf, (int) toRead);
+	if (didRead == HT_INTERRUPTED)
+	    return (HT_INTERRUPTED);
+	if (didRead == -1)	/* error */
+	    return (-1);
+	if (didRead == 0)	/* eof */
+	    return (-2);	/* maybe this should return 0? */
+	toRead -= didRead;
+	buf += didRead;
+	totalRead += didRead;
+    }
+    if (totalRead != nbytes)	/* we overread for some reason */
+	return (-totalRead);	/* bad news */
+    return (totalRead);
 }
 
 /*----------------------------------------------------------------------*/
 
 /* returns the length of the response, 0 if an error */
 
-PRIVATE long
-transport_message(
-	long connection,
-	char *request_message,
-	long request_length,
-	char *response_message,
-	long response_buffer_length)
-{
-  WAISMessage header;
-  long response_length;
-  int rv;
-
-
-  /* Write out message.  Read back header.  Figure out response length. */
-
-  if( request_length + HEADER_LENGTH !=
-      NETWRITE(connection,request_message,
-		  (int)( request_length +HEADER_LENGTH)) )
-    return 0;
+static long transport_message(long connection,
+			      char *request_message,
+			      long request_length,
+			      char *response_message,
+			      long response_buffer_length)
+{
+    WAISMessage header;
+    long response_length;
+    int rv;
+
+    /* Write out message.  Read back header.  Figure out response length. */
+
+    if (request_length + HEADER_LENGTH !=
+	NETWRITE(connection, request_message,
+		 (int) (request_length + HEADER_LENGTH)))
+	return 0;
 
-  /* read for the first '0' */
+    /* read for the first '0' */
 
-  while(1){
-    rv = read_from_stream(connection, response_message, 1);
-    if (rv == HT_INTERRUPTED)
-      return HT_INTERRUPTED;
-    if (rv < 0)
-      return 0;
-    if('0' == response_message[0])
-      break;
-  }
-
-  rv = read_from_stream(connection, response_message + 1, HEADER_LENGTH -1);
-  if (rv == HT_INTERRUPTED)
-    return HT_INTERRUPTED;
-  if (rv < 0)
-    return 0;
-
-  readWAISPacketHeader(response_message, &header);
-  {
-    char length_array[11];
-    strncpy(length_array, header.msg_len, 10);
-    length_array[10] = '\0';
-    response_length = atol(length_array);
-    /*
-      if(verbose){
-      printf("WAIS header: '%s' length_array: '%s'\n",
-      response_message, length_array);
-      }
-      */
-    if(response_length > response_buffer_length){
-      /* we got a message that is too long, therefore empty the message out,
-	 and return 0 */
-      long i;
-      for(i = 0; i < response_length; i++){
-	rv = read_from_stream(connection,
-			      response_message + HEADER_LENGTH,
-			      1);
+    while (1) {
+	rv = read_from_stream(connection, response_message, 1);
 	if (rv == HT_INTERRUPTED)
-	  return HT_INTERRUPTED;
+	    return HT_INTERRUPTED;
 	if (rv < 0)
-	  return 0;
-      }
-      return(0);
-    }
-  }
-  rv = read_from_stream(connection,
-			response_message + HEADER_LENGTH,
-			response_length);
-  if (rv == HT_INTERRUPTED)
-    return HT_INTERRUPTED;
-  if (rv < 0)
-    return 0;
-  return(response_length);
+	    return 0;
+	if ('0' == response_message[0])
+	    break;
+    }
+
+    rv = read_from_stream(connection, response_message + 1, HEADER_LENGTH - 1);
+    if (rv == HT_INTERRUPTED)
+	return HT_INTERRUPTED;
+    if (rv < 0)
+	return 0;
+
+    readWAISPacketHeader(response_message, &header);
+    {
+	char length_array[11];
+
+	strncpy(length_array, header.msg_len, 10);
+	length_array[10] = '\0';
+	response_length = atol(length_array);
+	/*
+	   if(verbose){
+	   printf("WAIS header: '%s' length_array: '%s'\n",
+	   response_message, length_array);
+	   }
+	 */
+	if (response_length > response_buffer_length) {
+	    /* we got a message that is too long, therefore empty the message out,
+	       and return 0 */
+	    long i;
+
+	    for (i = 0; i < response_length; i++) {
+		rv = read_from_stream(connection,
+				      response_message + HEADER_LENGTH,
+				      1);
+		if (rv == HT_INTERRUPTED)
+		    return HT_INTERRUPTED;
+		if (rv < 0)
+		    return 0;
+	    }
+	    return (0);
+	}
+    }
+    rv = read_from_stream(connection,
+			  response_message + HEADER_LENGTH,
+			  response_length);
+    if (rv == HT_INTERRUPTED)
+	return HT_INTERRUPTED;
+    if (rv < 0)
+	return 0;
+    return (response_length);
 }
 
 /*----------------------------------------------------------------------*/
 
 /* returns the number of bytes written.  0 if an error */
-long
-interpret_message(
-	char *request_message,
-	long request_length, /* length of the buffer */
-	char *response_message,
-	long response_buffer_length,
-	long connection,
-	boolean verbose GCC_UNUSED)
-{
-  long response_length;
-
-  /* ?
-  if(verbose){
-    printf ("sending");
-    if(hostname_internal && strlen(hostname_internal) > 0)
-      printf(" to host %s", hostname_internal);
-    if(service_name && strlen(service_name) > 0)
-      printf(" for service %s", service_name);
-    printf("\n");
-    twais_dsply_rsp_apdu(request_message + HEADER_LENGTH,
-			 request_length);
-  }
-
-  */
-
-  writeWAISPacketHeader(request_message,
-			request_length,
-			(long)'z',	/* Z39.50 */
-			"wais      ", /* server name */
-			(long)NO_COMPRESSION,	/* no compression */
-			(long)NO_ENCODING,(long)HEADER_VERSION);
-  if(connection != 0) {
-    response_length = transport_message(connection, request_message,
-					request_length,
-					response_message,
-					response_buffer_length);
-    if (response_length == HT_INTERRUPTED)
-      return(HT_INTERRUPTED);
-  }
-  else
-      return(0);
+long interpret_message(char *request_message,
+		       long request_length,	/* length of the buffer */
+		       char *response_message,
+		       long response_buffer_length,
+		       long connection,
+		       boolean verbose GCC_UNUSED)
+{
+    long response_length;
+
+    /* ?
+       if(verbose){
+       printf ("sending");
+       if(hostname_internal && strlen(hostname_internal) > 0)
+       printf(" to host %s", hostname_internal);
+       if(service_name && strlen(service_name) > 0)
+       printf(" for service %s", service_name);
+       printf("\n");
+       twais_dsply_rsp_apdu(request_message + HEADER_LENGTH,
+       request_length);
+       }
+
+     */
+
+    writeWAISPacketHeader(request_message,
+			  request_length,
+			  (long) 'z',	/* Z39.50 */
+			  "wais      ",		/* server name */
+			  (long) NO_COMPRESSION,	/* no compression */
+			  (long) NO_ENCODING, (long) HEADER_VERSION);
+    if (connection != 0) {
+	response_length = transport_message(connection, request_message,
+					    request_length,
+					    response_message,
+					    response_buffer_length);
+	if (response_length == HT_INTERRUPTED)
+	    return (HT_INTERRUPTED);
+    } else
+	return (0);
 
-  return(response_length);
+    return (response_length);
 }
 
 /*----------------------------------------------------------------------*/
 
 /* modifies the string to exclude all seeker codes. sets length to
    the new length. */
-PRIVATE char *delete_seeker_codes(char *string, long *length)
+static char *delete_seeker_codes(char *string, long *length)
 {
-  long original_count; /* index into the original string */
-  long new_count = 0; /* index into the collapsed string */
-  for(original_count = 0; original_count < *length; original_count++){
-    if(27 == string[original_count]){
-      /* then we have an escape code */
-      /* if the next letter is '(' or ')', then ignore two letters */
-      if('(' == string[original_count + 1] ||
-    ')' == string[original_count + 1])
-     original_count += 1;    /* it is a term marker */
-      else original_count += 4; /* it is a paragraph marker */
+    long original_count;	/* index into the original string */
+    long new_count = 0;		/* index into the collapsed string */
+
+    for (original_count = 0; original_count < *length; original_count++) {
+	if (27 == string[original_count]) {
+	    /* then we have an escape code */
+	    /* if the next letter is '(' or ')', then ignore two letters */
+	    if ('(' == string[original_count + 1] ||
+		')' == string[original_count + 1])
+		original_count += 1;	/* it is a term marker */
+	    else
+		original_count += 4;	/* it is a paragraph marker */
+	} else
+	    string[new_count++] = string[original_count];
     }
-    else string[new_count++] = string[original_count];
-  }
-  *length = new_count;
-  return(string);
+    *length = new_count;
+    return (string);
 }
 
 /*----------------------------------------------------------------------*/
 
-#if defined(VMS) && defined(__GNUC__)			/* 10-AUG-1995 [pr] */
+#if defined(VMS) && defined(__GNUC__)	/* 10-AUG-1995 [pr] */
 /*
   Workaround for an obscure bug in gcc's 2.6.[123] and 2.7.0 vax/vms port;
   sometimes global variables will end up not being defined properly,
@@ -365,47 +362,48 @@
    Make a reference to VAXCRTL's _ctype_[], and also one to this dummy
    variable itself to prevent any "defined but not used" warning.
  */
-static __const void *__const ctype_dummy[] = { &_ctype_, &ctype_dummy };
+static __const void *__const ctype_dummy[] =
+{&_ctype_, &ctype_dummy};
 #endif /* VMS && __GNUC__ */
 
 /* returns a pointer to a string with good stuff */
 char *trim_junk(char *headline)
 {
-  long length = strlen(headline) + 1; /* include the trailing null */
-  size_t i;
-  headline = delete_seeker_codes(headline, &length);
-  /* delete leading spaces */
-  for(i=0; i < strlen(headline); i++){
-    if(isprint(headline[i])){
-      break;
-    }
-  }
-  headline = headline + i;
-  /* delete trailing stuff */
-  for(i=strlen(headline) - 1 ; i > 0; i--){
-    if(isprint(headline[i])){
-      break;
-    }
-    headline[i] = '\0';
-  }
-  return(headline);
+    long length = strlen(headline) + 1;		/* include the trailing null */
+    size_t i;
+
+    headline = delete_seeker_codes(headline, &length);
+    /* delete leading spaces */
+    for (i = 0; i < strlen(headline); i++) {
+	if (isprint(headline[i])) {
+	    break;
+	}
+    }
+    headline = headline + i;
+    /* delete trailing stuff */
+    for (i = strlen(headline) - 1; i > 0; i--) {
+	if (isprint(headline[i])) {
+	    break;
+	}
+	headline[i] = '\0';
+    }
+    return (headline);
 }
 
 /*----------------------------------------------------------------------*/
 
-
 /*
-**	Routines originally from ZProt.c -- FM
-**
-**----------------------------------------------------------------------*/
+ *	Routines originally from ZProt.c -- FM
+ *
+ *----------------------------------------------------------------------*/
 /* WIDE AREA INFORMATION SERVER SOFTWARE:`
-   No guarantees or restrictions.  See the readme file for the full standard
-   disclaimer.
-
-   3.26.90	Harry Morris, morris@think.com
-   3.30.90  Harry Morris - Changed any->bits to any->bytes
-   4.11.90  HWM - generalized conditional includes (see c-dialect.h)
-*/
+ * No guarantees or restrictions.  See the readme file for the full standard
+ * disclaimer.
+ *
+ * 3.26.90	Harry Morris, morris@think.com
+ * 3.30.90  Harry Morris - Changed any->bits to any->bytes
+ * 4.11.90  HWM - generalized conditional includes (see c-dialect.h)
+ */
 
 #define RESERVE_SPACE_FOR_HEADER(spaceLeft)		\
 	*spaceLeft -= HEADER_LEN;
@@ -416,156 +414,173 @@
 
 /*----------------------------------------------------------------------*/
 
-InitResponseAPDU*
-makeInitResponseAPDU(
-boolean result,
-boolean search,
-boolean present,
-boolean deleteIt,
-boolean accessControl,
-boolean resourceControl,
-long prefSize,
-long maxMsgSize,
-char* auth,
-char* id,
-char* name,
-char* version,
-any* refID,
-void* userInfo)
+InitResponseAPDU *makeInitResponseAPDU(boolean result,
+				       boolean search,
+				       boolean present,
+				       boolean deleteIt,
+				       boolean accessControl,
+				       boolean resourceControl,
+				       long prefSize,
+				       long maxMsgSize,
+				       char *auth,
+				       char *id,
+				       char *name,
+				       char *version,
+				       any *refID,
+				       void *userInfo)
 /* build an initResponse APDU with user specified information */
 {
-  InitResponseAPDU* init = (InitResponseAPDU*)s_malloc((size_t)sizeof(InitResponseAPDU));
+    InitResponseAPDU *init = (InitResponseAPDU *) s_malloc((size_t) sizeof(InitResponseAPDU));
 
-  init->PDUType = initResponseAPDU;
-  init->Result = result;
-  init->willSearch = search;
-  init->willPresent = present;
-  init->willDelete = deleteIt;
-  init->supportAccessControl = accessControl;
-  init->supportResourceControl = resourceControl;
-  init->PreferredMessageSize = prefSize;
-  init->MaximumRecordSize = maxMsgSize;
-  init->IDAuthentication = s_strdup(auth);
-  init->ImplementationID = s_strdup(id);
-  init->ImplementationName = s_strdup(name);
-  init->ImplementationVersion = s_strdup(version);
-  init->ReferenceID = duplicateAny(refID);
-  init->UserInformationField = userInfo; /* not copied! */
+    init->PDUType = initResponseAPDU;
+    init->Result = result;
+    init->willSearch = search;
+    init->willPresent = present;
+    init->willDelete = deleteIt;
+    init->supportAccessControl = accessControl;
+    init->supportResourceControl = resourceControl;
+    init->PreferredMessageSize = prefSize;
+    init->MaximumRecordSize = maxMsgSize;
+    init->IDAuthentication = s_strdup(auth);
+    init->ImplementationID = s_strdup(id);
+    init->ImplementationName = s_strdup(name);
+    init->ImplementationVersion = s_strdup(version);
+    init->ReferenceID = duplicateAny(refID);
+    init->UserInformationField = userInfo;	/* not copied! */
 
-  return(init);
+    return (init);
 }
 
 /*----------------------------------------------------------------------*/
 
-void
-freeInitResponseAPDU(InitResponseAPDU* init)
+void freeInitResponseAPDU(InitResponseAPDU *init)
 /* free an initAPDU */
 {
-  s_free(init->IDAuthentication);
-  s_free(init->ImplementationID);
-  s_free(init->ImplementationName);
-  s_free(init->ImplementationVersion);
-  freeAny(init->ReferenceID);
-  s_free(init);
+    s_free(init->IDAuthentication);
+    s_free(init->ImplementationID);
+    s_free(init->ImplementationName);
+    s_free(init->ImplementationVersion);
+    freeAny(init->ReferenceID);
+    s_free(init);
 }
 
 /*----------------------------------------------------------------------*/
 
-char*
-writeInitResponseAPDU(InitResponseAPDU* init, char* buffer, long* len)
+char *writeInitResponseAPDU(InitResponseAPDU *init, char *buffer, long *len)
 /* write the initResponse to a buffer, adding system information */
 {
-  char* buf = buffer + HEADER_LEN; /* leave room for the header-length-indicator */
-  long size;
-  bit_map* optionsBM = NULL;
-
-  RESERVE_SPACE_FOR_HEADER(len);
-
-  buf = writePDUType(init->PDUType,buf,len);
-  buf = writeBoolean(init->Result,buf,len);
-  buf = writeProtocolVersion(buf,len);
-
-  optionsBM = makeBitMap((unsigned long)5,init->willSearch,init->willPresent,
-                         init->willDelete,init->supportAccessControl,
-                         init->supportResourceControl);
-  buf = writeBitMap(optionsBM,DT_Options,buf,len);
-  freeBitMap(optionsBM);
-
-  buf = writeNum(init->PreferredMessageSize,DT_PreferredMessageSize,buf,len);
-  buf = writeNum(init->MaximumRecordSize,DT_MaximumRecordSize,buf,len);
-  buf = writeString(init->IDAuthentication,DT_IDAuthentication,buf,len);
-  buf = writeString(init->ImplementationID,DT_ImplementationID,buf,len);
-  buf = writeString(init->ImplementationName,DT_ImplementationName,buf,len);
-  buf = writeString(init->ImplementationVersion,DT_ImplementationVersion,buf,len);
-  buf = writeAny(init->ReferenceID,DT_ReferenceID,buf,len);
-
-  /* go back and write the header-length-indicator */
-  RELEASE_HEADER_SPACE(len);
-  size = buf - buffer - HEADER_LEN;
-  writeBinaryInteger(size,HEADER_LEN,buffer,len);
-
-  if (init->UserInformationField != NULL)
-    buf = writeInitResponseInfo(init,buf,len);
-
-  return(buf);
-}
-
-/*----------------------------------------------------------------------*/
-
-char*
-readInitResponseAPDU(InitResponseAPDU** init, char* buffer)
-{
-  char* buf = buffer;
-  boolean search,present,delete,accessControl,resourceControl;
-  long prefSize,maxMsgSize;
-  char *auth,*id,*name,*version;
-  long size;
-  pdu_type pduType;
-  bit_map* versionBM = NULL;
-  bit_map* optionsBM = NULL;
-  boolean result;
-  any *refID = NULL;
-  void* userInfo = NULL;
-
-  auth = id = name = version = NULL;
-  refID = NULL;
-
-  /* read required part */
-  buf = readBinaryInteger(&size,HEADER_LEN,buf);
-  buf = readPDUType(&pduType,buf);
-  buf = readBoolean(&result,buf);
-  buf = readBitMap(&versionBM,buf);
-  buf = readBitMap(&optionsBM,buf);
-  buf = readNum(&prefSize,buf);
-  buf = readNum(&maxMsgSize,buf);
-
-  /* decode optionsBM */
-  search = bitAtPos(0,optionsBM);
-  present = bitAtPos(1,optionsBM);
-  delete = bitAtPos(2,optionsBM);
-  accessControl = bitAtPos(3,optionsBM);
-  resourceControl = bitAtPos(4,optionsBM);
-
-  /* read optional part */
-  while (buf < (buffer + size + HEADER_LEN))
-    { data_tag tag = peekTag(buf);
-      switch (tag)
-	{ case DT_IDAuthentication:
-	    buf = readString(&auth,buf);
+    char *buf = buffer + HEADER_LEN;	/* leave room for the header-length-indicator */
+    long size;
+    bit_map *optionsBM = NULL;
+
+    RESERVE_SPACE_FOR_HEADER(len);
+
+    buf = writePDUType(init->PDUType, buf, len);
+    buf = writeBoolean(init->Result, buf, len);
+    buf = writeProtocolVersion(buf, len);
+
+    optionsBM = makeBitMap((unsigned long) 5, init->willSearch, init->willPresent,
+			   init->willDelete, init->supportAccessControl,
+			   init->supportResourceControl);
+    buf = writeBitMap(optionsBM, DT_Options, buf, len);
+    freeBitMap(optionsBM);
+
+    buf = writeNum(init->PreferredMessageSize,
+		   DT_PreferredMessageSize,
+		   buf,
+		   len);
+    buf = writeNum(init->MaximumRecordSize,
+		   DT_MaximumRecordSize,
+		   buf,
+		   len);
+    buf = writeString(init->IDAuthentication,
+		      DT_IDAuthentication,
+		      buf,
+		      len);
+    buf = writeString(init->ImplementationID,
+		      DT_ImplementationID,
+		      buf,
+		      len);
+    buf = writeString(init->ImplementationName,
+		      DT_ImplementationName,
+		      buf,
+		      len);
+    buf = writeString(init->ImplementationVersion,
+		      DT_ImplementationVersion,
+		      buf,
+		      len);
+    buf = writeAny(init->ReferenceID,
+		   DT_ReferenceID,
+		   buf,
+		   len);
+
+    /* go back and write the header-length-indicator */
+    RELEASE_HEADER_SPACE(len);
+    size = buf - buffer - HEADER_LEN;
+    writeBinaryInteger(size, HEADER_LEN, buffer, len);
+
+    if (init->UserInformationField != NULL)
+	buf = writeInitResponseInfo(init, buf, len);
+
+    return (buf);
+}
+
+/*----------------------------------------------------------------------*/
+
+char *readInitResponseAPDU(InitResponseAPDU **init, char *buffer)
+{
+    char *buf = buffer;
+    boolean search, present, delete, accessControl, resourceControl;
+    long prefSize, maxMsgSize;
+    char *auth, *id, *name, *version;
+    long size;
+    pdu_type pduType;
+    bit_map *versionBM = NULL;
+    bit_map *optionsBM = NULL;
+    boolean result;
+    any *refID = NULL;
+    void *userInfo = NULL;
+
+    auth = id = name = version = NULL;
+    refID = NULL;
+
+    /* read required part */
+    buf = readBinaryInteger(&size, HEADER_LEN, buf);
+    buf = readPDUType(&pduType, buf);
+    buf = readBoolean(&result, buf);
+    buf = readBitMap(&versionBM, buf);
+    buf = readBitMap(&optionsBM, buf);
+    buf = readNum(&prefSize, buf);
+    buf = readNum(&maxMsgSize, buf);
+
+    /* decode optionsBM */
+    search = bitAtPos(0, optionsBM);
+    present = bitAtPos(1, optionsBM);
+    delete = bitAtPos(2, optionsBM);
+    accessControl = bitAtPos(3, optionsBM);
+    resourceControl = bitAtPos(4, optionsBM);
+
+    /* read optional part */
+    while (buf < (buffer + size + HEADER_LEN)) {
+	data_tag tag = peekTag(buf);
+
+	switch (tag) {
+	case DT_IDAuthentication:
+	    buf = readString(&auth, buf);
 	    break;
-	  case DT_ImplementationID:
-	    buf = readString(&id,buf);
+	case DT_ImplementationID:
+	    buf = readString(&id, buf);
 	    break;
-	  case DT_ImplementationName:
-	    buf = readString(&name,buf);
+	case DT_ImplementationName:
+	    buf = readString(&name, buf);
 	    break;
-	  case DT_ImplementationVersion:
-	    buf = readString(&version,buf);
+	case DT_ImplementationVersion:
+	    buf = readString(&version, buf);
 	    break;
-	  case DT_ReferenceID:
-	    buf = readAny(&refID,buf);
+	case DT_ReferenceID:
+	    buf = readAny(&refID, buf);
 	    break;
-	  default:
+	default:
 	    freeBitMap(versionBM);
 	    freeBitMap(optionsBM);
 	    s_free(auth);
@@ -575,123 +590,150 @@
 	    freeAny(refID);
 	    REPORT_READ_ERROR(buf);
 	    break;
-	  }
-    }
-
-  buf = readInitResponseInfo(&userInfo,buf);
-  if (buf == NULL)
-    { freeBitMap(versionBM);
-      freeBitMap(optionsBM);
-      s_free(auth);
-      s_free(id);
-      s_free(name);
-      s_free(version);
-      freeAny(refID);
+	}
     }
-  RETURN_ON_NULL(buf);
 
-  /* construct the basic init object */
-  *init = makeInitResponseAPDU(result,
-			       search,present,delete,accessControl,resourceControl,
-			       prefSize,maxMsgSize,auth,id,name,version,refID,userInfo);
-
-  freeBitMap(versionBM);
-  freeBitMap(optionsBM);
-  s_free(auth);
-  s_free(id);
-  s_free(name);
-  s_free(version);
-  freeAny(refID);
+    buf = readInitResponseInfo(&userInfo, buf);
+    if (buf == NULL) {
+	freeBitMap(versionBM);
+	freeBitMap(optionsBM);
+	s_free(auth);
+	s_free(id);
+	s_free(name);
+	s_free(version);
+	freeAny(refID);
+    }
+    RETURN_ON_NULL(buf);
+
+    /* construct the basic init object */
+    *init = makeInitResponseAPDU(result,
+				 search,
+				 present,
+				 delete,
+				 accessControl,
+				 resourceControl,
+				 prefSize,
+				 maxMsgSize,
+				 auth,
+				 id,
+				 name,
+				 version,
+				 refID,
+				 userInfo);
+
+    freeBitMap(versionBM);
+    freeBitMap(optionsBM);
+    s_free(auth);
+    s_free(id);
+    s_free(name);
+    s_free(version);
+    freeAny(refID);
 
-  return(buf);
+    return (buf);
 }
 
 /*----------------------------------------------------------------------*/
 
-InitResponseAPDU*
-replyToInitAPDU(InitAPDU* init, boolean result, void* userInfo)
+InitResponseAPDU *replyToInitAPDU(InitAPDU * init, boolean result, void *userInfo)
 /* respond to an init message in the default way - echoing back
    the init info
  */
 {
-  InitResponseAPDU* initResp;
-  initResp = makeInitResponseAPDU(result,
-				  init->willSearch,init->willPresent,init->willDelete,
-				  init->supportAccessControl,init->supportResourceControl,
-				  init->PreferredMessageSize,init->MaximumRecordSize,
-				  init->IDAuthentication,defaultImplementationID(),defaultImplementationName(),
-				  defaultImplementationVersion(),
-				  init->ReferenceID,userInfo);
-  return(initResp);
+    InitResponseAPDU *initResp;
+
+    initResp = makeInitResponseAPDU(result,
+				    init->willSearch,
+				    init->willPresent,
+				    init->willDelete,
+				    init->supportAccessControl,
+				    init->supportResourceControl,
+				    init->PreferredMessageSize,
+				    init->MaximumRecordSize,
+				    init->IDAuthentication,
+				    defaultImplementationID(),
+				    defaultImplementationName(),
+				    defaultImplementationVersion(),
+				    init->ReferenceID,
+				    userInfo);
+    return (initResp);
 }
 
 /*----------------------------------------------------------------------*/
 
-SearchAPDU*
-makeSearchAPDU(
-long small,
-long large,
-long medium,
-boolean replace,
-char* name,
-char** databases,
-char* type,
-char** elements,
-any* refID,
-void* queryInfo)
-{
-  char* ptr = NULL;
-  long i;
-  SearchAPDU* query = (SearchAPDU*)s_malloc((size_t)sizeof(SearchAPDU));
-  query->PDUType = searchAPDU;
-  query->SmallSetUpperBound = small;
-  query->LargeSetLowerBound = large;
-  query->MediumSetPresentNumber = medium;
-  query->ReplaceIndicator = replace;
-  query->ResultSetName = s_strdup(name);
-  query->DatabaseNames = NULL;
-  if (databases != NULL) {
-    for (i = 0, ptr = databases[i]; ptr != NULL; ptr = databases[++i]) {
-	if (query->DatabaseNames == NULL)
-	    query->DatabaseNames = (char**)s_malloc((size_t)(sizeof(char*) * 2));
-        else
-          query->DatabaseNames = (char**)s_realloc((char*)query->DatabaseNames,
-						   (size_t)(sizeof(char*) * (i + 2)));
+SearchAPDU *makeSearchAPDU(long small,
+			   long large,
+			   long medium,
+			   boolean replace,
+			   char *name,
+			   char **databases,
+			   char *type,
+			   char **elements,
+			   any *refID,
+			   void *queryInfo)
+{
+    char *ptr = NULL;
+    long i;
+    SearchAPDU *query = (SearchAPDU *) s_malloc((size_t) sizeof(SearchAPDU));
+
+    query->PDUType = searchAPDU;
+    query->SmallSetUpperBound = small;
+    query->LargeSetLowerBound = large;
+    query->MediumSetPresentNumber = medium;
+    query->ReplaceIndicator = replace;
+    query->ResultSetName = s_strdup(name);
+    query->DatabaseNames = NULL;
+    if (databases != NULL) {
+	for (i = 0, ptr = databases[i]; ptr != NULL; ptr = databases[++i]) {
+	    if (query->DatabaseNames == NULL)
+		query->DatabaseNames = (char **) s_malloc((size_t) (sizeof(char
+									   *)
+								    * 2));
+
+	    else
+		query->DatabaseNames = (char **) s_realloc((char *) query->DatabaseNames,
+							   (size_t) (sizeof(char
+									    *) *
+								       (i + 2)));
+
 	    query->DatabaseNames[i] = s_strdup(ptr);
-	    query->DatabaseNames[i+1] = NULL;
+	    query->DatabaseNames[i + 1] = NULL;
 	}
     }
-  query->QueryType = s_strdup(type);
-  query->ElementSetNames = NULL;
-  if (elements != NULL) {
-    for (i = 0, ptr = elements[i]; ptr != NULL; ptr = elements[++i]) {
-	if (query->ElementSetNames == NULL)
-	    query->ElementSetNames = (char**)s_malloc((size_t)(sizeof(char*) * 2));
-        else
-          query->ElementSetNames = (char**)s_realloc((char*)query->ElementSetNames,
-						     (size_t)(sizeof(char*) * (i + 2)));
+    query->QueryType = s_strdup(type);
+    query->ElementSetNames = NULL;
+    if (elements != NULL) {
+	for (i = 0, ptr = elements[i]; ptr != NULL; ptr = elements[++i]) {
+	    if (query->ElementSetNames == NULL)
+		query->ElementSetNames =
+		    (char **) s_malloc((size_t) (sizeof(char *) * 2));
+
+	    else
+		query->ElementSetNames = (char **) s_realloc((char *) query->ElementSetNames,
+							     (size_t) (sizeof(char
+									      *) *
+								         (i + 2)));
+
 	    query->ElementSetNames[i] = s_strdup(ptr);
-	    query->ElementSetNames[i+1] = NULL;
-	  }
-      }
-  query->ReferenceID = duplicateAny(refID);
-  query->Query = queryInfo;	/* not copied! */
-  return(query);
+	    query->ElementSetNames[i + 1] = NULL;
+	}
+    }
+    query->ReferenceID = duplicateAny(refID);
+    query->Query = queryInfo;	/* not copied! */
+    return (query);
 }
 
 /*----------------------------------------------------------------------*/
 
-void
-freeSearchAPDU(SearchAPDU* query)
-{
-  s_free(query->ResultSetName);
-  s_free(query->QueryType);
-  doList((void**)query->DatabaseNames,fs_free); /* can't use the macro here ! */
-  s_free(query->DatabaseNames);
-  doList((void**)query->ElementSetNames,fs_free); /* can't use the macro here ! */
-  s_free(query->ElementSetNames);
-  freeAny(query->ReferenceID);
-  s_free(query);
+void freeSearchAPDU(SearchAPDU *query)
+{
+    s_free(query->ResultSetName);
+    s_free(query->QueryType);
+    doList((void **) query->DatabaseNames, fs_free);	/* can't use the macro here ! */
+    s_free(query->DatabaseNames);
+    doList((void **) query->ElementSetNames, fs_free);	/* can't use the macro here ! */
+    s_free(query->ElementSetNames);
+    freeAny(query->ReferenceID);
+    s_free(query);
 }
 
 /*----------------------------------------------------------------------*/
@@ -700,224 +742,262 @@
 #define ES_DELIMITER_1	"\037"	/* separates database name from element name */
 #define ES_DELIMITER_2	"\036"	/* hex 1E separates <db,es> groups from one another */
 
-char*
-writeSearchAPDU(SearchAPDU* query, char* buffer, long* len)
+char *writeSearchAPDU(SearchAPDU *query, char *buffer, long *len)
 {
-  char* buf = buffer + HEADER_LEN; /* leave room for the header-length-indicator */
-  long size,i;
-  char* ptr = NULL;
-  char* scratch = NULL;
-
-  RESERVE_SPACE_FOR_HEADER(len);
-
-  buf = writePDUType(query->PDUType,buf,len);
-  buf = writeBinaryInteger(query->SmallSetUpperBound,(size_t)3,buf,len);
-  buf = writeBinaryInteger(query->LargeSetLowerBound,(size_t)3,buf,len);
-  buf = writeBinaryInteger(query->MediumSetPresentNumber,(size_t)3,buf,len);
-  buf = writeBoolean(query->ReplaceIndicator,buf,len);
-  buf = writeString(query->ResultSetName,DT_ResultSetName,buf,len);
-  /* write database names */
-  if (query->DatabaseNames != NULL) {
-    for (i = 0,scratch = NULL, ptr = query->DatabaseNames[i]; ptr != NULL; ptr = query->DatabaseNames[++i]) {
-	if (scratch == NULL)
-	    scratch = s_strdup(ptr);
-        else
-	  { size_t newScratchSize = (size_t)(strlen(scratch) + strlen(ptr) + 2);
-	    scratch = (char*)s_realloc(scratch,newScratchSize);
-	    s_strncat(scratch,DB_DELIMITER,2,newScratchSize);
-	    s_strncat(scratch,ptr,strlen(ptr) + 1,newScratchSize);
-	  }
+    char *buf = buffer + HEADER_LEN;	/* leave room for the header-length-indicator */
+    long size, i;
+    char *ptr = NULL;
+    char *scratch = NULL;
+
+    RESERVE_SPACE_FOR_HEADER(len);
+
+    buf = writePDUType(query->PDUType, buf, len);
+    buf = writeBinaryInteger(query->SmallSetUpperBound, (size_t) 3, buf, len);
+    buf = writeBinaryInteger(query->LargeSetLowerBound, (size_t) 3, buf, len);
+    buf = writeBinaryInteger(query->MediumSetPresentNumber, (size_t) 3, buf, len);
+    buf = writeBoolean(query->ReplaceIndicator, buf, len);
+    buf = writeString(query->ResultSetName, DT_ResultSetName, buf, len);
+    /* write database names */
+    if (query->DatabaseNames != NULL) {
+	for (i = 0, scratch = NULL, ptr = query->DatabaseNames[i]; ptr != NULL;
+	     ptr = query->DatabaseNames[++i]) {
+	    if (scratch == NULL)
+		scratch = s_strdup(ptr);
+	    else {
+		size_t newScratchSize = (size_t) (strlen(scratch) +
+						  strlen(ptr) + 2);
+
+		scratch = (char *) s_realloc(scratch, newScratchSize);
+		s_strncat(scratch, DB_DELIMITER, 2, newScratchSize);
+		s_strncat(scratch, ptr, strlen(ptr) + 1, newScratchSize);
+	    }
 	}
-	buf = writeString(scratch,DT_DatabaseNames,buf,len);
+	buf = writeString(scratch, DT_DatabaseNames, buf, len);
 	s_free(scratch);
-      }
-  buf = writeString(query->QueryType,DT_QueryType,buf,len);
-  /* write element set names */
-  if (query->ElementSetNames != NULL) {
-    for (i = 0,scratch = NULL, ptr = query->ElementSetNames[i]; ptr != NULL; ptr = query->ElementSetNames[++i]) {
-	if (scratch == NULL) {
-	    if (query->ElementSetNames[i+1] == NULL) /* there is a single element set name */
-		{ scratch = (char*)s_malloc((size_t)strlen(ptr) + 2);
-		  strncpy(scratch,ES_DELIMITER_1,2);
-		  s_strncat(scratch,ptr,strlen(ptr) + 1,strlen(ptr) + 2);
+    }
+    buf = writeString(query->QueryType, DT_QueryType, buf, len);
+    /* write element set names */
+    if (query->ElementSetNames != NULL) {
+	for (i = 0, scratch = NULL, ptr = query->ElementSetNames[i];
+	     ptr != NULL;
+	     ptr = query->ElementSetNames[++i]) {
+	    if (scratch == NULL) {
+		if (query->ElementSetNames[i + 1] == NULL)	/* there is a single element set name */
+		{
+		    scratch = (char *) s_malloc((size_t) strlen(ptr) + 2);
+		    strncpy(scratch, ES_DELIMITER_1, 2);
+		    s_strncat(scratch, ptr, strlen(ptr) + 1, strlen(ptr) + 2);
+		} else {	/* this is the first of a series of element set names */
+		    size_t newScratchSize = (size_t) (strlen(ptr) +
+						      strlen(query->ElementSetNames[i
+										    + 1])
+						      + 2);
+
+		    scratch = s_strdup(ptr);	/* the database name */
+		    ptr = query->ElementSetNames[++i];	/* the element set name */
+		    scratch = (char *) s_realloc(scratch, newScratchSize);
+		    s_strncat(scratch, ES_DELIMITER_1, 2, newScratchSize);
+		    s_strncat(scratch, ptr, strlen(ptr) + 1, newScratchSize);
 		}
-	    else		/* this is the first of a series of element set names */
-	      { size_t newScratchSize = (size_t)(strlen(ptr) + strlen(query->ElementSetNames[i + 1]) + 2);
-		scratch = s_strdup(ptr); /* the database name */
-		ptr = query->ElementSetNames[++i]; /* the element set name */
-		scratch = (char*)s_realloc(scratch,newScratchSize);
-		s_strncat(scratch,ES_DELIMITER_1,2,newScratchSize);
-		s_strncat(scratch,ptr,strlen(ptr) + 1,newScratchSize);
-	      }
-	  }
-        else
-	  { char* esPtr = query->ElementSetNames[++i]; /* the element set name */
-	    size_t newScratchSize = (size_t)(strlen(scratch) + strlen(ptr) + strlen(esPtr) + 3);
-	    scratch = (char*)s_realloc(scratch,newScratchSize);
-	    s_strncat(scratch,ES_DELIMITER_2,2,newScratchSize);
-	    s_strncat(scratch,ptr,strlen(ptr) + 1,newScratchSize);
-	    s_strncat(scratch,ES_DELIMITER_1,2,newScratchSize);
-	    s_strncat(scratch,esPtr,strlen(esPtr) + 1,newScratchSize);
-	  }
-	  }
-	buf = writeString(scratch,DT_ElementSetNames,buf,len);
+	    } else {
+		char *esPtr = query->ElementSetNames[++i];	/* the element set name */
+		size_t newScratchSize = (size_t) (strlen(scratch) +
+						  strlen(ptr) +
+						  strlen(esPtr) +
+						  3);
+
+		scratch = (char *) s_realloc(scratch, newScratchSize);
+		s_strncat(scratch, ES_DELIMITER_2, 2, newScratchSize);
+		s_strncat(scratch, ptr, strlen(ptr) + 1, newScratchSize);
+		s_strncat(scratch, ES_DELIMITER_1, 2, newScratchSize);
+		s_strncat(scratch, esPtr, strlen(esPtr) + 1, newScratchSize);
+	    }
+	}
+	buf = writeString(scratch, DT_ElementSetNames, buf, len);
 	s_free(scratch);
-      }
-  buf = writeAny(query->ReferenceID,DT_ReferenceID,buf,len);
+    }
+    buf = writeAny(query->ReferenceID, DT_ReferenceID, buf, len);
 
-  /* go back and write the header-length-indicator */
-  RELEASE_HEADER_SPACE(len);
-  size = buf - buffer - HEADER_LEN;
-  writeBinaryInteger(size,HEADER_LEN,buffer,len);
+    /* go back and write the header-length-indicator */
+    RELEASE_HEADER_SPACE(len);
+    size = buf - buffer - HEADER_LEN;
+    writeBinaryInteger(size, HEADER_LEN, buffer, len);
 
-  if (query->Query != NULL)
-    buf = writeSearchInfo(query,buf,len);
+    if (query->Query != NULL)
+	buf = writeSearchInfo(query, buf, len);
 
-  return(buf);
+    return (buf);
 }
 
 /*----------------------------------------------------------------------*/
 
-SearchResponseAPDU*
-makeSearchResponseAPDU(
-long result,
-long count,
-long recordsReturned,
-long nextPos,
-long resultStatus,
-long presentStatus,
-any* refID,
-void* records)
+SearchResponseAPDU *makeSearchResponseAPDU(long result,
+					   long count,
+					   long recordsReturned,
+					   long nextPos,
+					   long resultStatus,
+					   long presentStatus,
+					   any *refID,
+					   void *records)
 {
-  SearchResponseAPDU* query = (SearchResponseAPDU*)s_malloc((size_t)sizeof(SearchResponseAPDU));
-  query->PDUType = searchResponseAPDU;
-  query->SearchStatus = result;
-  query->ResultCount = count;
-  query->NumberOfRecordsReturned = recordsReturned;
-  query->NextResultSetPosition = nextPos;
-  query->ResultSetStatus = resultStatus;
-  query->PresentStatus = presentStatus;
-  query->ReferenceID = duplicateAny(refID);
-  query->DatabaseDiagnosticRecords = records;
-  return(query);
+    SearchResponseAPDU *query =
+    (SearchResponseAPDU *) s_malloc((size_t) sizeof(SearchResponseAPDU));
+
+    query->PDUType = searchResponseAPDU;
+    query->SearchStatus = result;
+    query->ResultCount = count;
+    query->NumberOfRecordsReturned = recordsReturned;
+    query->NextResultSetPosition = nextPos;
+    query->ResultSetStatus = resultStatus;
+    query->PresentStatus = presentStatus;
+    query->ReferenceID = duplicateAny(refID);
+    query->DatabaseDiagnosticRecords = records;
+    return (query);
 }
 
 /*----------------------------------------------------------------------*/
 
-void
-freeSearchResponseAPDU(SearchResponseAPDU* queryResponse)
+void freeSearchResponseAPDU(SearchResponseAPDU *queryResponse)
 {
-  freeAny(queryResponse->ReferenceID);
-  s_free(queryResponse);
+    freeAny(queryResponse->ReferenceID);
+    s_free(queryResponse);
 }
 
 /*----------------------------------------------------------------------*/
 
-char*
-writeSearchResponseAPDU(SearchResponseAPDU* queryResponse, char* buffer, long* len)
+char *writeSearchResponseAPDU(SearchResponseAPDU *queryResponse, char *buffer,
+			      long *len)
 {
-  char* buf = buffer + HEADER_LEN; /* leave room for the header-length-indicator */
-  long size;
+    char *buf = buffer + HEADER_LEN;	/* leave room for the header-length-indicator */
+    long size;
 
-  RESERVE_SPACE_FOR_HEADER(len);
+    RESERVE_SPACE_FOR_HEADER(len);
 
-  buf = writePDUType(queryResponse->PDUType,buf,len);
-  buf = writeBinaryInteger(queryResponse->SearchStatus,(size_t)1,buf,len);
-  buf = writeBinaryInteger(queryResponse->ResultCount,(size_t)3,buf,len);
-  buf = writeBinaryInteger(queryResponse->NumberOfRecordsReturned,(size_t)3,buf,len);
-  buf = writeBinaryInteger(queryResponse->NextResultSetPosition,(size_t)3,buf,len);
-  buf = writeNum(queryResponse->ResultSetStatus,DT_ResultSetStatus,buf,len);
-  buf = writeNum(queryResponse->PresentStatus,DT_PresentStatus,buf,len);
-  buf = writeAny(queryResponse->ReferenceID,DT_ReferenceID,buf,len);
+    buf = writePDUType(queryResponse->PDUType,
+		       buf,
+		       len);
+    buf = writeBinaryInteger(queryResponse->SearchStatus,
+			     (size_t) 1,
+			     buf,
+			     len);
+    buf = writeBinaryInteger(queryResponse->ResultCount,
+			     (size_t) 3,
+			     buf,
+			     len);
+    buf = writeBinaryInteger(queryResponse->NumberOfRecordsReturned,
+			     (size_t) 3,
+			     buf,
+			     len);
+    buf = writeBinaryInteger(queryResponse->NextResultSetPosition,
+			     (size_t) 3,
+			     buf,
+			     len);
+    buf = writeNum(queryResponse->ResultSetStatus,
+		   DT_ResultSetStatus,
+		   buf,
+		   len);
+    buf = writeNum(queryResponse->PresentStatus,
+		   DT_PresentStatus,
+		   buf,
+		   len);
+    buf = writeAny(queryResponse->ReferenceID,
+		   DT_ReferenceID,
+		   buf,
+		   len);
 
-  /* go back and write the header-length-indicator */
-  RELEASE_HEADER_SPACE(len);
-  size = buf - buffer - HEADER_LEN;
-  writeBinaryInteger(size,HEADER_LEN,buffer,len);
+    /* go back and write the header-length-indicator */
+    RELEASE_HEADER_SPACE(len);
+    size = buf - buffer - HEADER_LEN;
+    writeBinaryInteger(size, HEADER_LEN, buffer, len);
 
-  if (queryResponse->DatabaseDiagnosticRecords != NULL)
-    buf = writeSearchResponseInfo(queryResponse,buf,len);
+    if (queryResponse->DatabaseDiagnosticRecords != NULL)
+	buf = writeSearchResponseInfo(queryResponse, buf, len);
 
-  return(buf);
+    return (buf);
 }
 
 /*----------------------------------------------------------------------*/
 
-char*
-readSearchResponseAPDU(SearchResponseAPDU** queryResponse, char* buffer)
+char *readSearchResponseAPDU(SearchResponseAPDU **queryResponse, char *buffer)
 {
-  char* buf = buffer;
-  long size;
-  pdu_type pduType;
-  long result,count,recordsReturned,nextPos;
-  long resultStatus,presentStatus;
-  any *refID = NULL;
-  void* userInfo = NULL;
+    char *buf = buffer;
+    long size;
+    pdu_type pduType;
+    long result, count, recordsReturned, nextPos;
+    long resultStatus, presentStatus;
+    any *refID = NULL;
+    void *userInfo = NULL;
 
-  /* read required part */
-  buf = readBinaryInteger(&size,HEADER_LEN,buf);
-  buf = readPDUType(&pduType,buf);
-  buf = readBinaryInteger(&result,(size_t)1,buf);
-  buf = readBinaryInteger(&count,(size_t)3,buf);
-  buf = readBinaryInteger(&recordsReturned,(size_t)3,buf);
-  buf = readBinaryInteger(&nextPos,(size_t)3,buf);
+    /* read required part */
+    buf = readBinaryInteger(&size, HEADER_LEN, buf);
+    buf = readPDUType(&pduType, buf);
+    buf = readBinaryInteger(&result, (size_t) 1, buf);
+    buf = readBinaryInteger(&count, (size_t) 3, buf);
+    buf = readBinaryInteger(&recordsReturned, (size_t) 3, buf);
+    buf = readBinaryInteger(&nextPos, (size_t) 3, buf);
 
-  resultStatus = presentStatus = UNUSED;
-  refID = NULL;
+    resultStatus = presentStatus = UNUSED;
+    refID = NULL;
 
-  /* read optional part */
-  while (buf < (buffer + size + HEADER_LEN))
-    { data_tag tag = peekTag(buf);
-      switch (tag)
-	{ case DT_ResultSetStatus:
-	    buf = readNum(&resultStatus,buf);
+    /* read optional part */
+    while (buf < (buffer + size + HEADER_LEN)) {
+	data_tag tag = peekTag(buf);
+
+	switch (tag) {
+	case DT_ResultSetStatus:
+	    buf = readNum(&resultStatus, buf);
 	    break;
-	  case DT_PresentStatus:
-	    buf = readNum(&presentStatus,buf);
+	case DT_PresentStatus:
+	    buf = readNum(&presentStatus, buf);
 	    break;
-	  case DT_ReferenceID:
-	    buf = readAny(&refID,buf);
+	case DT_ReferenceID:
+	    buf = readAny(&refID, buf);
 	    break;
-	  default:
+	default:
 	    freeAny(refID);
 	    REPORT_READ_ERROR(buf);
 	    break;
-	  }
+	}
     }
 
-  buf = readSearchResponseInfo(&userInfo,buf);
-  if (buf == NULL)
-    freeAny(refID);
-  RETURN_ON_NULL(buf);
-
-  /* construct the search object */
-  *queryResponse = makeSearchResponseAPDU(result,count,recordsReturned,nextPos,
-					  (long)resultStatus,(long)presentStatus,refID,userInfo);
+    buf = readSearchResponseInfo(&userInfo, buf);
+    if (buf == NULL)
+	freeAny(refID);
+    RETURN_ON_NULL(buf);
+
+    /* construct the search object */
+    *queryResponse = makeSearchResponseAPDU(result,
+					    count,
+					    recordsReturned,
+					    nextPos,
+					    (long) resultStatus,
+					    (long) presentStatus,
+					    refID,
+					    userInfo);
 
-  freeAny(refID);
+    freeAny(refID);
 
-  return(buf);
+    return (buf);
 }
 
-
 /*
-**	Routines originally from ZUtil.c -- FM
-**
-**----------------------------------------------------------------------*/
+ *	Routines originally from ZUtil.c -- FM
+ *
+ *----------------------------------------------------------------------*/
 /* WIDE AREA INFORMATION SERVER SOFTWARE:
-   No guarantees or restrictions.  See the readme file for the full standard
-   disclaimer.
-
-   3.26.90	Harry Morris, morris@think.com
-   3.30.90  Harry Morris - Changed any->bits to any->bytes
-   4.11.90  HWM - fixed include file names, changed
-		- writeCompressedIntegerWithPadding() to
-		  writeCompressedIntWithPadding()
-		- generalized conditional includes (see c-dialect.h)
-   3.7.91   Jonny Goldman.  Replaced "short" in makeBitMap with "int" line 632.
-*/
+ * No guarantees or restrictions.  See the readme file for the full standard
+ * disclaimer.
+ *
+ * 3.26.90	Harry Morris, morris@think.com
+ * 3.30.90  Harry Morris - Changed any->bits to any->bytes
+ * 4.11.90  HWM - fixed include file names, changed
+ *		- writeCompressedIntegerWithPadding() to
+ *		  writeCompressedIntWithPadding()
+ *		- generalized conditional includes (see c-dialect.h)
+ * 3.7.91   Jonny Goldman.  Replaced "short" in makeBitMap with "int" line 632.
+ */
 
-char* readErrorPosition = NULL; /* pos where buf stoped making sense */
+char *readErrorPosition = NULL;	/* pos where buf stoped making sense */
 
 /*----------------------------------------------------------------------*/
 /* A note on error handling
@@ -935,118 +1015,113 @@
  */
 /*----------------------------------------------------------------------*/
 
-diagnosticRecord*
-makeDiag(boolean surrogate, char* code, char* addInfo)
+diagnosticRecord *makeDiag(boolean surrogate, char *code, char *addInfo)
 {
-  diagnosticRecord* diag =
-    (diagnosticRecord*)s_malloc((size_t)sizeof(diagnosticRecord));
+    diagnosticRecord *diag =
+    (diagnosticRecord *) s_malloc((size_t) sizeof(diagnosticRecord));
 
-  diag->SURROGATE = surrogate;
-  memcpy(diag->DIAG,code,DIAGNOSTIC_CODE_SIZE);
-  diag->ADDINFO = s_strdup(addInfo);
+    diag->SURROGATE = surrogate;
+    memcpy(diag->DIAG, code, DIAGNOSTIC_CODE_SIZE);
+    diag->ADDINFO = s_strdup(addInfo);
 
-  return(diag);
+    return (diag);
 }
 
 /*----------------------------------------------------------------------*/
 
-void
-freeDiag(diagnosticRecord* diag)
+void freeDiag(diagnosticRecord * diag)
 {
-  if (diag != NULL) {
-    if (diag->ADDINFO != NULL)
-	s_free(diag->ADDINFO);
-    s_free(diag);
-  }
+    if (diag != NULL) {
+	if (diag->ADDINFO != NULL)
+	    s_free(diag->ADDINFO);
+	s_free(diag);
+    }
 }
 
 /*----------------------------------------------------------------------*/
 
 #define END_OF_RECORD	0x1D
 
-char*
-writeDiag(diagnosticRecord* diag, char* buffer, long* len)
+char *writeDiag(diagnosticRecord * diag, char *buffer, long *len)
 /* diagnostics (as per Appendix D) have a very weird format - this changes
    in SR-1
  */
 {
-  char* buf = buffer;
-  long  length;
+    char *buf = buffer;
+    long length;
 
-  if (diag == NULL)		/* handle unspecified optional args */
-    return(buf);
+    if (diag == NULL)		/* handle unspecified optional args */
+	return (buf);
 
-  buf = writeTag(DT_DatabaseDiagnosticRecords,buf,len);
-  CHECK_FOR_SPACE_LEFT(0,len);
+    buf = writeTag(DT_DatabaseDiagnosticRecords, buf, len);
+    CHECK_FOR_SPACE_LEFT(0, len);
 
-  length = 3;
-  if (diag->ADDINFO != NULL)
-    length += strlen(diag->ADDINFO);
+    length = 3;
+    if (diag->ADDINFO != NULL)
+	length += strlen(diag->ADDINFO);
 
-  if (length >= 0xFFFF )	/* make sure the length is reasonable */
-    { length = 0xFFFF - 1;
-      diag->ADDINFO[0xFFFF - 3 - 1] = '\0';
+    if (length >= 0xFFFF)	/* make sure the length is reasonable */
+    {
+	length = 0xFFFF - 1;
+	diag->ADDINFO[0xFFFF - 3 - 1] = '\0';
     }
 
-  buf = writeBinaryInteger(length,2,buf,len);
+    buf = writeBinaryInteger(length, 2, buf, len);
 
-  CHECK_FOR_SPACE_LEFT(1,len);
-  buf[0] = diag->DIAG[0];
-  buf++;
+    CHECK_FOR_SPACE_LEFT(1, len);
+    buf[0] = diag->DIAG[0];
+    buf++;
 
-  CHECK_FOR_SPACE_LEFT(1,len);
-  buf[0] = diag->DIAG[1];
-  buf++;
+    CHECK_FOR_SPACE_LEFT(1, len);
+    buf[0] = diag->DIAG[1];
+    buf++;
 
-  if (length > 3)
-    { CHECK_FOR_SPACE_LEFT(3,len);
-      memcpy(buf,diag->ADDINFO,(size_t)length - 3);
-      buf += length - 3;
+    if (length > 3) {
+	CHECK_FOR_SPACE_LEFT(3, len);
+	memcpy(buf, diag->ADDINFO, (size_t) length - 3);
+	buf += length - 3;
     }
 
-  CHECK_FOR_SPACE_LEFT(1,len);
-  buf[0] = diag->SURROGATE;
-  buf++;
+    CHECK_FOR_SPACE_LEFT(1, len);
+    buf[0] = diag->SURROGATE;
+    buf++;
 
-  CHECK_FOR_SPACE_LEFT(1,len);
-  buf[0] = END_OF_RECORD;
-  buf++;
+    CHECK_FOR_SPACE_LEFT(1, len);
+    buf[0] = END_OF_RECORD;
+    buf++;
 
-  return(buf);
+    return (buf);
 }
 
 /*----------------------------------------------------------------------*/
 
-char*
-readDiag(diagnosticRecord** diag, char* buffer)
+char *readDiag(diagnosticRecord ** diag, char *buffer)
 {
-  char* buf = buffer;
-  diagnosticRecord* d
-    = (diagnosticRecord*)s_malloc((size_t)sizeof(diagnosticRecord));
-  data_tag tag;
-  long len;
+    char *buf = buffer;
+    diagnosticRecord *d = (diagnosticRecord *) s_malloc((size_t) sizeof(diagnosticRecord));
+    data_tag tag;
+    long len;
 
-  buf = readTag(&tag,buf);
+    buf = readTag(&tag, buf);
 
-  buf = readBinaryInteger(&len,2,buf);
+    buf = readBinaryInteger(&len, 2, buf);
 
-  d->DIAG[0] = buf[0];
-  d->DIAG[1] = buf[1];
-  d->DIAG[2] = '\0';
+    d->DIAG[0] = buf[0];
+    d->DIAG[1] = buf[1];
+    d->DIAG[2] = '\0';
 
-  if (len > 3)
-    { d->ADDINFO = (char*)s_malloc((size_t)(len - 3 + 1));
-      memcpy(d->ADDINFO,(char*)(buf + 2),(size_t)(len - 3));
-      d->ADDINFO[len - 3] = '\0';
-    }
-  else
-    d->ADDINFO = NULL;
+    if (len > 3) {
+	d->ADDINFO = (char *) s_malloc((size_t) (len - 3 + 1));
+	memcpy(d->ADDINFO, (char *) (buf + 2), (size_t) (len - 3));
+	d->ADDINFO[len - 3] = '\0';
+    } else
+	d->ADDINFO = NULL;
 
-  d->SURROGATE = buf[len - 1];
+    d->SURROGATE = buf[len - 1];
 
-  *diag = d;
+    *diag = d;
 
-  return(buf + len + 1);
+    return (buf + len + 1);
 }
 
 /*----------------------------------------------------------------------*/
@@ -1055,417 +1130,404 @@
 #define dataMask	0x7F
 #define dataBits	7
 
-char*
-writeCompressedInteger(unsigned long num, char* buf, long* len)
+char *writeCompressedInteger(unsigned long num, char *buf, long *len)
 /* write a binary integer in the format described on p. 40.
    this might be sped up
 */
 {
-  char byte;
-  unsigned long i;
-  unsigned long size;
+    char byte;
+    unsigned long i;
+    unsigned long size;
 
-  size = writtenCompressedIntSize(num);
-  CHECK_FOR_SPACE_LEFT(size,len);
+    size = writtenCompressedIntSize(num);
+    CHECK_FOR_SPACE_LEFT(size, len);
 
-  for (i = size - 1; i != 0; i--)
-    { byte = num & dataMask;
-      if (i != (size-1))	/* turn on continue bit */
-	byte = (char)(byte | continueBit);
-      buf[i] = byte;
-      num = num >> dataBits;	/* don't and here */
+    for (i = size - 1; i != 0; i--) {
+	byte = num & dataMask;
+	if (i != (size - 1))	/* turn on continue bit */
+	    byte = (char) (byte | continueBit);
+	buf[i] = byte;
+	num = num >> dataBits;	/* don't and here */
     }
 
-  return(buf + size);
+    return (buf + size);
 }
 
 /*----------------------------------------------------------------------*/
 
-char*
-readCompressedInteger(unsigned long *num, char* buf)
+char *readCompressedInteger(unsigned long *num, char *buf)
 /* read a binary integer in the format described on p. 40.
    this might be sped up
 */
 {
-  long i = 0;
-  unsigned char byte;
+    long i = 0;
+    unsigned char byte;
 
-  *num = 0;
+    *num = 0;
 
-  do
-    { byte = buf[i++];
-      *num = *num << dataBits;
-      *num += (byte & dataMask);
+    do {
+	byte = buf[i++];
+	*num = *num << dataBits;
+	*num += (byte & dataMask);
     }
-  while (byte & continueBit);
+    while (byte & continueBit);
 
-  return(buf + i);
+    return (buf + i);
 }
 
 /*----------------------------------------------------------------------*/
 
-#define pad	128 /* high bit is set */
+#define pad	128		/* high bit is set */
 
-char*
-writeCompressedIntWithPadding(
-unsigned long num,
-unsigned long size,
-char* buffer,
-long* len)
+char *writeCompressedIntWithPadding(unsigned long num,
+				    unsigned long size,
+				    char *buffer,
+				    long *len)
 /* Like writeCompressedInteger, except writes padding (128) to make
    sure that size bytes are used.  This can be read correctly by
    readCompressedInteger()
 */
 {
-  char* buf = buffer;
-  unsigned long needed,padding;
-  long i;
+    char *buf = buffer;
+    unsigned long needed, padding;
+    long i;
 
-  CHECK_FOR_SPACE_LEFT(size,len);
+    CHECK_FOR_SPACE_LEFT(size, len);
 
-  needed = writtenCompressedIntSize(num);
-  padding = size - needed;
-  i = padding - 1;
+    needed = writtenCompressedIntSize(num);
+    padding = size - needed;
+    i = padding - 1;
 
-  for (i = padding - 1;i >= 0;i--)
-    { buf[i] = pad;
+    for (i = padding - 1; i >= 0; i--) {
+	buf[i] = pad;
     }
 
-  buf = writeCompressedInteger(num,buf + padding,len);
+    buf = writeCompressedInteger(num, buf + padding, len);
 
-  return(buf);
+    return (buf);
 }
 
 /*----------------------------------------------------------------------*/
 
-unsigned long
-writtenCompressedIntSize(unsigned long num)
+unsigned long writtenCompressedIntSize(unsigned long num)
 /* return the number of bytes needed to represnet the value num in
    compressed format.  curently limited to 4 bytes
  */
 {
-  if (num < CompressedInt1Byte)
-    return(1);
-  else if (num < CompressedInt2Byte)
-    return(2);
-  else if (num < CompressedInt3Byte)
-    return(3);
-  else
-    return(4);
+    if (num < CompressedInt1Byte)
+	return (1);
+    else if (num < CompressedInt2Byte)
+	return (2);
+    else if (num < CompressedInt3Byte)
+	return (3);
+    else
+	return (4);
 }
 
 /*----------------------------------------------------------------------*/
 
-char*
-writeTag(data_tag tag, char* buf, long* len)
+char *writeTag(data_tag tag, char *buf, long *len)
 /* write out a data tag */
 {
-  return(writeCompressedInteger(tag,buf,len));
+    return (writeCompressedInteger(tag, buf, len));
 }
 
 /*----------------------------------------------------------------------*/
 
-char*
-readTag(data_tag* tag, char* buf)
+char *readTag(data_tag *tag, char *buf)
 /* read a data tag */
 {
-  return(readCompressedInteger(tag,buf));
+    return (readCompressedInteger(tag, buf));
 }
 
 /*----------------------------------------------------------------------*/
 
-unsigned long
-writtenTagSize(data_tag tag)
+unsigned long writtenTagSize(data_tag tag)
 {
-  return(writtenCompressedIntSize(tag));
+    return (writtenCompressedIntSize(tag));
 }
 
 /*----------------------------------------------------------------------*/
 
-data_tag
-peekTag(char* buf)
+data_tag peekTag(char *buf)
 /* read a data tag without advancing the buffer */
 {
-  data_tag tag;
-  readTag(&tag,buf);
-  return(tag);
+    data_tag tag;
+
+    readTag(&tag, buf);
+    return (tag);
 }
 
 /*----------------------------------------------------------------------*/
 
-any*
-makeAny(unsigned long size, char* data)
+any *makeAny(unsigned long size, char *data)
 {
-  any* a = (any*)s_malloc((size_t)sizeof(any));
-  a->size = size;
-  a->bytes = data;
-  return(a);
+    any *a = (any *) s_malloc((size_t) sizeof(any));
+
+    a->size = size;
+    a->bytes = data;
+    return (a);
 }
 
 /*----------------------------------------------------------------------*/
 
-void
-freeAny(any* a)
+void freeAny(any *a)
 /* destroy an any and its associated data.  Assumes a->bytes was
    allocated using the s_malloc family of libraries
  */
 {
-  if (a != NULL)
-    { if (a->bytes != NULL)
-	s_free(a->bytes);
-      s_free(a);
+    if (a != NULL) {
+	if (a->bytes != NULL)
+	    s_free(a->bytes);
+	s_free(a);
     }
 }
 
 /*----------------------------------------------------------------------*/
 
-any*
-duplicateAny(any* a)
+any *duplicateAny(any *a)
 {
-  any* copy = NULL;
+    any *copy = NULL;
 
-  if (a == NULL)
-    return(NULL);
+    if (a == NULL)
+	return (NULL);
 
-  copy = (any*)s_malloc((size_t)sizeof(any));
-  copy->size = a->size;
-  if (a->bytes == NULL)
-    copy->bytes = NULL;
-  else
-    { copy->bytes = (char*)s_malloc((size_t)copy->size);
-      memcpy(copy->bytes,a->bytes,(size_t)copy->size);
+    copy = (any *) s_malloc((size_t) sizeof(any));
+
+    copy->size = a->size;
+    if (a->bytes == NULL)
+	copy->bytes = NULL;
+    else {
+	copy->bytes = (char *) s_malloc((size_t) copy->size);
+	memcpy(copy->bytes, a->bytes, (size_t) copy->size);
     }
-  return(copy);
+    return (copy);
 }
 
 /*----------------------------------------------------------------------*/
 
-char*
-writeAny(any* a, data_tag tag, char* buffer, long* len)
+char *writeAny(any *a, data_tag tag, char *buffer, long *len)
 /* write an any + tag and size info */
 {
-  char* buf = buffer;
+    char *buf = buffer;
 
-  if (a == NULL)		/* handle unspecified optional args */
-    return(buf);
+    if (a == NULL)		/* handle unspecified optional args */
+	return (buf);
 
-  /* write the tags */
-  buf = writeTag(tag,buf,len);
-  buf = writeCompressedInteger(a->size,buf,len);
+    /* write the tags */
+    buf = writeTag(tag, buf, len);
+    buf = writeCompressedInteger(a->size, buf, len);
 
-  /* write the bytes */
-  CHECK_FOR_SPACE_LEFT(a->size,len);
-  memcpy(buf,a->bytes,(size_t)a->size);
+    /* write the bytes */
+    CHECK_FOR_SPACE_LEFT(a->size, len);
+    memcpy(buf, a->bytes, (size_t) a->size);
 
-  return(buf+a->size);
+    return (buf + a->size);
 }
 
 /*----------------------------------------------------------------------*/
 
-
-char *readAny(any** anAny, char* buffer)
+char *readAny(any **anAny, char *buffer)
 /* read an any + tag and size info */
 {
-  char *buf;
-  any* a;
-  data_tag tag;
+    char *buf;
+    any *a;
+    data_tag tag;
 
+    a = (any *) s_malloc((size_t) sizeof(any));
 
+    buf = buffer;
 
-a=(any*)s_malloc((size_t)sizeof(any));
+    buf = readTag(&tag, buf);
 
-  buf=buffer;
+    buf = readCompressedInteger(&a->size, buf);
 
-  buf = readTag(&tag,buf);
+    /* now simply copy the bytes */
+    a->bytes = (char *) s_malloc((size_t) a->size);
+    memcpy(a->bytes, buf, (size_t) a->size);
+    *anAny = a;
 
-  buf = readCompressedInteger(&a->size,buf);
-
-  /* now simply copy the bytes */
-  a->bytes = (char*)s_malloc((size_t)a->size);
-  memcpy(a->bytes,buf,(size_t)a->size);
-  *anAny = a;
-
-  return(buf+a->size);
+    return (buf + a->size);
 }
 
 /*----------------------------------------------------------------------*/
 
-unsigned long
-writtenAnySize(data_tag tag, any* a)
+unsigned long writtenAnySize(data_tag tag, any *a)
 {
-  unsigned long size;
+    unsigned long size;
 
-  if (a == NULL)
-    return(0);
+    if (a == NULL)
+	return (0);
 
-  size = writtenTagSize(tag);
-  size += writtenCompressedIntSize(a->size);
-  size += a->size;
-  return(size);
+    size = writtenTagSize(tag);
+    size += writtenCompressedIntSize(a->size);
+    size += a->size;
+    return (size);
 }
 
 /*----------------------------------------------------------------------*/
 
-any*
-stringToAny(char* s)
+any *stringToAny(char *s)
 {
-  any* a = NULL;
+    any *a = NULL;
 
-  if (s == NULL)
-    return(NULL);
+    if (s == NULL)
+	return (NULL);
 
-  a = (any*)s_malloc((size_t)sizeof(any));
-  a->size = strlen(s);
-  a->bytes = (char*)s_malloc((size_t)a->size);
-  memcpy(a->bytes,s,(size_t)a->size);
-  return(a);
+    a = (any *) s_malloc((size_t) sizeof(any));
+
+    a->size = strlen(s);
+    a->bytes = (char *) s_malloc((size_t) a->size);
+    memcpy(a->bytes, s, (size_t) a->size);
+    return (a);
 }
 
 /*----------------------------------------------------------------------*/
 
-char*
-anyToString(any* a)
+char *anyToString(any *a)
 {
-  char* s = NULL;
+    char *s = NULL;
 
-  if (a == NULL)
-    return(NULL);
+    if (a == NULL)
+	return (NULL);
 
-  s = s_malloc((size_t)(a->size + 1));
-  memcpy(s,a->bytes,(size_t)a->size);
-  s[a->size] = '\0';
-  return(s);
+    s = s_malloc((size_t) (a->size + 1));
+    memcpy(s, a->bytes, (size_t) a->size);
+    s[a->size] = '\0';
+    return (s);
 }
 
 /*----------------------------------------------------------------------*/
 
-char*
-writeString(char* s, data_tag tag, char* buffer, long* len)
+char *writeString(char *s, data_tag tag, char *buffer, long *len)
 /* Write a C style string.  The terminating null is not written.
    This function is not part of the Z39.50 spec.  It is provided
    for the convienience of those wishing to pass C strings in
    the place of an any.
  */
 {
-  char* buf = buffer;
-  any* data = NULL;
-  if (s == NULL)
-    return(buffer);		/* handle unused optional item before making an any */
-  data = (any*)s_malloc((size_t)sizeof(any));
-  data->size = strlen(s);
-  data->bytes = s;		/* save a copy here by not using stringToAny() */
-  buf = writeAny(data,tag,buf,len);
-  s_free(data);			/* don't use freeAny() since it will free s too */
-  return(buf);
+    char *buf = buffer;
+    any *data = NULL;
+
+    if (s == NULL)
+	return (buffer);	/* handle unused optional item before making an any */
+    data = (any *) s_malloc((size_t) sizeof(any));
+
+    data->size = strlen(s);
+    data->bytes = s;		/* save a copy here by not using stringToAny() */
+    buf = writeAny(data, tag, buf, len);
+    s_free(data);		/* don't use freeAny() since it will free s too */
+    return (buf);
 }
 
 /*----------------------------------------------------------------------*/
 
-char*
-readString(char** s, char* buffer)
+char *readString(char **s, char *buffer)
 /* Read an any and convert it into a C style string.
    This function is not part of the Z39.50 spec.  It is provided
    for the convienience of those wishing to pass C strings in
    the place of an any.
  */
 {
-  any* data = NULL;
-  char* buf = readAny(&data,buffer);
-  *s = anyToString(data);
-  freeAny(data);
-  return(buf);
+    any *data = NULL;
+    char *buf = readAny(&data, buffer);
+
+    *s = anyToString(data);
+    freeAny(data);
+    return (buf);
 }
 
 /*----------------------------------------------------------------------*/
 
-unsigned long
-writtenStringSize(data_tag tag, char* s)
+unsigned long writtenStringSize(data_tag tag, char *s)
 {
-  unsigned long size;
+    unsigned long size;
 
-  if (s == NULL)
-   return(0);
+    if (s == NULL)
+	return (0);
 
-  size = writtenTagSize(tag);
-  size += writtenCompressedIntSize(size);
-  size += strlen(s);
-  return(size);
+    size = writtenTagSize(tag);
+    size += writtenCompressedIntSize(size);
+    size += strlen(s);
+    return (size);
 }
 
 /*----------------------------------------------------------------------*/
 
-any*
-longToAny(long num)
+any *longToAny(long num)
 /* a convienience function */
 {
-  char s[40];
+    char s[40];
 
-  sprintf(s,"%ld",num);
+    sprintf(s, "%ld", num);
 
-  return(stringToAny(s));
+    return (stringToAny(s));
 }
 
 /*----------------------------------------------------------------------*/
 
-long
-anyToLong(any* a)
+long anyToLong(any *a)
 /* a convienience function */
 {
-  long num;
-  char* str = NULL;
-  str = anyToString(a);
-  sscanf(str,"%ld",&num);	/* could check the result and return
+    long num;
+    char *str = NULL;
+
+    str = anyToString(a);
+    sscanf(str, "%ld", &num);	/* could check the result and return
 				   an error */
-  s_free(str);
-  return(num);
+    s_free(str);
+    return (num);
 }
 
 /*----------------------------------------------------------------------*/
 
 #define bitsPerByte	8
 
-bit_map*
-makeBitMap(unsigned long numBits, ...)
+bit_map *makeBitMap(unsigned long numBits,...)
 /* construct and return a bitmap with numBits elements */
 {
-  va_list ap;
-  unsigned long i,j;
-  bit_map* bm = NULL;
-
-  LYva_start(ap,numBits);
-
-  bm = (bit_map*)s_malloc((size_t)sizeof(bit_map));
-  bm->size = (unsigned long)(ceil((double)numBits / bitsPerByte));
-  bm->bytes = (char*)s_malloc((size_t)bm->size);
-
-  /* fill up the bits */
-  for (i = 0; i < bm->size; i++) /* iterate over bytes */
-    { char byte = 0;
-      for (j = 0; j < bitsPerByte; j++) /* iterate over bits */
-	{ if ((i * bitsPerByte + j) < numBits)
-	    { boolean bit = false;
-	      bit = (boolean)va_arg(ap,boolean);
-	      if (bit)
-	        { byte = byte | (1 << (bitsPerByte - j - 1));
-	        }
+    va_list ap;
+    unsigned long i, j;
+    bit_map *bm = NULL;
+
+    LYva_start(ap, numBits);
+
+    bm = (bit_map *) s_malloc((size_t) sizeof(bit_map));
+
+    bm->size = (unsigned long) (ceil((double) numBits / bitsPerByte));
+    bm->bytes = (char *) s_malloc((size_t) bm->size);
+
+    /* fill up the bits */
+    for (i = 0; i < bm->size; i++)	/* iterate over bytes */
+    {
+	char byte = 0;
+
+	for (j = 0; j < bitsPerByte; j++)	/* iterate over bits */
+	{
+	    if ((i * bitsPerByte + j) < numBits) {
+		boolean bit = false;
+
+		bit = (boolean) va_arg(ap, boolean);
+
+		if (bit) {
+		    byte = byte | (1 << (bitsPerByte - j - 1));
+		}
 	    }
-	  }
-      bm->bytes[i] = byte;
+	}
+	bm->bytes[i] = byte;
     }
 
-  va_end(ap);
-  return(bm);
+    va_end(ap);
+    return (bm);
 }
 
-
 /*----------------------------------------------------------------------*/
 
-void
-freeBitMap(bit_map* bm)
+void freeBitMap(bit_map *bm)
 /* destroy a bit map created by makeBitMap() */
 {
-  s_free(bm->bytes);
-  s_free(bm);
+    s_free(bm->bytes);
+    s_free(bm);
 }
 
 /*----------------------------------------------------------------------*/
@@ -1475,386 +1537,367 @@
    Could do bounds checking.
  */
 
-boolean
-bitAtPos(unsigned long pos, bit_map* bm)
+boolean bitAtPos(unsigned long pos, bit_map *bm)
 {
-  if (pos > bm->size*bitsPerByte)
-    return false;
-  else
-    return((bm->bytes[(pos / bitsPerByte)] &
-	    (0x80>>(pos % bitsPerByte))) ?
-	   true : false);
+    if (pos > bm->size * bitsPerByte)
+	return false;
+    else
+	return ((bm->bytes[(pos / bitsPerByte)] &
+		 (0x80 >> (pos % bitsPerByte))) ?
+		true : false);
 }
 
 /*----------------------------------------------------------------------*/
 
-char*
-writeBitMap(bit_map* bm, data_tag tag, char* buffer, long* len)
+char *writeBitMap(bit_map *bm, data_tag tag, char *buffer, long *len)
 /* write a bitmap + type and size info */
 {
-  return(writeAny((any*)bm,tag,buffer,len));
+    return (writeAny((any *) bm, tag, buffer, len));
 }
 
 /*----------------------------------------------------------------------*/
 
-char*
-readBitMap(bit_map** bm, char* buffer)
+char *readBitMap(bit_map **bm, char *buffer)
 /* read a bitmap + type and size info */
 {
     char *c;
-    c = readAny((any**)bm,buffer);
-    return(c);
+
+    c = readAny((any **) bm, buffer);
+    return (c);
 }
 
 /*----------------------------------------------------------------------*/
 
-char*
-writeByte(unsigned long byte, char* buf, long* len)
+char *writeByte(unsigned long byte, char *buf, long *len)
 {
-  CHECK_FOR_SPACE_LEFT(1,len);
-  buf[0] = byte & 0xFF; /* we really only want the first byte */
-  return(buf + 1);
+    CHECK_FOR_SPACE_LEFT(1, len);
+    buf[0] = byte & 0xFF;	/* we really only want the first byte */
+    return (buf + 1);
 }
 
 /*----------------------------------------------------------------------*/
 
-char*
-readByte(unsigned char* byte, char* buf)
+char *readByte(unsigned char *byte, char *buf)
 {
-  *byte = buf[0];
-  return(buf + 1);
+    *byte = buf[0];
+    return (buf + 1);
 }
 
 /*----------------------------------------------------------------------*/
 
-char*
-writeBoolean(boolean flag, char* buf, long* len)
+char *writeBoolean(boolean flag, char *buf, long *len)
 {
-  return(writeByte(flag,buf,len));
+    return (writeByte(flag, buf, len));
 }
 
 /*----------------------------------------------------------------------*/
 
-char*
-readBoolean(boolean* flag, char* buffer)
+char *readBoolean(boolean *flag, char *buffer)
 {
-  unsigned char byte;
-  char* buf = readByte(&byte,buffer);
-  *flag = (byte == true) ? true : false;
-  return(buf);
+    unsigned char byte;
+    char *buf = readByte(&byte, buffer);
+
+    *flag = (byte == true) ? true : false;
+    return (buf);
 }
 
 /*----------------------------------------------------------------------*/
 
-char*
-writePDUType(pdu_type pduType, char* buf, long* len)
+char *writePDUType(pdu_type pduType, char *buf, long *len)
 /* PDUType is a single byte */
 {
-  return(writeBinaryInteger((long)pduType,(unsigned long)1,buf,len));
+    return (writeBinaryInteger((long) pduType, (unsigned long) 1, buf, len));
 }
 
 /*----------------------------------------------------------------------*/
 
-char*
-readPDUType(pdu_type* pduType, char* buf)
+char *readPDUType(pdu_type *pduType, char *buf)
 /* PDUType is a single byte */
 {
-  return(readBinaryInteger((long*)pduType,(unsigned long)1,buf));
+    return (readBinaryInteger((long *) pduType, (unsigned long) 1, buf));
 }
 
 /*----------------------------------------------------------------------*/
 
-pdu_type
-peekPDUType(char* buf)
+pdu_type peekPDUType(char *buf)
 /* read the next pdu without advancing the buffer, Note that this
    function is to be used on a buffer that is known to contain an
    APDU.  The pdu_type is written HEADER_LEN bytes into the buffer
  */
 {
-  pdu_type pdu;
-  readPDUType(&pdu,buf + HEADER_LEN);
-  return(pdu);
+    pdu_type pdu;
+
+    readPDUType(&pdu, buf + HEADER_LEN);
+    return (pdu);
 }
 
 /*----------------------------------------------------------------------*/
 
-#define BINARY_INTEGER_BYTES	sizeof(long) /* the number of bytes used by
-						a "binary integer" */
-char*
-writeBinaryInteger(long num, unsigned long size, char* buf, long* len)
+#define BINARY_INTEGER_BYTES	sizeof(long)	/* the number of bytes used by
+						   a "binary integer" */
+char *writeBinaryInteger(long num, unsigned long size, char *buf, long *len)
 /* write out first size bytes of num - no type info
   XXX should this take unsigned longs instead ???  */
 {
-  long i;
-  char byte;
+    long i;
+    char byte;
 
-  if (size < 1 || size > BINARY_INTEGER_BYTES)
-    return(NULL);		/* error */
+    if (size < 1 || size > BINARY_INTEGER_BYTES)
+	return (NULL);		/* error */
 
-  CHECK_FOR_SPACE_LEFT(size,len);
+    CHECK_FOR_SPACE_LEFT(size, len);
 
-  for (i = size - 1; i >= 0; i--)
-    { byte = (char)(num & 255);
-      buf[i] = byte;
-      num = num >> bitsPerByte; /* don't and here */
+    for (i = size - 1; i >= 0; i--) {
+	byte = (char) (num & 255);
+	buf[i] = byte;
+	num = num >> bitsPerByte;	/* don't and here */
     }
 
-  return(buf + size);
+    return (buf + size);
 }
 
 /*----------------------------------------------------------------------*/
 
-char*
-readBinaryInteger(long* num, unsigned long size, char* buf)
+char *readBinaryInteger(long *num, unsigned long size, char *buf)
 /* read in first size bytes of num - no type info
   XXX this should take unsigned longs instead !!! */
 {
-  unsigned long i;
-  unsigned char byte;
+    unsigned long i;
+    unsigned char byte;
 
-  if (size < 1 || size > BINARY_INTEGER_BYTES)
-    return(buf);		/* error */
-  *num = 0;
+    if (size < 1 || size > BINARY_INTEGER_BYTES)
+	return (buf);		/* error */
+    *num = 0;
 
-  for (i = 0; i < size; i++)
-    { byte = buf[i];
-      *num = *num << bitsPerByte;
-      *num += byte;
+    for (i = 0; i < size; i++) {
+	byte = buf[i];
+	*num = *num << bitsPerByte;
+	*num += byte;
     }
 
-  return(buf + size);
+    return (buf + size);
 }
 
 /*----------------------------------------------------------------------*/
 
-unsigned long
-writtenCompressedBinIntSize(long num)
+unsigned long writtenCompressedBinIntSize(long num)
 /* return the number of bytes needed to represent the value num.
    currently limited to max of 4 bytes
    Only compresses for positive nums - negatives get whole 4 bytes
  */
 {
-  if (num < 0L)
-    return(4);
-  else if (num < 256L)		/* 2**8 */
-    return(1);
-  else if (num < 65536L)	/* 2**16 */
-    return(2);
-  else if (num < 16777216L)	/* 2**24 */
-    return(3);
-  else
-    return(4);
+    if (num < 0L)
+	return (4);
+    else if (num < 256L)	/* 2**8 */
+	return (1);
+    else if (num < 65536L)	/* 2**16 */
+	return (2);
+    else if (num < 16777216L)	/* 2**24 */
+	return (3);
+    else
+	return (4);
 }
 
 /*----------------------------------------------------------------------*/
 
-char*
-writeNum(long num, data_tag tag, char* buffer, long* len)
+char *writeNum(long num, data_tag tag, char *buffer, long *len)
 /* write a binary integer + size and tag info */
 {
-  char* buf = buffer;
-  long size = writtenCompressedBinIntSize(num);
+    char *buf = buffer;
+    long size = writtenCompressedBinIntSize(num);
 
-  if (num == UNUSED)
-    return(buffer);
+    if (num == UNUSED)
+	return (buffer);
 
-  buf = writeTag(tag,buf,len);
-  buf = writeCompressedInteger(size,buf,len);
-  buf = writeBinaryInteger(num,(unsigned long)size,buf,len);
-  return(buf);
+    buf = writeTag(tag, buf, len);
+    buf = writeCompressedInteger(size, buf, len);
+    buf = writeBinaryInteger(num, (unsigned long) size, buf, len);
+    return (buf);
 }
 
 /*----------------------------------------------------------------------*/
 
-char*
-readNum(long* num, char* buffer)
+char *readNum(long *num, char *buffer)
 /* read a binary integer + size and tag info */
 {
-  char* buf = buffer;
-  data_tag tag;
-  unsigned long size;
-  unsigned long val;
+    char *buf = buffer;
+    data_tag tag;
+    unsigned long size;
+    unsigned long val;
 
-  buf = readTag(&tag,buf);
-  buf = readCompressedInteger(&val,buf);
-  size = (unsigned long)val;
-  buf = readBinaryInteger(num,size,buf);
-  return(buf);
+    buf = readTag(&tag, buf);
+    buf = readCompressedInteger(&val, buf);
+    size = (unsigned long) val;
+    buf = readBinaryInteger(num, size, buf);
+    return (buf);
 }
 
 /*----------------------------------------------------------------------*/
 
-unsigned long
-writtenNumSize(data_tag tag, long num)
+unsigned long writtenNumSize(data_tag tag, long num)
 {
-  long dataSize = writtenCompressedBinIntSize(num);
-  long size;
+    long dataSize = writtenCompressedBinIntSize(num);
+    long size;
 
-  size = writtenTagSize(tag); /* space for the tag */
-  size += writtenCompressedIntSize(dataSize); /* space for the size */
-  size += dataSize; /* space for the data */
+    size = writtenTagSize(tag);	/* space for the tag */
+    size += writtenCompressedIntSize(dataSize);		/* space for the size */
+    size += dataSize;		/* space for the data */
 
-  return(size);
+    return (size);
 }
 
 /*----------------------------------------------------------------------*/
 
-typedef void (voidfunc)(void *);
+typedef void (voidfunc) (void *);
 
-void
-doList(void** list, voidfunc *func)
+void doList(void **list, voidfunc * func)
 /* call func on each element of the NULL terminated list of pointers */
 {
-  register long i;
-  register void* ptr = NULL;
-  if (list == NULL)
-    return;
-  for (i = 0,ptr = list[i]; ptr != NULL; ptr = list[++i])
-    (*func)(ptr);
+    register long i;
+    register void *ptr = NULL;
+
+    if (list == NULL)
+	return;
+    for (i = 0, ptr = list[i]; ptr != NULL; ptr = list[++i])
+	(*func) (ptr);
 }
 
 /*----------------------------------------------------------------------*/
 
-char*
-writeProtocolVersion(char* buf, long* len)
+char *writeProtocolVersion(char *buf, long *len)
 /* write a bitmap describing the protocols available */
 {
-  static bit_map* version = NULL;
+    static bit_map *version = NULL;
 
-  if (version == NULL)
-   { version = makeBitMap((unsigned long)1,true); /* version 1! */
-   }
+    if (version == NULL) {
+	version = makeBitMap((unsigned long) 1, true);	/* version 1! */
+    }
 
-  return(writeBitMap(version,DT_ProtocolVersion,buf,len));
+    return (writeBitMap(version, DT_ProtocolVersion, buf, len));
 }
 
 /*----------------------------------------------------------------------*/
 
-char*
-defaultImplementationID(void)
+char *defaultImplementationID(void)
 {
-  static char	ImplementationID[] = "TMC";
-  return(ImplementationID);
+    static char ImplementationID[] = "TMC";
+
+    return (ImplementationID);
 }
 
 /*----------------------------------------------------------------------*/
 
-char*
-defaultImplementationName(void)
+char *defaultImplementationName(void)
 {
-  static char ImplementationName[] = "Thinking Machines Corporation Z39.50";
-  return(ImplementationName);
+    static char ImplementationName[] = "Thinking Machines Corporation Z39.50";
+
+    return (ImplementationName);
 }
 
 /*----------------------------------------------------------------------*/
 
-char*
-defaultImplementationVersion(void)
+char *defaultImplementationVersion(void)
 {
-  static char	ImplementationVersion[] = "2.0A";
-  return(ImplementationVersion);
+    static char ImplementationVersion[] = "2.0A";
+
+    return (ImplementationVersion);
 }
 
 /*----------------------------------------------------------------------*/
 
-
 /*
-**	Routines originally from ZType1.c -- FM
-**
-**----------------------------------------------------------------------*/
+ *	Routines originally from ZType1.c -- FM
+ *
+ *----------------------------------------------------------------------*/
 /* WIDE AREA INFORMATION SERVER SOFTWARE:
-   No guarantees or restrictions.  See the readme file for the full standard
-   disclaimer.
-
-   3.26.90	Harry Morris, morris@think.com
-   4.11.90  HWM - generalized conditional includes (see c-dialect.h)
-*/
+ * No guarantees or restrictions.  See the readme file for the full standard
+ * disclaimer.
+ *
+ * 3.26.90	Harry Morris, morris@think.com
+ * 4.11.90  HWM - generalized conditional includes (see c-dialect.h)
+ */
 /*----------------------------------------------------------------------*/
 
-query_term*
-makeAttributeTerm(
-char* use,
-char* relation,
-char* position,
-char* structure,
-char* truncation,
-char* completeness,
-any* term)
+query_term *makeAttributeTerm(char *use,
+			      char *relation,
+			      char *position,
+			      char *structure,
+			      char *truncation,
+			      char *completeness,
+			      any *term)
 {
-  query_term* qt = (query_term*)s_malloc((size_t)sizeof(query_term));
+    query_term *qt = (query_term *) s_malloc((size_t) sizeof(query_term));
 
-  qt->TermType = TT_Attribute;
+    qt->TermType = TT_Attribute;
 
-  /* copy in the attributes */
-  strncpy(qt->Use,use,ATTRIBUTE_SIZE);
-  strncpy(qt->Relation,relation,ATTRIBUTE_SIZE);
-  strncpy(qt->Position,position,ATTRIBUTE_SIZE);
-  strncpy(qt->Structure,structure,ATTRIBUTE_SIZE);
-  strncpy(qt->Truncation,truncation,ATTRIBUTE_SIZE);
-  strncpy(qt->Completeness,completeness,ATTRIBUTE_SIZE);
+    /* copy in the attributes */
+    strncpy(qt->Use, use, ATTRIBUTE_SIZE);
+    strncpy(qt->Relation, relation, ATTRIBUTE_SIZE);
+    strncpy(qt->Position, position, ATTRIBUTE_SIZE);
+    strncpy(qt->Structure, structure, ATTRIBUTE_SIZE);
+    strncpy(qt->Truncation, truncation, ATTRIBUTE_SIZE);
+    strncpy(qt->Completeness, completeness, ATTRIBUTE_SIZE);
 
-  qt->Term = duplicateAny(term);
+    qt->Term = duplicateAny(term);
 
-  qt->ResultSetID = NULL;
+    qt->ResultSetID = NULL;
 
-  return(qt);
+    return (qt);
 }
 
 /*----------------------------------------------------------------------*/
 
-query_term*
-makeResultSetTerm(any* resultSet)
+query_term *makeResultSetTerm(any *resultSet)
 {
-  query_term* qt = (query_term*)s_malloc((size_t)sizeof(query_term));
+    query_term *qt = (query_term *) s_malloc((size_t) sizeof(query_term));
 
-  qt->TermType = TT_ResultSetID;
+    qt->TermType = TT_ResultSetID;
 
-  qt->ResultSetID = duplicateAny(resultSet);
+    qt->ResultSetID = duplicateAny(resultSet);
 
-  qt->Term = NULL;
+    qt->Term = NULL;
 
-  return(qt);
+    return (qt);
 }
 
 /*----------------------------------------------------------------------*/
 
-query_term*
-makeOperatorTerm(char* operatorCode)
+query_term *makeOperatorTerm(char *operatorCode)
 {
-  query_term* qt = (query_term*)s_malloc((size_t)sizeof(query_term));
+    query_term *qt = (query_term *) s_malloc((size_t) sizeof(query_term));
 
-  qt->TermType = TT_Operator;
+    qt->TermType = TT_Operator;
 
-  strncpy(qt->Operator,operatorCode,OPERATOR_SIZE);
+    strncpy(qt->Operator, operatorCode, OPERATOR_SIZE);
 
-  qt->Term = NULL;
-  qt->ResultSetID = NULL;
+    qt->Term = NULL;
+    qt->ResultSetID = NULL;
 
-  return(qt);
+    return (qt);
 }
 
 /*----------------------------------------------------------------------*/
 
-void
-freeTerm(void* param)
+void freeTerm(void *param)
 {
-  query_term* qt = (query_term*)param;
-  switch (qt->TermType)
-    { case TT_Attribute:
+    query_term *qt = (query_term *) param;
+
+    switch (qt->TermType) {
+    case TT_Attribute:
 	freeAny(qt->Term);
 	break;
-      case TT_ResultSetID:
+    case TT_ResultSetID:
 	freeAny(qt->ResultSetID);
 	break;
-      case TT_Operator:
+    case TT_Operator:
 	/* do nothing */
 	break;
-      default:
+    default:
 	panic("Implementation error: Unknown term type %ld",
 	      qt->TermType);
 	break;
-      }
-  s_free(qt);
+    }
+    s_free(qt);
 }
 
 /*----------------------------------------------------------------------*/
@@ -1862,128 +1905,125 @@
 #define ATTRIBUTE_LIST_SIZE	ATTRIBUTE_SIZE * 6
 #define AT_DELIMITER	" "
 
-char*
-writeQueryTerm(query_term* qt, char* buffer, long* len)
+char *writeQueryTerm(query_term *qt, char *buffer, long *len)
 {
-  char* buf = buffer;
-  char attributes[ATTRIBUTE_LIST_SIZE];
+    char *buf = buffer;
+    char attributes[ATTRIBUTE_LIST_SIZE];
 
-  switch (qt->TermType)
-    { case TT_Attribute:
-	strncpy(attributes,qt->Use,ATTRIBUTE_LIST_SIZE);
-	s_strncat(attributes,AT_DELIMITER,sizeof(AT_DELIMITER) + 1,ATTRIBUTE_LIST_SIZE);
-	s_strncat(attributes,qt->Relation,ATTRIBUTE_SIZE,ATTRIBUTE_LIST_SIZE);
-	s_strncat(attributes,AT_DELIMITER,sizeof(AT_DELIMITER) + 1,ATTRIBUTE_LIST_SIZE);
-	s_strncat(attributes,qt->Position,ATTRIBUTE_SIZE,ATTRIBUTE_LIST_SIZE);
-	s_strncat(attributes,AT_DELIMITER,sizeof(AT_DELIMITER) + 1,ATTRIBUTE_LIST_SIZE);
-	s_strncat(attributes,qt->Structure,ATTRIBUTE_SIZE,ATTRIBUTE_LIST_SIZE);
-	s_strncat(attributes,AT_DELIMITER,sizeof(AT_DELIMITER) + 1,ATTRIBUTE_LIST_SIZE);
-	s_strncat(attributes,qt->Truncation,ATTRIBUTE_SIZE,ATTRIBUTE_LIST_SIZE);
-	s_strncat(attributes,AT_DELIMITER,sizeof(AT_DELIMITER) + 1,ATTRIBUTE_LIST_SIZE);
-	s_strncat(attributes,qt->Completeness,ATTRIBUTE_SIZE,ATTRIBUTE_LIST_SIZE);
-	buf = writeString(attributes,DT_AttributeList,buf,len);
-	buf = writeAny(qt->Term,DT_Term,buf,len);
+    switch (qt->TermType) {
+    case TT_Attribute:
+	strncpy(attributes, qt->Use, ATTRIBUTE_LIST_SIZE);
+	s_strncat(attributes, AT_DELIMITER, sizeof(AT_DELIMITER) + 1, ATTRIBUTE_LIST_SIZE);
+	s_strncat(attributes, qt->Relation, ATTRIBUTE_SIZE, ATTRIBUTE_LIST_SIZE);
+	s_strncat(attributes, AT_DELIMITER, sizeof(AT_DELIMITER) + 1, ATTRIBUTE_LIST_SIZE);
+	s_strncat(attributes, qt->Position, ATTRIBUTE_SIZE, ATTRIBUTE_LIST_SIZE);
+	s_strncat(attributes, AT_DELIMITER, sizeof(AT_DELIMITER) + 1, ATTRIBUTE_LIST_SIZE);
+	s_strncat(attributes, qt->Structure, ATTRIBUTE_SIZE, ATTRIBUTE_LIST_SIZE);
+	s_strncat(attributes, AT_DELIMITER, sizeof(AT_DELIMITER) + 1, ATTRIBUTE_LIST_SIZE);
+	s_strncat(attributes, qt->Truncation, ATTRIBUTE_SIZE, ATTRIBUTE_LIST_SIZE);
+	s_strncat(attributes, AT_DELIMITER, sizeof(AT_DELIMITER) + 1, ATTRIBUTE_LIST_SIZE);
+	s_strncat(attributes, qt->Completeness, ATTRIBUTE_SIZE, ATTRIBUTE_LIST_SIZE);
+	buf = writeString(attributes, DT_AttributeList, buf, len);
+	buf = writeAny(qt->Term, DT_Term, buf, len);
 	break;
-      case TT_ResultSetID:
-	buf = writeAny(qt->ResultSetID,DT_ResultSetID,buf,len);
+    case TT_ResultSetID:
+	buf = writeAny(qt->ResultSetID, DT_ResultSetID, buf, len);
 	break;
-      case TT_Operator:
-	buf = writeString(qt->Operator,DT_Operator,buf,len);
+    case TT_Operator:
+	buf = writeString(qt->Operator, DT_Operator, buf, len);
 	break;
-      default:
+    default:
 	panic("Implementation error: Unknown term type %ld",
 	      qt->TermType);
 	break;
-      }
+    }
 
-  return(buf);
+    return (buf);
 }
 
 /*----------------------------------------------------------------------*/
 
-char*
-readQueryTerm(query_term** qt, char* buffer)
-{
-  char* buf = buffer;
-  char  *attributeList = NULL;
-  char* operator = NULL;
-  any*  term;
-  char* use = NULL;
-  char* relation = NULL;
-  char* position = NULL;
-  char* structure = NULL;
-  char* truncation = NULL;
-  char* completeness;
-  any*	resultSetID = NULL;
-  data_tag tag;
-
-
-  tag = peekTag(buffer);
-
-  switch(tag)
-    { case DT_AttributeList:
-	buf = readString(&attributeList,buf);
-	buf = readAny(&term,buf);
-	use = strtok(attributeList,AT_DELIMITER);
-	relation = strtok(NULL,AT_DELIMITER);
-	position = strtok(NULL,AT_DELIMITER);
-	structure = strtok(NULL,AT_DELIMITER);
-	truncation = strtok(NULL,AT_DELIMITER);
-	completeness = strtok(NULL,AT_DELIMITER);
-	*qt = makeAttributeTerm(use,relation,position,structure,
-				truncation,completeness,term);
+char *readQueryTerm(query_term **qt, char *buffer)
+{
+    char *buf = buffer;
+    char *attributeList = NULL;
+    char *operator = NULL;
+    any *term;
+    char *use = NULL;
+    char *relation = NULL;
+    char *position = NULL;
+    char *structure = NULL;
+    char *truncation = NULL;
+    char *completeness;
+    any *resultSetID = NULL;
+    data_tag tag;
+
+    tag = peekTag(buffer);
+
+    switch (tag) {
+    case DT_AttributeList:
+	buf = readString(&attributeList, buf);
+	buf = readAny(&term, buf);
+	use = strtok(attributeList, AT_DELIMITER);
+	relation = strtok(NULL, AT_DELIMITER);
+	position = strtok(NULL, AT_DELIMITER);
+	structure = strtok(NULL, AT_DELIMITER);
+	truncation = strtok(NULL, AT_DELIMITER);
+	completeness = strtok(NULL, AT_DELIMITER);
+	*qt = makeAttributeTerm(use, relation, position, structure,
+				truncation, completeness, term);
 	s_free(attributeList);
 	freeAny(term);
 	break;
-      case DT_ResultSetID:
-	buf = readAny(&resultSetID,buf);
+    case DT_ResultSetID:
+	buf = readAny(&resultSetID, buf);
 	*qt = makeResultSetTerm(resultSetID);
 	freeAny(resultSetID);
 	break;
-      case DT_Operator:
-	buf = readString(&operator,buf);
+    case DT_Operator:
+	buf = readString(&operator, buf);
 	*qt = makeOperatorTerm(operator);
 	s_free(operator);
 	break;
-      default:
+    default:
 	REPORT_READ_ERROR(buf);
 	break;
-      }
+    }
 
-  return(buf);
+    return (buf);
 }
 
 /*----------------------------------------------------------------------*/
 
-static unsigned long getQueryTermSize PARAMS((query_term* qt));
+static unsigned long getQueryTermSize(query_term *qt);
 
-static unsigned long
-getQueryTermSize(query_term* qt)
+static unsigned long getQueryTermSize(query_term *qt)
 /* figure out how many bytes it will take to write this query */
 {
-  unsigned long size = 0;
-  static char attributes[] = "11 22 33 44 55 66"; /* we just need this to
-						     calculate its written
-						     size */
-
-  switch (qt->TermType)
-    { case TT_Attribute:
-	size = writtenStringSize(DT_AttributeList,attributes);
-	size += writtenAnySize(DT_Term,qt->Term);
+    unsigned long size = 0;
+    static char attributes[] = "11 22 33 44 55 66";	/* we just need this to
+
+							   calculate its written
+							   size */
+
+    switch (qt->TermType) {
+    case TT_Attribute:
+	size = writtenStringSize(DT_AttributeList, attributes);
+	size += writtenAnySize(DT_Term, qt->Term);
 	break;
-      case TT_ResultSetID:
-	size = writtenAnySize(DT_ResultSetID,qt->ResultSetID);
+    case TT_ResultSetID:
+	size = writtenAnySize(DT_ResultSetID, qt->ResultSetID);
 	break;
-      case TT_Operator:
-	size = writtenStringSize(DT_Operator,qt->Operator);
+    case TT_Operator:
+	size = writtenStringSize(DT_Operator, qt->Operator);
 	break;
-      default:
+    default:
 	panic("Implementation error: Unknown term type %ld",
 	      qt->TermType);
 	break;
-      }
+    }
 
-  return(size);
+    return (size);
 }
 
 /*----------------------------------------------------------------------*/
@@ -1992,84 +2032,81 @@
    transmission, a query is written into an any which is sent as
    the user information field. */
 
-any*
-writeQuery(query_term** terms)
+any *writeQuery(query_term **terms)
 {
-  any* info = NULL;
-  char* writePos = NULL;
-  char* data = NULL;
-  unsigned long size = 0;
-  long remaining = 0;
-  long i;
-  query_term* qt = NULL;
+    any *info = NULL;
+    char *writePos = NULL;
+    char *data = NULL;
+    unsigned long size = 0;
+    long remaining = 0;
+    long i;
+    query_term *qt = NULL;
 
-  if (terms == NULL)
-    return(NULL);
+    if (terms == NULL)
+	return (NULL);
 
-  /* calculate the size of write buffer */
-  for (i = 0,qt = terms[i]; qt != NULL; qt = terms[++i])
-    size += getQueryTermSize(qt);
+    /* calculate the size of write buffer */
+    for (i = 0, qt = terms[i]; qt != NULL; qt = terms[++i])
+	size += getQueryTermSize(qt);
 
-  data = (char*)s_malloc((size_t)size);
+    data = (char *) s_malloc((size_t) size);
 
-  /* write the terms */
-  writePos = data;
-  remaining = size;
-  for (i = 0,qt = terms[i]; qt != NULL; qt = terms[++i])
-    writePos = writeQueryTerm(qt,writePos,&remaining);
+    /* write the terms */
+    writePos = data;
+    remaining = size;
+    for (i = 0, qt = terms[i]; qt != NULL; qt = terms[++i])
+	writePos = writeQueryTerm(qt, writePos, &remaining);
 
-  info = makeAny(size,data);
+    info = makeAny(size, data);
 
-  return(info);
+    return (info);
 }
 
 /*----------------------------------------------------------------------*/
 
-query_term**
-readQuery(any *info)
+query_term **readQuery(any *info)
 {
-  char* readPos = info->bytes;
-  query_term** terms = NULL;
-  query_term* qt = NULL;
-  long numTerms = 0L;
-  char tmp[100];
+    char *readPos = info->bytes;
+    query_term **terms = NULL;
+    query_term *qt = NULL;
+    long numTerms = 0L;
+    char tmp[100];
 
-  sprintf(tmp,"readquery: bytes: %ld",info->size);
-  log_write(tmp);
+    sprintf(tmp, "readquery: bytes: %ld", info->size);
+    log_write(tmp);
 
-  while (readPos < info->bytes + info->size)
-    { readPos = readQueryTerm(&qt,readPos);
+    while (readPos < info->bytes + info->size) {
+	readPos = readQueryTerm(&qt, readPos);
 
-      if (terms == NULL)
-	{ terms = (query_term**)s_malloc((size_t)(sizeof(query_term*)*2));
+	if (terms == NULL) {
+	    terms = (query_term **) s_malloc((size_t) (sizeof(query_term *) * 2));
+	} else {
+	    terms =
+		(query_term **) s_realloc((char *) terms,
+					  (size_t) (sizeof(query_term *) *
+						      (numTerms + 2)));
 	}
-      else
-	{ terms =
-	    (query_term**)s_realloc((char*)terms,
-				    (size_t)(sizeof(query_term*)*(numTerms+2)));
-	  }
-      if (qt == NULL)
-	log_write("qt = null");
-      terms[numTerms++] = qt;
-      terms[numTerms] = NULL;
+	if (qt == NULL)
+	    log_write("qt = null");
+	terms[numTerms++] = qt;
+	terms[numTerms] = NULL;
     }
 
-  return(terms);
+    return (terms);
 }
 
 /*----------------------------------------------------------------------*/
 
-
 /*
-**	Routines originally from panic.c -- FM
-**
-**----------------------------------------------------------------------*/
+ *	Routines originally from panic.c -- FM
+ *
+ *----------------------------------------------------------------------*/
 /* WIDE AREA INFORMATION SERVER SOFTWARE:
-   No guarantees or restrictions.  See the readme file for the full standard
-   disclaimer.
-
-   Morris@think.com
-*/
+ * No guarantees or restrictions.  See the readme file for the full standard
+ * disclaimer.
+ *
+ * Morris@think.com
+ */
 
 /* panic is an error system interface.  On the Mac, it will pop
  * up a little window to explain the problem.
@@ -2078,151 +2115,144 @@
 
 /*----------------------------------------------------------------------*/
 
-static void exitAction PARAMS((long error));
+static void exitAction(long error);
 
-static void
-exitAction(long error GCC_UNUSED)
+static void exitAction(long error GCC_UNUSED)
 {
-  long i;
-  for (i = 0; i < 100000; i++)
-    ;
-  exit(0);
+    long i;
+
+    for (i = 0; i < 100000; i++) ;
+    exit_immediately(0);
 }
 
 /*----------------------------------------------------------------------*/
 
 #define PANIC_HEADER "Fatal Error:  "
 
-void
-panic(char *format, ...)
+void panic(char *format,...)
 {
-  va_list ap;			/* the variable arguments */
+    va_list ap;			/* the variable arguments */
 
-  fprintf(stderr,PANIC_HEADER);
-  LYva_start(ap, format);	/* init ap */
-  vfprintf(stderr,format,ap);	/* print the contents */
-  va_end(ap);			/* free ap */
-  fflush(stderr);
+    fprintf(stderr, PANIC_HEADER);
+    LYva_start(ap, format);	/* init ap */
+    vfprintf(stderr, format, ap);	/* print the contents */
+    va_end(ap);			/* free ap */
+    fflush(stderr);
 
-  exitAction(0);
+    exitAction(0);
 }
 
 /*----------------------------------------------------------------------*/
 
-
 /*
-**	Routines originally from cutil.c -- FM
-**
-**----------------------------------------------------------------------*/
+ *	Routines originally from cutil.c -- FM
+ *
+ *----------------------------------------------------------------------*/
 /* Wide AREA INFORMATION SERVER SOFTWARE
-   No guarantees or restrictions.  See the readme file for the full standard
-   disclaimer.
-
-   3.26.90	Harry Morris, morris@think.com
-   4.11.90  HWM - generalized conditional includes (see c-dialect.h)
-*/
+ * No guarantees or restrictions.  See the readme file for the full standard
+ * disclaimer.
+ *
+ * 3.26.90	Harry Morris, morris@think.com
+ * 4.11.90  HWM - generalized conditional includes (see c-dialect.h)
+ */
 
 /*----------------------------------------------------------------------*/
 
-void
-fs_checkPtr(void* ptr)
+void fs_checkPtr(void *ptr)
 /* If the ptr is NULL, give an error */
 {
-  if (ptr == NULL)
-    panic("checkPtr found a NULL pointer");
+    if (ptr == NULL)
+	panic("checkPtr found a NULL pointer");
 }
 
 /*----------------------------------------------------------------------*/
 
-void*
-fs_malloc(size_t size)
+void *fs_malloc(size_t size)
 /* does safety checks and optional accounting */
 {
-  register void* ptr = NULL;
+    register void *ptr = NULL;
 
-  ptr = (void*)calloc((size_t)size,(size_t)1);
-  s_checkPtr(ptr);
+    ptr = (void *) calloc((size_t) size, (size_t) 1);
+    s_checkPtr(ptr);
 
-  return(ptr);
+    return (ptr);
 }
 
 /*----------------------------------------------------------------------*/
 
-void*
-fs_realloc(void* ptr, size_t size)
+void *fs_realloc(void *ptr, size_t size)
 /* does safety checks and optional accounting
    note - we don't know how big ptr's memory is, so we can't ensure
    that any new memory allocated is NULLed!
  */
 {
-  register void* nptr = NULL;
+    register void *nptr = NULL;
 
-  if (ptr == NULL)		/* this is really a malloc */
-    return(s_malloc(size));
+    if (ptr == NULL)		/* this is really a malloc */
+	return (s_malloc(size));
 
-  nptr = (void*)realloc(ptr,size);
-  s_checkPtr(ptr);
+    nptr = (void *) realloc(ptr, size);
+    s_checkPtr(ptr);
 
-  return(nptr);
+    return (nptr);
 }
 
 /*----------------------------------------------------------------------*/
 
-void
-fs_free(void* ptr)
+void fs_free(void *ptr)
 /* does safety checks and optional accounting */
 {
-  if (ptr != NULL)		/* some non-ansi compilers/os's cant handle freeing null */
+    if (ptr != NULL)		/* some non-ansi compilers/os's cant handle freeing null */
     {				/* if we knew the size of this block of memory, we could clear it - oh well */
-      free(ptr);
-      ptr = NULL;
+	free(ptr);
+	ptr = NULL;
     }
 }
 
 /*----------------------------------------------------------------------*/
 
-char*
-s_strdup(char* s)
+char *s_strdup(char *s)
 
 /* return a copy of s.  This is identical to the standard library routine
    strdup(), except that it is safe.  If s == NULL or malloc fails,
    appropriate action is taken.
  */
 {
-  unsigned long len;
-  char* copy = NULL;
+    unsigned long len;
+    char *copy = NULL;
+
+    if (s == NULL)		/* saftey check to postpone stupid errors */
+	return (NULL);
 
-  if (s == NULL)		/* saftey check to postpone stupid errors */
-    return(NULL);
+    len = strlen(s);		/* length of string - terminator */
+    copy = (char *) s_malloc((size_t) (sizeof(char) * (len + 1)));
 
-  len = strlen(s);		/* length of string - terminator */
-  copy = (char*)s_malloc((size_t)(sizeof(char)*(len + 1)));
-  strncpy(copy,s,len + 1);
-  return(copy);
+    strncpy(copy, s, len + 1);
+    return (copy);
 }
 
 /*----------------------------------------------------------------------*/
 
-char*
-fs_strncat(char* dst, char* src, size_t maxToAdd, size_t maxTotal)
+char *fs_strncat(char *dst, char *src, size_t maxToAdd, size_t maxTotal)
 
 /* like strncat, except the fourth argument limits the maximum total
    length of the resulting string
  */
 {
-  size_t dstSize = strlen(dst);
-  size_t srcSize = strlen(src);
+    size_t dstSize = strlen(dst);
+    size_t srcSize = strlen(src);
 
-  if (dstSize + srcSize < maxTotal) /* use regular old strncat */
-    return(strncat(dst,src,maxToAdd));
-  else
-    { size_t truncateTo = maxTotal - dstSize - 1;
-      char   saveChar = src[truncateTo];
-      char*  result = NULL;
-      src[truncateTo] = '\0';
-      result = strncat(dst,src,maxToAdd);
-      src[truncateTo] = saveChar;
-      return(result);
+    if (dstSize + srcSize < maxTotal)	/* use regular old strncat */
+	return (strncat(dst, src, maxToAdd));
+    else {
+	size_t truncateTo = maxTotal - dstSize - 1;
+	char saveChar = src[truncateTo];
+	char *result = NULL;
+
+	src[truncateTo] = '\0';
+	result = strncat(dst, src, maxToAdd);
+	src[truncateTo] = saveChar;
+	return (result);
     }
 }
 
@@ -2230,20 +2260,22 @@
 
 char char_downcase(unsigned long long_ch)
 {
-  unsigned char ch = long_ch & 0xFF; /* just want one byte */
-  /* when ansi is the way of the world, this can be tolower */
-  return (((ch >= 'A') && (ch <= 'Z')) ? (ch + 'a' -'A') : ch);
+    unsigned char ch = long_ch & 0xFF;	/* just want one byte */
+
+    /* when ansi is the way of the world, this can be tolower */
+    return (((ch >= 'A') && (ch <= 'Z')) ? (ch + 'a' - 'A') : ch);
 }
 
 char *string_downcase(char *word)
 {
-  long i = 0;
-  while(word[i] != '\0'){
-    word[i] = char_downcase((unsigned long)word[i]);
-    i++;
-  }
-  return(word);
+    long i = 0;
+
+    while (word[i] != '\0') {
+	word[i] = char_downcase((unsigned long) word[i]);
+	i++;
+    }
+    return (word);
 }
 
 /*----------------------------------------------------------------------*/
-
+#endif /* VMS */
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/HTVMS_WaisProt.h
+++ lynx-cur-2.8.6/WWW/Library/Implementation/HTVMS_WaisProt.h
@@ -1,32 +1,32 @@
 /*							HTVMS_WAISProt.h
-**
-**	Adaptation for Lynx by F.Macrides (macrides@sci.wfeb.edu)
-**
-**	31-May-1994 FM	Initial version.
-**
-**----------------------------------------------------------------------*/
+ *
+ *	Adaptation for Lynx by F.Macrides (macrides@sci.wfeb.edu)
+ *
+ *	31-May-1994 FM	Initial version.
+ *
+ *----------------------------------------------------------------------*/
 
 /*
-**	Routines originally from WProt.h -- FM
-**
-**----------------------------------------------------------------------*/
+ *	Routines originally from WProt.h -- FM
+ *
+ *----------------------------------------------------------------------*/
 /* WIDE AREA INFORMATION SERVER SOFTWARE:
-   No guarantees or restrictions.  See the readme file for the full standard
-   disclaimer.
-
-   3.26.90	Harry Morris, morris@think.com
-   3.30.90  Harry Morris
-			-	removed chunk code from WAISSearchAPDU,
-			-	added makeWAISQueryType1Query() and readWAISType1Query() which
-				replace makeWAISQueryTerms() and makeWAISQueryDocs().
-   4.11.90  HWM - added definitions of wais element set names
-   4.14.90  HWM - changed symbol for relevance feedback query from QT_3 to
-				  QT_RelevanceFeedbackQuery added QT_TextRetrievalQuery as a
-				  synonym for QT_BooleanQuery
-				- renamed makeWAISType1Query() to makeWAISTextQuery()
-				  renamed readWAISType1Query() to readWAISTextQuery()
-   5.29.90  TS - added CSTFreeWAISFoo functions
-*/
+ * No guarantees or restrictions.  See the readme file for the full standard
+ * disclaimer.
+ *
+ *  3.26.90	Harry Morris, morris@think.com
+ *  3.30.90  Harry Morris
+ *			-	removed chunk code from WAISSearchAPDU,
+ *			-	added makeWAISQueryType1Query() and readWAISType1Query() which
+ *				replace makeWAISQueryTerms() and makeWAISQueryDocs().
+ *  4.11.90  HWM - added definitions of wais element set names
+ *  4.14.90  HWM - changed symbol for relevance feedback query from QT_3 to
+ *				  QT_RelevanceFeedbackQuery added QT_TextRetrievalQuery as a
+ *				  synonym for QT_BooleanQuery
+ *				- renamed makeWAISType1Query() to makeWAISTextQuery()
+ *				  renamed readWAISType1Query() to readWAISTextQuery()
+ *  5.29.90  TS - added CSTFreeWAISFoo functions
+ */
 
 #ifndef _H_WAIS_protocol_
 #define _H_WAIS_protocol_
@@ -109,226 +109,256 @@
 #define ES_DocumentHeadline		"Document Headline"
 #define ES_DocumentCodes		"Document Codes"
 
-typedef struct DocObj { /* specifies a section of a document */
-	any*	DocumentID;
-	char*   Type;
-	long	ChunkCode;
-	union {
-		long	Pos;
-		any*	ID;
-	} ChunkStart;
-	union {
-		long	Pos;
-		any*	ID;
-	} ChunkEnd;
-	} DocObj;
+typedef struct DocObj {		/* specifies a section of a document */
+    any *DocumentID;
+    char *Type;
+    long ChunkCode;
+    union {
+	long Pos;
+	any *ID;
+    } ChunkStart;
+    union {
+	long Pos;
+	any *ID;
+    } ChunkEnd;
+} DocObj;
 
 /*----------------------------------------------------------------------*/
 /* WAIS APDU extensions */
 
 typedef struct WAISInitResponse {
-	long				ChunkCode;
-	long				ChunkIDLength;
-	char*				ChunkMarker;
-	char*				HighlightMarker;
-	char*				DeHighlightMarker;
-	char*				NewlineCharacters;
-	/* XXX  need to add UpdateFrequency and Update Time */
-	} WAISInitResponse;
+    long ChunkCode;
+    long ChunkIDLength;
+    char *ChunkMarker;
+    char *HighlightMarker;
+    char *DeHighlightMarker;
+    char *NewlineCharacters;
+    /* XXX  need to add UpdateFrequency and Update Time */
+} WAISInitResponse;
 
 typedef struct WAISSearch {
-	char*				SeedWords;
-	DocObj**			Docs;
-	char**				TextList;
-	long				DateFactor;
-	char*				BeginDateRange;
-	char*				EndDateRange;
-	long				MaxDocumentsRetrieved;
-	} WAISSearch;
+    char *SeedWords;
+    DocObj **Docs;
+    char **TextList;
+    long DateFactor;
+    char *BeginDateRange;
+    char *EndDateRange;
+    long MaxDocumentsRetrieved;
+} WAISSearch;
 
 typedef struct WAISDocumentHeader {
-	any*				DocumentID;
-	long				VersionNumber;
-	long				Score;
-	long				BestMatch;
-	long				DocumentLength;
-	long				Lines;
-	char**				Types;
-	char*				Source;
-	char*				Date;
-	char*				Headline;
-	char*				OriginCity;
-	} WAISDocumentHeader;
+    any *DocumentID;
+    long VersionNumber;
+    long Score;
+    long BestMatch;
+    long DocumentLength;
+    long Lines;
+    char **Types;
+    char *Source;
+    char *Date;
+    char *Headline;
+    char *OriginCity;
+} WAISDocumentHeader;
 
 typedef struct WAISDocumentShortHeader {
-	any*				DocumentID;
-	long				VersionNumber;
-	long				Score;
-	long				BestMatch;
-	long				DocumentLength;
-	long				Lines;
-	} WAISDocumentShortHeader;
+    any *DocumentID;
+    long VersionNumber;
+    long Score;
+    long BestMatch;
+    long DocumentLength;
+    long Lines;
+} WAISDocumentShortHeader;
 
 typedef struct WAISDocumentLongHeader {
-	any*				DocumentID;
-	long				VersionNumber;
-	long				Score;
-	long				BestMatch;
-	long				DocumentLength;
-	long				Lines;
-	char**				Types;
-	char*				Source;
-	char*				Date;
-	char*				Headline;
-	char*				OriginCity;
-	char*				StockCodes;
-	char*				CompanyCodes;
-	char*				IndustryCodes;
-	} WAISDocumentLongHeader;
+    any *DocumentID;
+    long VersionNumber;
+    long Score;
+    long BestMatch;
+    long DocumentLength;
+    long Lines;
+    char **Types;
+    char *Source;
+    char *Date;
+    char *Headline;
+    char *OriginCity;
+    char *StockCodes;
+    char *CompanyCodes;
+    char *IndustryCodes;
+} WAISDocumentLongHeader;
 
 typedef struct WAISDocumentText {
-	any*				DocumentID;
-	long				VersionNumber;
-	any*				DocumentText;
-	} WAISDocumentText;
+    any *DocumentID;
+    long VersionNumber;
+    any *DocumentText;
+} WAISDocumentText;
 
 typedef struct WAISDocumentHeadlines {
-	any*				DocumentID;
-	long				VersionNumber;
-	char*				Source;
-	char*				Date;
-	char*				Headline;
-	char*				OriginCity;
-	} WAISDocumentHeadlines;
+    any *DocumentID;
+    long VersionNumber;
+    char *Source;
+    char *Date;
+    char *Headline;
+    char *OriginCity;
+} WAISDocumentHeadlines;
 
 typedef struct WAISDocumentCodes {
-	any*				DocumentID;
-	long				VersionNumber;
-	char*				StockCodes;
-	char*				CompanyCodes;
-	char*				IndustryCodes;
-	} WAISDocumentCodes;
+    any *DocumentID;
+    long VersionNumber;
+    char *StockCodes;
+    char *CompanyCodes;
+    char *IndustryCodes;
+} WAISDocumentCodes;
 
 typedef struct WAISSearchResponse {
-	char*					SeedWordsUsed;
-	WAISDocumentHeader**		DocHeaders;
-	WAISDocumentShortHeader**	ShortHeaders;
-	WAISDocumentLongHeader**	LongHeaders;
-	WAISDocumentText**			Text;
-	WAISDocumentHeadlines**		Headlines;
-	WAISDocumentCodes**			Codes;
-	diagnosticRecord**			Diagnostics;
-	} WAISSearchResponse;
+    char *SeedWordsUsed;
+    WAISDocumentHeader **DocHeaders;
+    WAISDocumentShortHeader **ShortHeaders;
+    WAISDocumentLongHeader **LongHeaders;
+    WAISDocumentText **Text;
+    WAISDocumentHeadlines **Headlines;
+    WAISDocumentCodes **Codes;
+    diagnosticRecord **Diagnostics;
+} WAISSearchResponse;
 
 /*----------------------------------------------------------------------*/
 /* Functions */
 
-char *
-generate_search_apdu PARAMS((char* buff,  /* buffer to hold the apdu */
-			  long *buff_len, /* number of bytes written to the buffer */
-			  char *seed_words, /* string of the seed words */
-			  char *database_name,
-			  DocObj** docobjs,
-			  long maxDocsRetrieved
-			  ));
-
-DocObj* makeDocObjUsingWholeDocument PARAMS((any* aDocID,char* type));
-DocObj* makeDocObjUsingBytes PARAMS((any* aDocID,char* type,long start,long end));
-DocObj* makeDocObjUsingLines PARAMS((any* aDocID,char* type,long start,long end));
-DocObj* makeDocObjUsingParagraphs PARAMS((any* aDocID,char* type,any* start,any* end));
-void freeDocObj PARAMS((DocObj* doc));
-
-WAISInitResponse* makeWAISInitResponse PARAMS((long chunkCode,long chunkIDLen,
-					    char* chunkMarker,char* highlightMarker,
-					    char* deHighlightMarker,char* newLineChars));
-void freeWAISInitResponse PARAMS((WAISInitResponse* init));
-
-WAISSearch* makeWAISSearch PARAMS((
-	char* seedWords,DocObj** docs,char** textList,
-	long dateFactor,char* beginDateRange,char* endDateRange,
-	long maxDocsRetrieved));
-void freeWAISSearch PARAMS((WAISSearch* query));
-
-WAISDocumentHeader* makeWAISDocumentHeader PARAMS((
-	any* aDocID,long versionNumber,long score,long bestMatch,long docLen,
-	long lines,char** types,char* source,char* date,char* headline,char* originCity));
-void freeWAISDocumentHeader PARAMS((WAISDocumentHeader* header));
-char* writeWAISDocumentHeader PARAMS((WAISDocumentHeader* header,char* buffer,long* len));
-char* readWAISDocumentHeader PARAMS((WAISDocumentHeader** header,char* buffer));
-
-WAISDocumentShortHeader* makeWAISDocumentShortHeader PARAMS((
-	any* aDocID,long versionNumber,long score,long bestMatch,long docLen,long lines));
-void freeWAISDocumentShortHeader PARAMS((WAISDocumentShortHeader* header));
-char* writeWAISDocumentShortHeader PARAMS((WAISDocumentShortHeader* header,
-                                   char* buffer,long* len));
-char* readWAISDocumentShortHeader PARAMS((WAISDocumentShortHeader** header,char* buffer));
-
-WAISDocumentLongHeader* makeWAISDocumentLongHeader PARAMS((
-	any* aDocID,long versionNumber,long score,long bestMatch,long docLen,
-	long lines,char** types,char* source,char* date, char* headline,char* originCity,
-	char* stockCodes,char* companyCodes,char* industryCodes));
-void freeWAISDocumentLongHeader PARAMS((WAISDocumentLongHeader* header));
-char* writeWAISDocumentLongHeader PARAMS((WAISDocumentLongHeader* header,char* buffer,long* len));
-char* readWAISDocumentLongHeader PARAMS((WAISDocumentLongHeader** header,char* buffer));
-
-WAISSearchResponse* makeWAISSearchResponse PARAMS((
-	char* seedWordsUsed,WAISDocumentHeader** docHeaders,
-	WAISDocumentShortHeader** shortHeaders,
-	WAISDocumentLongHeader** longHeaders,
-	WAISDocumentText** text,WAISDocumentHeadlines** headlines,
-	WAISDocumentCodes** codes,
-	diagnosticRecord** diagnostics));
-void freeWAISSearchResponse PARAMS((WAISSearchResponse* response));
-
-WAISDocumentText* makeWAISDocumentText PARAMS((any* aDocID,long versionNumber,
-				       any* documentText));
-void freeWAISDocumentText PARAMS((WAISDocumentText* docText));
-char* writeWAISDocumentText PARAMS((WAISDocumentText* docText,char* buffer,long* len));
-char* readWAISDocumentText PARAMS((WAISDocumentText** docText,char* buffer));
-
-WAISDocumentHeadlines* makeWAISDocumentHeadlines PARAMS((
-	any* aDocID,long versionNumber,char* source,char* date,char* headline,
-	char* originCity));
-void freeWAISDocumentHeadlines PARAMS((WAISDocumentHeadlines* docHeadline));
-char* writeWAISDocumentHeadlines PARAMS((WAISDocumentHeadlines* docHeadline,char* buffer,long* len));
-char* readWAISDocumentHeadlines PARAMS((WAISDocumentHeadlines** docHeadline,char* buffer));
-
-WAISDocumentCodes* makeWAISDocumentCodes PARAMS((
-	any* aDocID,long versionNumber,char* stockCodes,char* companyCodes,
-	char* industryCodes));
-void freeWAISDocumentCodes PARAMS((WAISDocumentCodes* docCodes));
-char* writeWAISDocumentCodes PARAMS((WAISDocumentCodes* docCodes,char* buffer,long* len));
-char* readWAISDocumentCodes PARAMS((WAISDocumentCodes** docCodes,char* buffer));
-
-any* makeWAISTextQuery PARAMS((DocObj** docs));
-DocObj** readWAISTextQuery PARAMS((any* terms));
-
-void CSTFreeWAISInitResponse PARAMS((WAISInitResponse* init));
-void CSTFreeWAISSearch PARAMS((WAISSearch* query));
-void CSTFreeDocObj PARAMS((DocObj* doc));
-void CSTFreeWAISDocumentHeader PARAMS((WAISDocumentHeader* header));
-void CSTFreeWAISDocumentShortHeader PARAMS((WAISDocumentShortHeader* header));
-void CSTFreeWAISDocumentLongHeader PARAMS((WAISDocumentLongHeader* header));
-void CSTFreeWAISSearchResponse PARAMS((WAISSearchResponse* response));
-void CSTFreeWAISDocumentText PARAMS((WAISDocumentText* docText));
-void CSTFreeWAISDocHeadlines PARAMS((WAISDocumentHeadlines* docHeadline));
-void CSTFreeWAISDocumentCodes PARAMS((WAISDocumentCodes* docCodes));
-void CSTFreeWAISTextQuery PARAMS(( any* query));
+char *generate_search_apdu(char *buff,	/* buffer to hold the apdu */
+			   long *buff_len,	/* number of bytes written to the buffer */
+			   char *seed_words,	/* string of the seed words */
+			   char *database_name,
+			   DocObj **docobjs,
+			   long maxDocsRetrieved);
+
+DocObj *makeDocObjUsingWholeDocument(any *aDocID, char *type);
+DocObj *makeDocObjUsingBytes(any *aDocID, char *type, long start, long end);
+DocObj *makeDocObjUsingLines(any *aDocID, char *type, long start, long end);
+DocObj *makeDocObjUsingParagraphs(any *aDocID, char *type, any *start, any *end);
+void freeDocObj(DocObj *doc);
+
+WAISInitResponse *makeWAISInitResponse(long chunkCode, long chunkIDLen,
+				       char *chunkMarker, char *highlightMarker,
+				       char *deHighlightMarker, char *newLineChars);
+void freeWAISInitResponse(WAISInitResponse *init);
+
+WAISSearch *makeWAISSearch(char *seedWords,
+			   DocObj **docs,
+			   char **textList,
+			   long dateFactor,
+			   char *beginDateRange,
+			   char *endDateRange,
+			   long maxDocsRetrieved);
+void freeWAISSearch(WAISSearch *query);
+
+WAISDocumentHeader *makeWAISDocumentHeader(any *aDocID,
+					   long versionNumber,
+					   long score,
+					   long bestMatch,
+					   long docLen,
+					   long lines,
+					   char **types,
+					   char *source,
+					   char *date,
+					   char *headline,
+					   char *originCity);
+void freeWAISDocumentHeader(WAISDocumentHeader *header);
+char *writeWAISDocumentHeader(WAISDocumentHeader *header, char *buffer, long *len);
+char *readWAISDocumentHeader(WAISDocumentHeader **header, char *buffer);
+
+WAISDocumentShortHeader *makeWAISDocumentShortHeader(any *aDocID,
+						     long versionNumber,
+						     long score,
+						     long bestMatch,
+						     long docLen,
+						     long lines);
+void freeWAISDocumentShortHeader(WAISDocumentShortHeader *header);
+char *writeWAISDocumentShortHeader(WAISDocumentShortHeader *header,
+				   char *buffer, long *len);
+char *readWAISDocumentShortHeader(WAISDocumentShortHeader **header, char *buffer);
+
+WAISDocumentLongHeader *makeWAISDocumentLongHeader(any *aDocID,
+						   long versionNumber,
+						   long score,
+						   long bestMatch,
+						   long docLen,
+						   long lines,
+						   char **types,
+						   char *source,
+						   char *date, char *headline,
+						   char *originCity,
+						   char *stockCodes,
+						   char *companyCodes,
+						   char *industryCodes);
+void freeWAISDocumentLongHeader(WAISDocumentLongHeader *header);
+char *writeWAISDocumentLongHeader(WAISDocumentLongHeader *header,
+				  char *buffer,
+				  long *len);
+char *readWAISDocumentLongHeader(WAISDocumentLongHeader **header, char *buffer);
+
+WAISSearchResponse *makeWAISSearchResponse(char *seedWordsUsed,
+					   WAISDocumentHeader **docHeaders,
+					   WAISDocumentShortHeader **shortHeaders,
+					   WAISDocumentLongHeader **longHeaders,
+					   WAISDocumentText **text, WAISDocumentHeadlines **headlines,
+					   WAISDocumentCodes **codes,
+					   diagnosticRecord ** diagnostics);
+void freeWAISSearchResponse(WAISSearchResponse * response);
+
+WAISDocumentText *makeWAISDocumentText(any *aDocID, long versionNumber,
+				       any *documentText);
+void freeWAISDocumentText(WAISDocumentText *docText);
+char *writeWAISDocumentText(WAISDocumentText *docText, char *buffer, long *len);
+char *readWAISDocumentText(WAISDocumentText **docText, char *buffer);
+
+WAISDocumentHeadlines *makeWAISDocumentHeadlines(any *aDocID,
+						 long versionNumber,
+						 char *source,
+						 char *date,
+						 char *headline,
+						 char *originCity);
+void freeWAISDocumentHeadlines(WAISDocumentHeadlines *docHeadline);
+char *writeWAISDocumentHeadlines(WAISDocumentHeadlines *docHeadline,
+				 char *buffer,
+				 long *len);
+char *readWAISDocumentHeadlines(WAISDocumentHeadlines **docHeadline, char *buffer);
+
+WAISDocumentCodes *makeWAISDocumentCodes(any *aDocID,
+					 long versionNumber,
+					 char *stockCodes,
+					 char *companyCodes,
+					 char *industryCodes);
+void freeWAISDocumentCodes(WAISDocumentCodes *docCodes);
+char *writeWAISDocumentCodes(WAISDocumentCodes *docCodes, char *buffer, long *len);
+char *readWAISDocumentCodes(WAISDocumentCodes **docCodes, char *buffer);
+
+any *makeWAISTextQuery(DocObj **docs);
+DocObj **readWAISTextQuery(any *terms);
+
+void CSTFreeWAISInitResponse(WAISInitResponse *init);
+void CSTFreeWAISSearch(WAISSearch *query);
+void CSTFreeDocObj(DocObj *doc);
+void CSTFreeWAISDocumentHeader(WAISDocumentHeader *header);
+void CSTFreeWAISDocumentShortHeader(WAISDocumentShortHeader *header);
+void CSTFreeWAISDocumentLongHeader(WAISDocumentLongHeader *header);
+void CSTFreeWAISSearchResponse(WAISSearchResponse * response);
+void CSTFreeWAISDocumentText(WAISDocumentText *docText);
+void CSTFreeWAISDocHeadlines(WAISDocumentHeadlines *docHeadline);
+void CSTFreeWAISDocumentCodes(WAISDocumentCodes *docCodes);
+void CSTFreeWAISTextQuery(any *query);
 
 /*----------------------------------------------------------------------*/
 
 #endif /* ndef _H_WAIS_protocol_ */
 
-
 /*
-**	Routines originally from WMessage.h -- FM
-**
-**----------------------------------------------------------------------*/
+ *	Routines originally from WMessage.h -- FM
+ *
+ *----------------------------------------------------------------------*/
 /* WIDE AREA INFORMATION SERVER SOFTWARE
-   No guarantees or restrictions.  See the readme file for the full standard
-   disclaimer.
-   3.26.90
-*/
+ * No guarantees or restrictions.  See the readme file for the full standard
+ * disclaimer.
+ * 3.26.90
+ */
 
 /* wais-message.h
  *
@@ -355,16 +385,16 @@
 #include <HTVMS_WaisUI.h>
 
 typedef struct wais_header {
-        char    msg_len[10];    /* length in bytes of following message */
-        char    msg_type;       /* type of message: 'z'=Z39.50 APDU,
-                                   'a'=ACK, 'n'=NACK */
-        char    hdr_vers;       /* version of this header, currently = '2' */
-        char    server[10];     /* name or address of server */
-        char    compression;    /* <sp>=no compression, 'u'=unix compress */
-        char    encoding;       /* <sp>=no encoding, 'h'=hexize,
+    char msg_len[10];		/* length in bytes of following message */
+    char msg_type;		/* type of message: 'z'=Z39.50 APDU,
+				   'a'=ACK, 'n'=NACK */
+    char hdr_vers;		/* version of this header, currently = '2' */
+    char server[10];		/* name or address of server */
+    char compression;		/* <sp>=no compression, 'u'=unix compress */
+    char encoding;		/* <sp>=no encoding, 'h'=hexize,
 				   'u'=uuencode */
-        char    msg_checksum;   /* XOR of every byte of message */
-        } WAISMessage;
+    char msg_checksum;		/* XOR of every byte of message */
+} WAISMessage;
 
 #define HEADER_LENGTH	25	/* number of bytes needed to write a
 				   wais-header (not sizeof(wais_header)) */
@@ -382,15 +412,14 @@
 
 /* encoding */
 #define NO_ENCODING		' '
-#define HEX_ENCODING		'h'  /* Swartz 4/3 encoding */
-#define IBM_HEXCODING		'i'  /* same as h but uses characters acceptable for IBM mainframes */
+#define HEX_ENCODING		'h'	/* Swartz 4/3 encoding */
+#define IBM_HEXCODING		'i'	/* same as h but uses characters acceptable for IBM mainframes */
 #define UUENCODE		'u'
 
-
-void readWAISPacketHeader PARAMS((char* msgBuffer,WAISMessage *header_struct));
-long getWAISPacketLength PARAMS((WAISMessage* header));
-void writeWAISPacketHeader PARAMS((char* header,long dataLen,long type,
-				char* server,long compression,
-				long encoding,long version));
+void readWAISPacketHeader(char *msgBuffer, WAISMessage * header_struct);
+long getWAISPacketLength(WAISMessage * header);
+void writeWAISPacketHeader(char *header, long dataLen, long type,
+			   char *server, long compression,
+			   long encoding, long version);
 
 #endif /* ndef WMESSAGE_H */
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/LYLeaks.h
+++ lynx-cur-2.8.6/WWW/Library/Implementation/LYLeaks.h
@@ -6,161 +6,159 @@
 #define __LYLEAKS_H
 
 /*
-**  Copyright (c) 1994, University of Kansas, All Rights Reserved
-**
-**  Include File:	LYLeaks.h
-**  Purpose:		Header to convert requests for allocation to Lynx
-**			custom functions to track memory leaks.
-**  Remarks/Portability/Dependencies/Restrictions:
-**	For the stdlib.h allocation functions to be overriden by the
-**		Lynx memory tracking functions all modules allocating,
-**		freeing, or resizing memory must have LY_FIND_LEAKS
-**		defined before including this file.
-**	This header file should be included in every source file which
-**		does any memory manipulation through use of the
-**		stdlib.h memory functions.
-**	For proper reporting of memory leaks, the function LYLeaks
-**		should be registered for execution by atexit as the
-**		very first executable statement in main.
-**	This code is slow and should not be used except in debugging
-**		circumstances (don't define LY_FIND_LEAKS).
-**	If you are using LY_FIND_LEAKS and don't want the LYLeak*
-**		memory functions to be used in a certain file,
-**		define NO_MEMORY_TRACKING before including this file.
-**	The only safe way to call the LYLeak* functions is to use
-**		the below macros because they depend on the static
-**		string created by __FILE__ to not be dynamic in
-**		nature (don't free it and assume will exist at all
-**		times during execution).
-**	If you are using LY_FIND_LEAKS and LY_FIND_LEAKS_EXTENDED and
-**		want only normal memory tracking (not extended for
-**		HTSprintf/HTSprintf0) to be used in a certain file,
-**		define NO_EXTENDED_MEMORY_TRACKING and don't define
-**		NO_MEMORY_TRACKING before including this file.
-**  Revision History:
-**	05-26-94	created for Lynx 2-3-1, Garrett Arch Blythe
-**	10-30-97	modified to handle StrAllocCopy() and
-**			StrAllocCat(). - KW & FM
-**	1999-10-17	modified to handle HTSprintf0 and HTSprintf(),
-**			and to provide mark_malloced, if
-**			LY_FIND_LEAKS_EXTENDED is defined. - kw
-*/
+ *  Copyright (c) 1994, University of Kansas, All Rights Reserved
+ *
+ *  Include File:	LYLeaks.h
+ *  Purpose:		Header to convert requests for allocation to Lynx
+ *			custom functions to track memory leaks.
+ *  Remarks/Portability/Dependencies/Restrictions:
+ *	For the stdlib.h allocation functions to be overriden by the
+ *		Lynx memory tracking functions all modules allocating,
+ *		freeing, or resizing memory must have LY_FIND_LEAKS
+ *		defined before including this file.
+ *	This header file should be included in every source file which
+ *		does any memory manipulation through use of the
+ *		stdlib.h memory functions.
+ *	For proper reporting of memory leaks, the function LYLeaks
+ *		should be registered for execution by atexit as the
+ *		very first executable statement in main.
+ *	This code is slow and should not be used except in debugging
+ *		circumstances (don't define LY_FIND_LEAKS).
+ *	If you are using LY_FIND_LEAKS and don't want the LYLeak*
+ *		memory functions to be used in a certain file,
+ *		define NO_MEMORY_TRACKING before including this file.
+ *	The only safe way to call the LYLeak* functions is to use
+ *		the below macros because they depend on the static
+ *		string created by __FILE__ to not be dynamic in
+ *		nature (don't free it and assume will exist at all
+ *		times during execution).
+ *	If you are using LY_FIND_LEAKS and LY_FIND_LEAKS_EXTENDED and
+ *		want only normal memory tracking (not extended for
+ *		HTSprintf/HTSprintf0) to be used in a certain file,
+ *		define NO_EXTENDED_MEMORY_TRACKING and don't define
+ *		NO_MEMORY_TRACKING before including this file.
+ *  Revision History:
+ *	05-26-94	created for Lynx 2-3-1, Garrett Arch Blythe
+ *	10-30-97	modified to handle StrAllocCopy() and
+ *			StrAllocCat(). - KW & FM
+ *	1999-10-17	modified to handle HTSprintf0 and HTSprintf(),
+ *			and to provide mark_malloced, if
+ *			LY_FIND_LEAKS_EXTENDED is defined. - kw
+ */
 
 /* Undefine this to get no improved HTSprintf0/HTSprintf tracking: */
 #define LY_FIND_LEAKS_EXTENDED
 
 /*
-**  Required includes
-*/
+ *  Required includes
+ */
 
 #ifndef HTUTILS_H
 #include <HTUtils.h>
 #endif
 
+#ifdef __cplusplus
+extern "C" {
+#endif
 /*
-**	Constant defines
-*/
+ *	Constant defines
+ */
 #define MAX_CONTENT_LENGTH 50
 #ifdef VMS
 #define LEAKAGE_SINK "sys$login:Lynx.leaks"
 #else
 #define LEAKAGE_SINK "Lynx.leaks"
-#endif /* VMS */
-
+#endif				/* VMS */
 /*
-**	Data structures
-*/
-typedef struct SourceLocation_tag	{
+ * Data structures
+ */ typedef struct SourceLocation_tag {
 	/*
-	 *	The file name and line number of where an event took place.
+	 * The file name and line number of where an event took place.
 	 */
-	CONST char *cp_FileName;
+	const char *cp_FileName;
 	short ssi_LineNumber;
-}
-SourceLocation;
+    } SourceLocation;
 
-typedef struct AllocationList_tag	{
+    typedef struct AllocationList_tag {
 	/*
-	 *	A singly linked list.
+	 * A singly linked list.
 	 */
 	struct AllocationList_tag *ALp_Next;
 
 	/*
-	 *	Count the number of mallocs.
+	 * Count the number of mallocs.
 	 */
 	long st_Sequence;
 
 	/*
-	 *	The memory pointer allocated.
-	 *	If set to NULL, then an invalid request was made.
-	 *	The invalid pointer also.
+	 * The memory pointer allocated.  If set to NULL, then an invalid request
+	 * was made.  The invalid pointer also.
 	 */
 	void *vp_Alloced;
 	void *vp_BadRequest;
 
 	/*
-	 *	The size in bytes of the allocated memory.
+	 * The size in bytes of the allocated memory.
 	 */
 	size_t st_Bytes;
 
 	/*
-	 *	The source location of specific event (calloc, malloc, free).
-	 *	realloc kept separate since will track last realloc on pointer.
+	 * The source location of specific event (calloc, malloc, free).  realloc
+	 * kept separate since will track last realloc on pointer.
 	 */
 	SourceLocation SL_memory;
 	SourceLocation SL_realloc;
-} AllocationList;
+    } AllocationList;
 
 /*
-**  Global variable declarations
-*/
+ *  Global variable declarations
+ */
 
 /*
-**  Macros
-*/
+ *  Macros
+ */
 #if defined(LY_FIND_LEAKS) && !defined(NO_MEMORY_TRACKING)
 /*
-**	Only use these macros if we are to track memory allocations.
-**	The reason for using a macro instead of a define is that we want
-**		to track where the initial allocation took place or where
-**		the last reallocation took place.
-**	Track where the allocation took place by the __FILE__ and __LINE__
-**		defines which are automatic to the compiler.
-*/
+ * Only use these macros if we are to track memory allocations.  The reason for
+ * using a macro instead of a define is that we want to track where the initial
+ * allocation took place or where the last reallocation took place.  Track
+ * where the allocation took place by the __FILE__ and __LINE__ defines which
+ * are automatic to the compiler.
+ */
 #ifdef malloc
 #undef malloc
-#endif /* malloc */
+#endif				/* malloc */
 #define malloc(st_bytes) LYLeakMalloc(st_bytes, __FILE__, __LINE__)
 
 #ifdef calloc
 #undef calloc
-#endif /* calloc */
+#endif				/* calloc */
 #define calloc(st_number, st_bytes) LYLeakCalloc(st_number, st_bytes, \
 	__FILE__, __LINE__)
 
 #ifdef realloc
 #undef realloc
-#endif /* realloc */
+#endif				/* realloc */
 #define realloc(vp_alloced, st_newbytes) LYLeakRealloc(vp_alloced, \
 	st_newbytes, __FILE__, __LINE__)
 
 #ifdef free
 #undef free
-#endif /* free */
+#endif				/* free */
 #define free(vp_alloced) LYLeakFree(vp_alloced, __FILE__, __LINE__)
 
 /*
-**  Added the following two defines to track Lynx's frequent use
-**  of those macros. - KW 1997-10-12
-*/
+ * Added the following two defines to track Lynx's frequent use of those
+ * macros.  - KW 1997-10-12
+ */
 #ifdef StrAllocCopy
 #undef StrAllocCopy
-#endif /* StrAllocCopy */
+#endif				/* StrAllocCopy */
 #define StrAllocCopy(dest, src) LYLeakSACopy(&(dest), src, __FILE__, __LINE__)
 
 #ifdef StrAllocCat
 #undef StrAllocCat
-#endif /* StrAllocCat */
+#endif				/* StrAllocCat */
 #define StrAllocCat(dest, src)  LYLeakSACat(&(dest), src, __FILE__, __LINE__)
 
 #define mark_malloced(a,size) LYLeak_mark_malloced(a,size, __FILE__, __LINE__)
@@ -169,84 +167,77 @@
 
 #ifdef HTSprintf0
 #undef HTSprintf0
-#endif /* HTSprintf0 */
+#endif				/* HTSprintf0 */
 #define HTSprintf0 (Get_htsprintf0_fn(__FILE__,__LINE__))
 
 #ifdef HTSprintf
 #undef HTSprintf
-#endif /* HTSprintf */
+#endif				/* HTSprintf */
 #define HTSprintf (Get_htsprintf_fn(__FILE__,__LINE__))
 
-#endif /* LY_FIND_LEAKS_EXTENDED and not NO_EXTENDED_MEMORY_TRACKING */
+#endif				/* LY_FIND_LEAKS_EXTENDED and not NO_EXTENDED_MEMORY_TRACKING */
 
-#else /* LY_FIND_LEAKS && !NO_MEMORY_TRACKING */
+#else				/* LY_FIND_LEAKS && !NO_MEMORY_TRACKING */
 
 #define mark_malloced(a,size)	/* no-op */
 #define LYLeakSequence() (-1)
 
-#endif /* LY_FIND_LEAKS && !NO_MEMORY_TRACKING */
+#endif				/* LY_FIND_LEAKS && !NO_MEMORY_TRACKING */
 
 #if defined(LY_FIND_LEAKS)
-#define PUBLIC_IF_FIND_LEAKS PUBLIC
+#define PUBLIC_IF_FIND_LEAKS	/* nothing */
 #else
-#define PUBLIC_IF_FIND_LEAKS PRIVATE
+#define PUBLIC_IF_FIND_LEAKS static
 #endif
 
 /*
-**	Function declarations
-**	See the appropriate source file for usage.
-*/
-#ifndef LYLeakSequence 
-extern long LYLeakSequence NOPARAMS;
+ * Function declarations.
+ * See the appropriate source file for usage.
+ */
+#ifndef LYLeakSequence
+    extern long LYLeakSequence(void);
 #endif
-extern void LYLeaks NOPARAMS;
-#ifdef LY_FIND_LEAKS_EXTENDED
-extern AllocationList *LYLeak_mark_malloced PARAMS((
-	void *		vp_alloced,
-	size_t		st_bytes,
-	CONST char *	cp_File,
-	CONST short	ssi_Line));
-#endif /* LY_FIND_LEAKS_EXTENDED */
-extern void *LYLeakMalloc PARAMS((
-	size_t		st_bytes,
-	CONST char *	cp_File,
-	CONST short	ssi_Line));
-extern void *LYLeakCalloc PARAMS((
-	size_t		st_number,
-	size_t		st_bytes,
-	CONST char *	cp_File,
-	CONST short	ssi_Line));
-extern void *LYLeakRealloc PARAMS((
-	void *		vp_alloced,
-	size_t		st_newbytes,
-	CONST char *	cp_File,
-	CONST short	ssi_Line));
-extern void LYLeakFree PARAMS((
-	void *		vp_alloced,
-	CONST char *	cp_File,
-	CONST short	ssi_Line));
-extern char * LYLeakSACopy PARAMS((
-	char **		dest,
-	CONST char *	src,
-	CONST char *	cp_File,
-	CONST short	ssi_Line));
-extern char * LYLeakSACat PARAMS((
-	char **		dest,
-	CONST char *	src,
-	CONST char *	cp_File,
-	CONST short	ssi_Line));
+    extern void LYLeaks(void);
 
 #ifdef LY_FIND_LEAKS_EXTENDED
-/* Trick to get tracking of var arg functions without relying
-   on var arg preprocessor macros: */
+    extern AllocationList *LYLeak_mark_malloced(void *vp_alloced,
+						size_t st_bytes,
+						const char *cp_File,
+						const short ssi_Line);
+#endif				/* LY_FIND_LEAKS_EXTENDED */
+    extern void *LYLeakMalloc(size_t st_bytes, const char *cp_File,
+			      const short ssi_Line);
+    extern void *LYLeakCalloc(size_t st_number, size_t st_bytes, const char *cp_File,
+			      const short ssi_Line);
+    extern void *LYLeakRealloc(void *vp_alloced,
+			       size_t st_newbytes,
+			       const char *cp_File,
+			       const short ssi_Line);
+    extern void LYLeakFree(void *vp_alloced,
+			   const char *cp_File,
+			   const short ssi_Line);
+    extern char *LYLeakSACopy(char **dest,
+			      const char *src,
+			      const char *cp_File,
+			      const short ssi_Line);
+    extern char *LYLeakSACat(char **dest,
+			     const char *src,
+			     const char *cp_File,
+			     const short ssi_Line);
 
-typedef char * HTSprintflike PARAMS((char **, CONST char *, ...));
-extern HTSprintflike *Get_htsprintf_fn PARAMS((
-			   CONST char *	cp_File,
-			   CONST short	ssi_Line));
-extern HTSprintflike *Get_htsprintf0_fn PARAMS((
-			   CONST char *	cp_File,
-			   CONST short	ssi_Line));
-#endif /* LY_FIND_LEAKS_EXTENDED */
+#ifdef LY_FIND_LEAKS_EXTENDED
+/*
+ * Trick to get tracking of var arg functions without relying on var arg
+ * preprocessor macros:
+ */
+    typedef char *HTSprintflike(char **, const char *,...);
+    extern HTSprintflike *Get_htsprintf_fn(const char *cp_File,
+					   const short ssi_Line);
+    extern HTSprintflike *Get_htsprintf0_fn(const char *cp_File,
+					    const short ssi_Line);
+#endif				/* LY_FIND_LEAKS_EXTENDED */
 
-#endif /* __LYLEAKS_H */
+#ifdef __cplusplus
+}
+#endif
+#endif				/* __LYLEAKS_H */
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/HTCJK.h
+++ lynx-cur-2.8.6/WWW/Library/Implementation/HTCJK.h
@@ -1,12 +1,12 @@
 /*			CJK character converter		HTCJK.h
-**			=======================
-**
-**	Added 11-Jun-96 by FM, based on jiscode.h for
-**	  Yutaka Sato's (ysato@etl.go.jp) SJIS.c, and
-**	  Takuya ASADA's (asada@three-a.co.jp) CJK patches.
-**	  (see SGML.c).
-**
-*/
+ *			=======================
+ *
+ *	Added 11-Jun-96 by FM, based on jiscode.h for
+ *	  Yutaka Sato's (ysato@etl.go.jp) SJIS.c, and
+ *	  Takuya ASADA's (asada@three-a.co.jp) CJK patches.
+ *	  (see SGML.c).
+ *
+ */
 
 #ifndef HTCJK_H
 #define HTCJK_H
@@ -15,108 +15,99 @@
 #include <HTUtils.h>
 #endif
 
+#ifdef __cplusplus
+extern "C" {
+#endif
 /*
-**	STATUS CHANGE CODES
-*/
+ *	STATUS CHANGE CODES
+ */
 #ifdef ESC
 #undef ESC
-#endif /* ESC */
-#define ESC		CH_ESC  /* S/390 -- gil -- 0098 */
+#endif				/* ESC */
+#define ESC		CH_ESC	/* S/390 -- gil -- 0098 */
 #define TO_2BCODE	'$'
 #define TO_1BCODE	'('
-
 #define TO_KANA		'\016'
 #define TO_KANAOUT	'\017'
-
 #define TO_KANJI	"\033$B"
 #define TO_HANJI	"\033$A"
 #define TO_HANGUL	"\033$(C"
 #define TO_ASCII	"\033(B"
-
 #define IS_SJIS_LO(lo)	((0x40<=lo)&&(lo!=0x7F)&&(lo<=0xFC))
 #define IS_SJIS_HI1(hi) ((0x81<=hi)&&(hi<=0x9F))	/* 1st lev. */
 #define IS_SJIS_HI2(hi) ((0xE0<=hi)&&(hi<=0xEF))	/* 2nd lev. */
 #define IS_SJIS(hi,lo,in_sjis) (!IS_SJIS_LO(lo)?0:IS_SJIS_HI1(hi)?(in_sjis=1):in_sjis&&IS_SJIS_HI2(hi))
 #define IS_SJIS_2BYTE(hi,lo) (IS_SJIS_LO(lo)&&(IS_SJIS_HI1(hi)||IS_SJIS_HI2(hi)))
 #define IS_SJIS_X0201KANA(lo) ((0xA1<=lo)&&(lo<=0xDF))
-
 #define IS_EUC_LOX(lo)	((0xA1<=lo)&&(lo<=0xFE))	/* extended */
 #define IS_EUC_HI(hi)	((0xA1<=hi)&&(hi<=0xFE))
 #define IS_EUC_X0201KANA(hi,lo) ((hi==0x8E)&&(0xA1<=lo)&&(lo<=0xDF))
 #define IS_EUC(hi,lo) ((IS_EUC_HI(hi) && IS_EUC_LOX(lo))||IS_EUC_X0201KANA(hi,lo))
-
 #define IS_JAPANESE_2BYTE(hi,lo) (IS_SJIS_2BYTE(hi,lo) || IS_EUC(hi,lo))
-
 #define IS_BIG5_LOS(lo)	((0x40<=lo)&&(lo<=0x7E))	/* standard */
 #define IS_BIG5_LOX(lo)	((0xA1<=lo)&&(lo<=0xFE))	/* extended */
 #define IS_BIG5_HI(hi)	((0xA1<=hi)&&(hi<=0xFE))
 #define IS_BIG5(hi,lo) (IS_BIG5_HI(hi) && (IS_BIG5_LOS(lo) || IS_BIG5_LOX(lo)))
+    typedef enum {
+	NOKANJI = 0, EUC, SJIS, JIS
+    } HTkcode;
+    typedef enum {
+	NOCJK = 0, JAPANESE, CHINESE, KOREAN, TAIPEI
+    } HTCJKlang;
 
-typedef enum {NOKANJI, EUC, SJIS, JIS} HTkcode;
-typedef enum {NOCJK, JAPANESE, CHINESE, KOREAN, TAIPEI} HTCJKlang;
-
-extern HTCJKlang HTCJK;
+    extern HTCJKlang HTCJK;
 
 /*
-**  Function prototypes.
-*/
-extern void JISx0201TO0208_EUC PARAMS((
-	register unsigned char		IHI,
-	register unsigned char		ILO,
-	register unsigned char *	OHI,
-	register unsigned char *	OLO));
-
-extern unsigned char * SJIS_TO_JIS1 PARAMS((
-	register unsigned char		HI,
-	register unsigned char		LO,
-	register unsigned char *	JCODE));
-
-extern unsigned char * JIS_TO_SJIS1 PARAMS((
-	register unsigned char		HI,
-	register unsigned char		LO,
-	register unsigned char *	SJCODE));
-
-extern unsigned char * EUC_TO_SJIS1 PARAMS((
-	unsigned char			HI,
-	unsigned char			LO,
-	register unsigned char *	SJCODE));
-
-extern void JISx0201TO0208_SJIS PARAMS((
-	register unsigned char		I,
-	register unsigned char *	OHI,
-	register unsigned char *	OLO));
-
-extern unsigned char * SJIS_TO_EUC1 PARAMS((
-	unsigned char		HI,
-	unsigned char		LO,
-	unsigned char *		EUCp));
-
-extern unsigned char * SJIS_TO_EUC PARAMS((
-	unsigned char *		src,
-	unsigned char *		dst));
-
-extern unsigned char * EUC_TO_SJIS PARAMS((
-	unsigned char *		src,
-	unsigned char *		dst));
-
-extern unsigned char * EUC_TO_JIS PARAMS((
-	unsigned char *		src,
-	unsigned char *		dst,
-	CONST char *		toK,
-	CONST char *		toA));
-
-extern unsigned char * TO_EUC PARAMS((
-	CONST unsigned char *	jis,
-	unsigned char *		euc));
-
-extern void TO_SJIS PARAMS((
-	CONST unsigned char *	any,
-	unsigned char *		sjis));
-
-extern void TO_JIS PARAMS((
-	CONST unsigned char *	any,
-	unsigned char *		jis));
+ *  Function prototypes.
+ */
+    extern void JISx0201TO0208_EUC(register unsigned char IHI,
+				   register unsigned char ILO,
+				   register unsigned char *OHI,
+				   register unsigned char *OLO);
+
+    extern unsigned char *SJIS_TO_JIS1(register unsigned char HI,
+				       register unsigned char LO,
+				       register unsigned char *JCODE);
+
+    extern unsigned char *JIS_TO_SJIS1(register unsigned char HI,
+				       register unsigned char LO,
+				       register unsigned char *SJCODE);
 
-extern char *str_kcode PARAMS((HTkcode code));
+    extern unsigned char *EUC_TO_SJIS1(unsigned char HI,
+				       unsigned char LO,
+				       register unsigned char *SJCODE);
 
-#endif /* HTCJK_H */
+    extern void JISx0201TO0208_SJIS(register unsigned char I,
+				    register unsigned char *OHI,
+				    register unsigned char *OLO);
+
+    extern unsigned char *SJIS_TO_EUC1(unsigned char HI,
+				       unsigned char LO,
+				       unsigned char *EUCp);
+
+    extern unsigned char *SJIS_TO_EUC(unsigned char *src,
+				      unsigned char *dst);
+
+    extern unsigned char *EUC_TO_SJIS(unsigned char *src,
+				      unsigned char *dst);
+
+    extern unsigned char *EUC_TO_JIS(unsigned char *src,
+				     unsigned char *dst,
+				     const char *toK,
+				     const char *toA);
+
+    extern unsigned char *TO_EUC(const unsigned char *jis,
+				 unsigned char *euc);
+
+    extern void TO_SJIS(const unsigned char *any,
+			unsigned char *sjis);
+
+    extern void TO_JIS(const unsigned char *any,
+		       unsigned char *jis);
+
+    extern char *str_kcode(HTkcode code);
+
+#ifdef __cplusplus
+}
+#endif
+#endif				/* HTCJK_H */
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/HTVMS_WaisProt.c
+++ lynx-cur-2.8.6/WWW/Library/Implementation/HTVMS_WaisProt.c
@@ -1,30 +1,30 @@
 /*							HTVMS_WAISProt.c
-**
-**	Adaptation for Lynx by F.Macrides (macrides@sci.wfeb.edu)
-**
-**	31-May-1994 FM	Initial version.
-**
-**----------------------------------------------------------------------*/
+ *
+ *	Adaptation for Lynx by F.Macrides (macrides@sci.wfeb.edu)
+ *
+ *	31-May-1994 FM	Initial version.
+ *
+ *----------------------------------------------------------------------*/
 
 /*
-**	Routines originally from WProt.c -- FM
-**
-**----------------------------------------------------------------------*/
+ *	Routines originally from WProt.c -- FM
+ *
+ *----------------------------------------------------------------------*/
 /* WIDE AREA INFORMATION SERVER SOFTWARE:
-   No guarantees or restrictions.  See the readme file for the full standard
-   disclaimer.
+ * No guarantees or restrictions.  See the readme file for the full standard
+ * disclaimer.
 
-   3.26.90	Harry Morris, morris@think.com
-   3.30.90  Harry Morris
-   -	removed chunk code from WAISSearchAPDU,
-   -	added makeWAISQueryType1Query() and readWAISType1Query() which replace
-   makeWAISQueryTerms() and makeWAISQueryDocs().
-   4.11.90  HWM - generalized conditional includes (see c-dialect.h)
-   - renamed makeWAISType1Query() to makeWAISTextQuery()
-   renamed readWAISType1Query() to readWAISTextQuery()
-   5.29.90  TS - fixed bug in makeWAISQueryDocs
-   added CSTFreeWAISFoo functions
-*/
+ * 3.26.90	Harry Morris, morris@think.com
+ * 3.30.90  Harry Morris
+ * -	removed chunk code from WAISSearchAPDU,
+ * -	added makeWAISQueryType1Query() and readWAISType1Query() which replace
+ * makeWAISQueryTerms() and makeWAISQueryDocs().
+ * 4.11.90  HWM - generalized conditional includes (see c-dialect.h)
+ * - renamed makeWAISType1Query() to makeWAISTextQuery()
+ * renamed readWAISType1Query() to readWAISTextQuery()
+ * 5.29.90  TS - fixed bug in makeWAISQueryDocs
+ * added CSTFreeWAISFoo functions
+ */
 
 #define _C_WAIS_protocol_
 
@@ -37,7 +37,6 @@
 
 #include <LYLeaks.h>
 
-
 /* very rough estimates of the size of an object */
 #define DefWAISInitResponseSize		(size_t)200
 #define DefWAISSearchSize			(size_t)3000
@@ -55,41 +54,35 @@
      if (*len > 0)				\
 	*len -= header_len;
 
-/*----------------------------------------------------------------------*/
+#define S_MALLOC(type) (type*)s_malloc(sizeof(type))
+#define S_MALLOC2(type) (type*)s_malloc(sizeof(type) * 2)
 
-static unsigned long userInfoTagSize PARAMS((data_tag tag,
-					  unsigned long length));
+#define S_REALLOC2(type, ptr, num) (type*)s_realloc((char*)ptr, (sizeof(type) * (num + 2)))
 
-static unsigned long
-userInfoTagSize(tag,length)
-data_tag tag;
-unsigned long length;
+/*----------------------------------------------------------------------*/
+
+static unsigned long userInfoTagSize(data_tag tag,
+				     unsigned long length)
 /* return the number of bytes required to write the user info tag and
    length
  */
 {
-  unsigned long size;
+    unsigned long size;
 
-  /* calculate bytes required to represent tag.  max tag is 16K */
-  size = writtenCompressedIntSize(tag);
-  size += writtenCompressedIntSize(length);
+    /* calculate bytes required to represent tag.  max tag is 16K */
+    size = writtenCompressedIntSize(tag);
+    size += writtenCompressedIntSize(length);
 
-  return(size);
+    return (size);
 }
 
 /*----------------------------------------------------------------------*/
 
-static char* writeUserInfoHeader PARAMS((data_tag tag,long infoSize,
-				      long estHeaderSize,char* buffer,
-				      long* len));
-
-static char*
-writeUserInfoHeader(tag,infoSize,estHeaderSize,buffer,len)
-data_tag tag;
-long infoSize;
-long estHeaderSize;
-char* buffer;
-long* len;
+static char *writeUserInfoHeader(data_tag tag,
+				 long infoSize,
+				 long estHeaderSize,
+				 char *buffer,
+				 long *len)
 /* write the tag and size, making sure the info fits.  return the true end
    of the info (after adjustment) note that the argument infoSize includes
    estHeaderSize.  Note that the argument len is the number of bytes remaining
@@ -98,787 +91,762 @@
    do that writing.
  */
 {
-  long dummyLen = 100;		/* plenty of space for a tag and size */
-  char* buf = buffer;
-  long realSize = infoSize - estHeaderSize;
-  long realHeaderSize = userInfoTagSize(tag,realSize);
-
-  if (buffer == NULL || *len == 0)
-    return(NULL);
-
-  /* write the tag */
-  buf = writeTag(tag,buf,&dummyLen);
-
-  /* see if the if the header size was correct. if not,
-     we have to shift the info to fit the real header size */
-  if (estHeaderSize != realHeaderSize)
-    {				/* make sure there is enough space */
-      CHECK_FOR_SPACE_LEFT(realHeaderSize - estHeaderSize,len);
-      memmove(buffer + realHeaderSize,buffer + estHeaderSize,(size_t)(realSize));
+    long dummyLen = 100;	/* plenty of space for a tag and size */
+    char *buf = buffer;
+    long realSize = infoSize - estHeaderSize;
+    long realHeaderSize = userInfoTagSize(tag, realSize);
+
+    if (buffer == NULL || *len == 0)
+	return (NULL);
+
+    /* write the tag */
+    buf = writeTag(tag, buf, &dummyLen);
+
+    /* see if the if the header size was correct. if not,
+       we have to shift the info to fit the real header size */
+    if (estHeaderSize != realHeaderSize) {	/* make sure there is enough space */
+	CHECK_FOR_SPACE_LEFT(realHeaderSize - estHeaderSize, len);
+	memmove(buffer + realHeaderSize, buffer + estHeaderSize, (size_t) (realSize));
     }
 
-  /* write the size */
-  writeCompressedInteger(realSize,buf,&dummyLen);
+    /* write the size */
+    writeCompressedInteger(realSize, buf, &dummyLen);
 
-  /* return the true end of buffer */
-  return(buffer + realHeaderSize + realSize);
+    /* return the true end of buffer */
+    return (buffer + realHeaderSize + realSize);
 }
 
 /*----------------------------------------------------------------------*/
 
-static char* readUserInfoHeader PARAMS((data_tag* tag,unsigned long* num,
-				     char* buffer));
-
-static char*
-readUserInfoHeader(tag,num,buffer)
-data_tag* tag;
-unsigned long* num;
-char* buffer;
+static char *readUserInfoHeader(data_tag *tag,
+				unsigned long *num,
+				char *buffer)
 /* read the tag and size */
 {
-  char* buf = buffer;
-  buf = readTag(tag,buf);
-  buf = readCompressedInteger(num,buf);
-  return(buf);
+    char *buf = buffer;
+
+    buf = readTag(tag, buf);
+    buf = readCompressedInteger(num, buf);
+    return (buf);
 }
 
 /*----------------------------------------------------------------------*/
 
-WAISInitResponse*
-makeWAISInitResponse(chunkCode,
-		     chunkIDLen,
-		     chunkMarker,
-		     highlightMarker,
-		     deHighlightMarker,
-		     newLineChars)
-long chunkCode;
-long chunkIDLen;
-char* chunkMarker;
-char* highlightMarker;
-char* deHighlightMarker;
-char* newLineChars;
+WAISInitResponse *makeWAISInitResponse(long chunkCode,
+				       long chunkIDLen,
+				       char *chunkMarker,
+				       char *highlightMarker,
+				       char *deHighlightMarker,
+				       char *newLineChars)
 /* create a WAIS init response object */
 {
-  WAISInitResponse* init = (WAISInitResponse*)s_malloc((size_t)sizeof(WAISInitResponse));
+    WAISInitResponse *init = S_MALLOC(WAISInitResponse);
 
-  init->ChunkCode = chunkCode;	/* note: none are copied! */
-  init->ChunkIDLength = chunkIDLen;
-  init->ChunkMarker = chunkMarker;
-  init->HighlightMarker = highlightMarker;
-  init->DeHighlightMarker = deHighlightMarker;
-  init->NewlineCharacters = newLineChars;
+    init->ChunkCode = chunkCode;	/* note: none are copied! */
+    init->ChunkIDLength = chunkIDLen;
+    init->ChunkMarker = chunkMarker;
+    init->HighlightMarker = highlightMarker;
+    init->DeHighlightMarker = deHighlightMarker;
+    init->NewlineCharacters = newLineChars;
 
-  return(init);
+    return (init);
 }
 
 /*----------------------------------------------------------------------*/
 
-void
-freeWAISInitResponse(init)
-WAISInitResponse* init;
+void freeWAISInitResponse(WAISInitResponse *init)
 /* free an object made with makeWAISInitResponse */
 {
-  s_free(init->ChunkMarker);
-  s_free(init->HighlightMarker);
-  s_free(init->DeHighlightMarker);
-  s_free(init->NewlineCharacters);
-  s_free(init);
+    s_free(init->ChunkMarker);
+    s_free(init->HighlightMarker);
+    s_free(init->DeHighlightMarker);
+    s_free(init->NewlineCharacters);
+    s_free(init);
 }
 
 /*----------------------------------------------------------------------*/
 
-char*
-writeInitResponseInfo(init,buffer,len)
-InitResponseAPDU* init;
-char* buffer;
-long* len;
+char *writeInitResponseInfo(InitResponseAPDU *init,
+			    char *buffer,
+			    long *len)
 /* write an init response object */
 {
-  unsigned long header_len = userInfoTagSize(DT_UserInformationLength,
-					     DefWAISInitResponseSize);
-  char* buf = buffer + header_len;
-  WAISInitResponse* info = (WAISInitResponse*)init->UserInformationField;
-  unsigned long size;
+    unsigned long header_len = userInfoTagSize(DT_UserInformationLength,
+					       DefWAISInitResponseSize);
+    char *buf = buffer + header_len;
+    WAISInitResponse *info = (WAISInitResponse *) init->UserInformationField;
+    unsigned long size;
 
-  RESERVE_SPACE_FOR_WAIS_HEADER(len);
+    RESERVE_SPACE_FOR_WAIS_HEADER(len);
 
-  buf = writeNum(info->ChunkCode,DT_ChunkCode,buf,len);
-  buf = writeNum(info->ChunkIDLength,DT_ChunkIDLength,buf,len);
-  buf = writeString(info->ChunkMarker,DT_ChunkMarker,buf,len);
-  buf = writeString(info->HighlightMarker,DT_HighlightMarker,buf,len);
-  buf = writeString(info->DeHighlightMarker,DT_DeHighlightMarker,buf,len);
-  buf = writeString(info->NewlineCharacters,DT_NewlineCharacters,buf,len);
+    buf = writeNum(info->ChunkCode, DT_ChunkCode, buf, len);
+    buf = writeNum(info->ChunkIDLength, DT_ChunkIDLength, buf, len);
+    buf = writeString(info->ChunkMarker, DT_ChunkMarker, buf, len);
+    buf = writeString(info->HighlightMarker, DT_HighlightMarker, buf, len);
+    buf = writeString(info->DeHighlightMarker, DT_DeHighlightMarker, buf, len);
+    buf = writeString(info->NewlineCharacters, DT_NewlineCharacters, buf, len);
 
-  /* now write the header and size */
-  size = buf - buffer;
-  buf = writeUserInfoHeader(DT_UserInformationLength,size,header_len,buffer,len);
+    /* now write the header and size */
+    size = buf - buffer;
+    buf = writeUserInfoHeader(DT_UserInformationLength,
+			      size,
+			      header_len,
+			      buffer,
+			      len);
 
-  return(buf);
+    return (buf);
 }
 
 /*----------------------------------------------------------------------*/
 
-char*
-readInitResponseInfo(info,buffer)
-void** info;
-char* buffer;
+char *readInitResponseInfo(void **info,
+			   char *buffer)
 /* read an init response object */
 {
-  char* buf = buffer;
-  unsigned long size;
-  unsigned long headerSize;
-  long chunkCode,chunkIDLen;
-  data_tag tag1;
-  char* chunkMarker = NULL;
-  char* highlightMarker = NULL;
-  char* deHighlightMarker = NULL;
-  char* newLineChars = NULL;
-
-  chunkCode = chunkIDLen = UNUSED;
-
-  buf = readUserInfoHeader(&tag1,&size,buf);
-  headerSize = buf - buffer;
-
-  while (buf < (buffer + size + headerSize))
-    { data_tag tag = peekTag(buf);
-      switch (tag)
-	{ case DT_ChunkCode:
-	    buf = readNum(&chunkCode,buf);
-	    break;
-	  case DT_ChunkIDLength:
-	    buf = readNum(&chunkIDLen,buf);
-	    break;
-	  case DT_ChunkMarker:
-	    buf = readString(&chunkMarker,buf);
-	    break;
-	  case DT_HighlightMarker:
-	    buf = readString(&highlightMarker,buf);
+    char *buf = buffer;
+    unsigned long size;
+    unsigned long headerSize;
+    long chunkCode, chunkIDLen;
+    data_tag tag1;
+    char *chunkMarker = NULL;
+    char *highlightMarker = NULL;
+    char *deHighlightMarker = NULL;
+    char *newLineChars = NULL;
+
+    chunkCode = chunkIDLen = UNUSED;
+
+    buf = readUserInfoHeader(&tag1, &size, buf);
+    headerSize = buf - buffer;
+
+    while (buf < (buffer + size + headerSize)) {
+	data_tag tag = peekTag(buf);
+
+	switch (tag) {
+	case DT_ChunkCode:
+	    buf = readNum(&chunkCode, buf);
+	    break;
+	case DT_ChunkIDLength:
+	    buf = readNum(&chunkIDLen, buf);
+	    break;
+	case DT_ChunkMarker:
+	    buf = readString(&chunkMarker, buf);
+	    break;
+	case DT_HighlightMarker:
+	    buf = readString(&highlightMarker, buf);
 	    break;
-	  case DT_DeHighlightMarker:
-	    buf = readString(&deHighlightMarker,buf);
+	case DT_DeHighlightMarker:
+	    buf = readString(&deHighlightMarker, buf);
 	    break;
-	  case DT_NewlineCharacters:
-	    buf = readString(&newLineChars,buf);
+	case DT_NewlineCharacters:
+	    buf = readString(&newLineChars, buf);
 	    break;
-	  default:
+	default:
 	    s_free(highlightMarker);
 	    s_free(deHighlightMarker);
 	    s_free(newLineChars);
 	    REPORT_READ_ERROR(buf);
 	    break;
-	  }
+	}
     }
 
-  *info = (void *)makeWAISInitResponse(chunkCode,chunkIDLen,chunkMarker,
-			       highlightMarker,deHighlightMarker,
-			       newLineChars);
-  return(buf);
+    *info = (void *) makeWAISInitResponse(chunkCode, chunkIDLen, chunkMarker,
+					  highlightMarker, deHighlightMarker,
+					  newLineChars);
+    return (buf);
 }
 
 /*----------------------------------------------------------------------*/
 
-WAISSearch*
-makeWAISSearch(seedWords,
-	       docs,
-	       textList,
-	       dateFactor,
-	       beginDateRange,
-	       endDateRange,
-	       maxDocsRetrieved)
-char* seedWords;
-DocObj** docs;
-char** textList;
-long dateFactor;
-char* beginDateRange;
-char* endDateRange;
-long maxDocsRetrieved;
+WAISSearch *makeWAISSearch(char *seedWords,
+			   DocObj **docs,
+			   char **textList,
+			   long dateFactor,
+			   char *beginDateRange,
+			   char *endDateRange,
+			   long maxDocsRetrieved)
 
 /* create a type 3 query object */
 {
-  WAISSearch* query = (WAISSearch*)s_malloc((size_t)sizeof(WAISSearch));
+    WAISSearch *query = S_MALLOC(WAISSearch);
 
-  query->SeedWords = seedWords;	/* not copied! */
-  query->Docs = docs;		/* not copied! */
-  query->TextList = textList;	/* not copied! */
-  query->DateFactor = dateFactor;
-  query->BeginDateRange = beginDateRange;
-  query->EndDateRange = endDateRange;
-  query->MaxDocumentsRetrieved = maxDocsRetrieved;
+    query->SeedWords = seedWords;	/* not copied! */
+    query->Docs = docs;		/* not copied! */
+    query->TextList = textList;	/* not copied! */
+    query->DateFactor = dateFactor;
+    query->BeginDateRange = beginDateRange;
+    query->EndDateRange = endDateRange;
+    query->MaxDocumentsRetrieved = maxDocsRetrieved;
 
-  return(query);
+    return (query);
 }
 
 /*----------------------------------------------------------------------*/
 
-void
-freeWAISSearch(query)
-WAISSearch* query;
+void freeWAISSearch(WAISSearch *query)
 
 /* destroy an object made with makeWAISSearch() */
 {
-  void* ptr = NULL;
-  long i;
+    void *ptr = NULL;
+    long i;
 
-  s_free(query->SeedWords);
+    s_free(query->SeedWords);
 
-  if (query->Docs != NULL)
-    for (i = 0,ptr = (void *)query->Docs[i]; ptr != NULL; ptr = (void *)query->Docs[++i])
-      freeDocObj((DocObj*)ptr);
-  s_free(query->Docs);
+    if (query->Docs != NULL)
+	for (i = 0, ptr = (void *) query->Docs[i];
+	     ptr != NULL;
+	     ptr = (void *) query->Docs[++i])
+	    freeDocObj((DocObj *) ptr);
+    s_free(query->Docs);
 
-  if (query->TextList != NULL)	/* XXX revisit when textlist is fully defined */
-    for (i = 0,ptr = (void *)query->TextList[i]; ptr != NULL; ptr = (void *)query->TextList[++i])
-      s_free(ptr);
-  s_free(query->TextList);
+    if (query->TextList != NULL)	/* XXX revisit when textlist is fully defined */
+	for (i = 0, ptr = (void *) query->TextList[i];
+	     ptr != NULL;
+	     ptr = (void *) query->TextList[++i])
+	    s_free(ptr);
+    s_free(query->TextList);
 
-  s_free(query->BeginDateRange);
-  s_free(query->EndDateRange);
-  s_free(query);
+    s_free(query->BeginDateRange);
+    s_free(query->EndDateRange);
+    s_free(query);
 }
 
 /*----------------------------------------------------------------------*/
 
-DocObj*
-makeDocObjUsingWholeDocument(docID,type)
-any* docID;
-char* type;
+DocObj *makeDocObjUsingWholeDocument(any *docID,
+				     char *type)
 
 /* construct a document object using byte chunks - only for use by
    servers */
 {
-  DocObj* doc = (DocObj*)s_malloc((size_t)sizeof(DocObj));
-  doc->DocumentID = docID;		/* not copied! */
-  doc->Type = type;		/* not copied! */
-  doc->ChunkCode = CT_document;
-  return(doc);
+    DocObj *doc = S_MALLOC(DocObj);
+
+    doc->DocumentID = docID;	/* not copied! */
+    doc->Type = type;		/* not copied! */
+    doc->ChunkCode = CT_document;
+    return (doc);
 }
 
 /*----------------------------------------------------------------------*/
 
-DocObj*
-makeDocObjUsingLines(docID,type,start,end)
-any* docID;
-char* type;
-long start;
-long end;
+DocObj *makeDocObjUsingLines(any *docID,
+			     char *type,
+			     long start,
+			     long end)
 
 /* construct a document object using line chunks - only for use by
    servers */
 {
-  DocObj* doc = (DocObj*)s_malloc((size_t)sizeof(DocObj));
-  doc->ChunkCode = CT_line;
-  doc->DocumentID = docID;		/* not copied */
-  doc->Type = type;		/* not copied! */
-  doc->ChunkStart.Pos = start;
-  doc->ChunkEnd.Pos = end;
-  return(doc);
+    DocObj *doc = S_MALLOC(DocObj);
+
+    doc->ChunkCode = CT_line;
+    doc->DocumentID = docID;	/* not copied */
+    doc->Type = type;		/* not copied! */
+    doc->ChunkStart.Pos = start;
+    doc->ChunkEnd.Pos = end;
+    return (doc);
 }
 
 /*----------------------------------------------------------------------*/
 
-DocObj*
-makeDocObjUsingBytes(docID,type,start,end)
-any* docID;
-char* type;
-long start;
-long end;
+DocObj *makeDocObjUsingBytes(any *docID,
+			     char *type,
+			     long start,
+			     long end)
 
 /* construct a document object using byte chunks - only for use by
    servers */
 {
-  DocObj* doc = (DocObj*)s_malloc((size_t)sizeof(DocObj));
-  doc->ChunkCode = CT_byte;
-  doc->DocumentID = docID;		/* not copied */
-  doc->Type = type;		/* not copied! */
-  doc->ChunkStart.Pos = start;
-  doc->ChunkEnd.Pos = end;
-  return(doc);
+    DocObj *doc = S_MALLOC(DocObj);
+
+    doc->ChunkCode = CT_byte;
+    doc->DocumentID = docID;	/* not copied */
+    doc->Type = type;		/* not copied! */
+    doc->ChunkStart.Pos = start;
+    doc->ChunkEnd.Pos = end;
+    return (doc);
 }
 
 /*----------------------------------------------------------------------*/
 
-DocObj*
-makeDocObjUsingParagraphs(docID,type,start,end)
-any* docID;
-char* type;
-any* start;
-any* end;
+DocObj *makeDocObjUsingParagraphs(any *docID,
+				  char *type,
+				  any *start,
+				  any *end)
 
 /* construct a document object using byte chunks - only for use by
    servers */
 {
-  DocObj* doc = (DocObj*)s_malloc((size_t)sizeof(DocObj));
-  doc->ChunkCode = CT_paragraph;
-  doc->DocumentID = docID;		/* not copied */
-  doc->Type = type;
-  doc->ChunkStart.ID = start;
-  doc->ChunkEnd.ID = end;
-  return(doc);
+    DocObj *doc = S_MALLOC(DocObj);
+
+    doc->ChunkCode = CT_paragraph;
+    doc->DocumentID = docID;	/* not copied */
+    doc->Type = type;
+    doc->ChunkStart.ID = start;
+    doc->ChunkEnd.ID = end;
+    return (doc);
 }
 
 /*----------------------------------------------------------------------*/
 
-void
-freeDocObj(doc)
-DocObj* doc;
+void freeDocObj(DocObj *doc)
 
 /* free a docObj */
 {
-  freeAny(doc->DocumentID);
-  s_free(doc->Type);
-  if (doc->ChunkCode == CT_paragraph)
-    { freeAny(doc->ChunkStart.ID);
-      freeAny(doc->ChunkEnd.ID);
+    freeAny(doc->DocumentID);
+    s_free(doc->Type);
+    if (doc->ChunkCode == CT_paragraph) {
+	freeAny(doc->ChunkStart.ID);
+	freeAny(doc->ChunkEnd.ID);
     }
-  s_free(doc);
+    s_free(doc);
 }
 
 /*----------------------------------------------------------------------*/
 
-static char* writeDocObj PARAMS((DocObj* doc,char* buffer,long* len));
-
-static char*
-writeDocObj(doc,buffer,len)
-DocObj* doc;
-char* buffer;
-long* len;
+static char *writeDocObj(DocObj *doc,
+			 char *buffer,
+			 long *len)
 
 /* write as little as we can about the doc obj */
 {
-  char* buf = buffer;
+    char *buf = buffer;
 
-  /* we alwasy have to write the id, but its tag depends on if its a chunk */
-  if (doc->ChunkCode == CT_document)
-    buf = writeAny(doc->DocumentID,DT_DocumentID,buf,len);
-  else
-    buf = writeAny(doc->DocumentID,DT_DocumentIDChunk,buf,len);
+    /* we alwasy have to write the id, but its tag depends on if its a chunk */
+    if (doc->ChunkCode == CT_document)
+	buf = writeAny(doc->DocumentID, DT_DocumentID, buf, len);
+    else
+	buf = writeAny(doc->DocumentID, DT_DocumentIDChunk, buf, len);
 
-  if (doc->Type != NULL)
-    buf = writeString(doc->Type,DT_TYPE,buf,len);
+    if (doc->Type != NULL)
+	buf = writeString(doc->Type, DT_TYPE, buf, len);
 
-  switch (doc->ChunkCode)
-    { case CT_document:
+    switch (doc->ChunkCode) {
+    case CT_document:
 	/* do nothing - there is no chunk data */
 	break;
-      case CT_byte:
-      case CT_line:
-	buf = writeNum(doc->ChunkCode,DT_ChunkCode,buf,len);
-	buf = writeNum(doc->ChunkStart.Pos,DT_ChunkStartID,buf,len);
-	buf = writeNum(doc->ChunkEnd.Pos,DT_ChunkEndID,buf,len);
+    case CT_byte:
+    case CT_line:
+	buf = writeNum(doc->ChunkCode, DT_ChunkCode, buf, len);
+	buf = writeNum(doc->ChunkStart.Pos, DT_ChunkStartID, buf, len);
+	buf = writeNum(doc->ChunkEnd.Pos, DT_ChunkEndID, buf, len);
 	break;
-      case CT_paragraph:
-	buf = writeNum(doc->ChunkCode,DT_ChunkCode,buf,len);
-	buf = writeAny(doc->ChunkStart.ID,DT_ChunkStartID,buf,len);
-	buf = writeAny(doc->ChunkEnd.ID,DT_ChunkEndID,buf,len);
+    case CT_paragraph:
+	buf = writeNum(doc->ChunkCode, DT_ChunkCode, buf, len);
+	buf = writeAny(doc->ChunkStart.ID, DT_ChunkStartID, buf, len);
+	buf = writeAny(doc->ChunkEnd.ID, DT_ChunkEndID, buf, len);
 	break;
-      default:
+    default:
 	panic("Implementation error: unknown chuck type %ld",
 	      doc->ChunkCode);
 	break;
-      }
+    }
 
-  return(buf);
+    return (buf);
 }
 
 /*----------------------------------------------------------------------*/
 
-static char* readDocObj PARAMS((DocObj** doc,char* buffer));
-
-static char*
-readDocObj(doc,buffer)
-DocObj** doc;
-char* buffer;
+static char *readDocObj(DocObj **doc,
+			char *buffer)
 
 /* read whatever we have about the new document */
 {
-  char* buf = buffer;
-  data_tag tag;
+    char *buf = buffer;
+    data_tag tag;
 
-  *doc = (DocObj*)s_malloc((size_t)sizeof(DocObj));
+    *doc = S_MALLOC(DocObj);
 
-  tag = peekTag(buf);
-  buf = readAny(&((*doc)->DocumentID),buf);
+    tag = peekTag(buf);
+    buf = readAny(&((*doc)->DocumentID), buf);
 
-  if (tag == DT_DocumentID)
-    { (*doc)->ChunkCode = CT_document;
-      tag = peekTag(buf);
-      if (tag == DT_TYPE)	/* XXX depends on DT_TYPE != what comes next */
-	buf = readString(&((*doc)->Type),buf);
-      /* ChunkStart and ChunkEnd are undefined */
-    }
-  else if (tag == DT_DocumentIDChunk)
-    { boolean readParagraphs = false; /* for cleanup */
-      tag = peekTag(buf);
-      if (tag == DT_TYPE)	/* XXX depends on DT_TYPE != CT_FOO */
-	buf = readString(&((*doc)->Type),buf);
-      buf = readNum(&((*doc)->ChunkCode),buf);
-      switch ((*doc)->ChunkCode)
-	{ case CT_byte:
-	  case CT_line:
-	    buf = readNum(&((*doc)->ChunkStart.Pos),buf);
-	    buf = readNum(&((*doc)->ChunkEnd.Pos),buf);
+    if (tag == DT_DocumentID) {
+	(*doc)->ChunkCode = CT_document;
+	tag = peekTag(buf);
+	if (tag == DT_TYPE)	/* XXX depends on DT_TYPE != what comes next */
+	    buf = readString(&((*doc)->Type), buf);
+	/* ChunkStart and ChunkEnd are undefined */
+    } else if (tag == DT_DocumentIDChunk) {
+	boolean readParagraphs = false;		/* for cleanup */
+
+	tag = peekTag(buf);
+	if (tag == DT_TYPE)	/* XXX depends on DT_TYPE != CT_FOO */
+	    buf = readString(&((*doc)->Type), buf);
+	buf = readNum(&((*doc)->ChunkCode), buf);
+	switch ((*doc)->ChunkCode) {
+	case CT_byte:
+	case CT_line:
+	    buf = readNum(&((*doc)->ChunkStart.Pos), buf);
+	    buf = readNum(&((*doc)->ChunkEnd.Pos), buf);
 	    break;
-	  case CT_paragraph:
+	case CT_paragraph:
 	    readParagraphs = true;
-	    buf = readAny(&((*doc)->ChunkStart.ID),buf);
-	    buf = readAny(&((*doc)->ChunkEnd.ID),buf);
+	    buf = readAny(&((*doc)->ChunkStart.ID), buf);
+	    buf = readAny(&((*doc)->ChunkEnd.ID), buf);
 	    break;
-	  default:
+	default:
 	    freeAny((*doc)->DocumentID);
-	    if (readParagraphs)
-	      { freeAny((*doc)->ChunkStart.ID);
+	    if (readParagraphs) {
+		freeAny((*doc)->ChunkStart.ID);
 		freeAny((*doc)->ChunkEnd.ID);
-	      }
+	    }
 	    s_free(doc);
 	    REPORT_READ_ERROR(buf);
 	    break;
-	  }
-    }
-  else
-    { freeAny((*doc)->DocumentID);
-      s_free(*doc);
-      REPORT_READ_ERROR(buf);
+	}
+    } else {
+	freeAny((*doc)->DocumentID);
+	s_free(*doc);
+	REPORT_READ_ERROR(buf);
     }
-  return(buf);
+    return (buf);
 }
 
 /*----------------------------------------------------------------------*/
 
-char*
-writeSearchInfo(query,buffer,len)
-SearchAPDU* query;
-char* buffer;
-long* len;
+char *writeSearchInfo(SearchAPDU *query,
+		      char *buffer,
+		      long *len)
 
 /* write out a WAIS query (type 1 or 3) */
 {
-  if (strcmp(query->QueryType,QT_TextRetrievalQuery) == 0)
-    { return(writeAny((any*)query->Query,DT_Query,buffer,len));
-    }
-  else
-    { unsigned long header_len = userInfoTagSize(DT_UserInformationLength,
-						 DefWAISSearchSize);
-      char* buf = buffer + header_len;
-      WAISSearch* info = (WAISSearch*)query->Query;
-      unsigned long size;
-      long i;
-
-      RESERVE_SPACE_FOR_WAIS_HEADER(len);
-
-      buf = writeString(info->SeedWords,DT_SeedWords,buf,len);
-
-      if (info->Docs != NULL)
-      { for (i = 0; info->Docs[i] != NULL; i++)
-	  { buf = writeDocObj(info->Docs[i],buf,len);
-	  }
+    if (strcmp(query->QueryType, QT_TextRetrievalQuery) == 0) {
+	return (writeAny((any *) query->Query, DT_Query, buffer, len));
+    } else {
+	unsigned long header_len = userInfoTagSize(DT_UserInformationLength,
+						   DefWAISSearchSize);
+	char *buf = buffer + header_len;
+	WAISSearch *info = (WAISSearch *) query->Query;
+	unsigned long size;
+	long i;
+
+	RESERVE_SPACE_FOR_WAIS_HEADER(len);
+
+	buf = writeString(info->SeedWords, DT_SeedWords, buf, len);
+
+	if (info->Docs != NULL) {
+	    for (i = 0; info->Docs[i] != NULL; i++) {
+		buf = writeDocObj(info->Docs[i], buf, len);
+	    }
 	}
 
-      /* XXX text list */
-
-      buf = writeNum(info->DateFactor,DT_DateFactor,buf,len);
-      buf = writeString(info->BeginDateRange,DT_BeginDateRange,buf,len);
-      buf = writeString(info->EndDateRange,DT_EndDateRange,buf,len);
-      buf = writeNum(info->MaxDocumentsRetrieved,DT_MaxDocumentsRetrieved,buf,len);
+	/* XXX text list */
 
-      /* now write the header and size */
-      size = buf - buffer;
-      buf = writeUserInfoHeader(DT_UserInformationLength,size,header_len,buffer,len);
+	buf = writeNum(info->DateFactor,
+		       DT_DateFactor,
+		       buf,
+		       len);
+	buf = writeString(info->BeginDateRange,
+			  DT_BeginDateRange,
+			  buf,
+			  len);
+	buf = writeString(info->EndDateRange,
+			  DT_EndDateRange,
+			  buf,
+			  len);
+	buf = writeNum(info->MaxDocumentsRetrieved,
+		       DT_MaxDocumentsRetrieved,
+		       buf,
+		       len);
+
+	/* now write the header and size */
+	size = buf - buffer;
+	buf = writeUserInfoHeader(DT_UserInformationLength,
+				  size,
+				  header_len,
+				  buffer,
+				  len);
 
-      return(buf);
+	return (buf);
     }
 }
 
 /*----------------------------------------------------------------------*/
 
-char*
-readSearchInfo(info,buffer)
-void** info;
-char* buffer;
+char *readSearchInfo(void **info,
+		     char *buffer)
 
 /* read a WAIS query (type 1 or 3) */
 {
-  data_tag type = peekTag(buffer);
-  if (type == DT_Query)		/* this is a type 1 query */
-    { char* buf = buffer;
-      any* query = NULL;
-      buf = readAny(&query,buf);
-      *info = (void *)query;
-      return(buf);
-    }
-  else				/* a type 3 query */
-    { char* buf = buffer;
-      unsigned long size;
-      unsigned long headerSize;
-      data_tag tag1;
-      char* seedWords = NULL;
-      char* beginDateRange = NULL;
-      char* endDateRange = NULL;
-      long dateFactor,maxDocsRetrieved;
-      char** textList = NULL;
-      DocObj** docIDs = NULL;
-      DocObj* doc = NULL;
-      long docs = 0;
-      long i;
-      void* ptr = NULL;
-
-      dateFactor = maxDocsRetrieved = UNUSED;
-
-      buf = readUserInfoHeader(&tag1,&size,buf);
-      headerSize = buf - buffer;
-
-      while (buf < (buffer + size + headerSize))
-	{ data_tag tag = peekTag(buf);
-	  switch (tag)
-	    { case DT_SeedWords:
-		buf = readString(&seedWords,buf);
+    data_tag type = peekTag(buffer);
+
+    if (type == DT_Query)	/* this is a type 1 query */
+    {
+	char *buf = buffer;
+	any *query = NULL;
+
+	buf = readAny(&query, buf);
+	*info = (void *) query;
+	return (buf);
+    } else {			/* a type 3 query */
+	char *buf = buffer;
+	unsigned long size;
+	unsigned long headerSize;
+	data_tag tag1;
+	char *seedWords = NULL;
+	char *beginDateRange = NULL;
+	char *endDateRange = NULL;
+	long dateFactor, maxDocsRetrieved;
+	char **textList = NULL;
+	DocObj **docIDs = NULL;
+	DocObj *doc = NULL;
+	long docs = 0;
+	long i;
+	void *ptr = NULL;
+
+	dateFactor = maxDocsRetrieved = UNUSED;
+
+	buf = readUserInfoHeader(&tag1, &size, buf);
+	headerSize = buf - buffer;
+
+	while (buf < (buffer + size + headerSize)) {
+	    data_tag tag = peekTag(buf);
+
+	    switch (tag) {
+	    case DT_SeedWords:
+		buf = readString(&seedWords, buf);
 		break;
-	      case DT_DocumentID:
-	      case DT_DocumentIDChunk:
-		if (docIDs == NULL) /* create a new doc list */
-		  { docIDs = (DocObj**)s_malloc((size_t)sizeof(DocObj*) * 2);
-		  }
-		else		/* grow the doc list */
-		  { docIDs = (DocObj**)s_realloc((char*)docIDs,(size_t)(sizeof(DocObj*) * (docs + 2)));
-		  }
-		buf = readDocObj(&doc,buf);
-		if (buf == NULL)
-		  { s_free(seedWords);
+	    case DT_DocumentID:
+	    case DT_DocumentIDChunk:
+		if (docIDs == NULL)	/* create a new doc list */
+		{
+		    docIDs = S_MALLOC2(DocObj *);
+		} else {	/* grow the doc list */
+		    docIDs = S_REALLOC2(DocObj *, docIDs, docs);
+		}
+		buf = readDocObj(&doc, buf);
+		if (buf == NULL) {
+		    s_free(seedWords);
 		    s_free(beginDateRange);
 		    s_free(endDateRange);
 		    if (docIDs != NULL)
-		      for (i = 0,ptr = (void *)docIDs[i]; ptr != NULL; ptr = (void *)docIDs[++i])
-			freeDocObj((DocObj*)ptr);
+			for (i = 0, ptr = (void *) docIDs[i];
+			     ptr != NULL;
+			     ptr = (void *) docIDs[++i])
+			    freeDocObj((DocObj *) ptr);
 		    s_free(docIDs);
 		    /* XXX should also free textlist when it is fully defined */
-		  }
+		}
 		RETURN_ON_NULL(buf);
-		docIDs[docs++] = doc; /* put it in the list */
+		docIDs[docs++] = doc;	/* put it in the list */
 		docIDs[docs] = NULL;
 		break;
-	      case DT_TextList:
+	    case DT_TextList:
 		/* XXX */
 		break;
-	      case DT_DateFactor:
-		buf = readNum(&dateFactor,buf);
+	    case DT_DateFactor:
+		buf = readNum(&dateFactor, buf);
 		break;
-	      case DT_BeginDateRange:
-		buf = readString(&beginDateRange,buf);
+	    case DT_BeginDateRange:
+		buf = readString(&beginDateRange, buf);
 		break;
-	      case DT_EndDateRange:
-		buf = readString(&endDateRange,buf);
+	    case DT_EndDateRange:
+		buf = readString(&endDateRange, buf);
 		break;
-	      case DT_MaxDocumentsRetrieved:
-		buf = readNum(&maxDocsRetrieved,buf);
+	    case DT_MaxDocumentsRetrieved:
+		buf = readNum(&maxDocsRetrieved, buf);
 		break;
-	      default:
+	    default:
 		s_free(seedWords);
 		s_free(beginDateRange);
 		s_free(endDateRange);
 		if (docIDs != NULL)
-		  for (i = 0,ptr = (void *)docIDs[i]; ptr != NULL; ptr = (void *)docIDs[++i])
-		    freeDocObj((DocObj*)ptr);
+		    for (i = 0, ptr = (void *) docIDs[i];
+			 ptr != NULL;
+			 ptr = (void *) docIDs[++i])
+			freeDocObj((DocObj *) ptr);
 		s_free(docIDs);
 		/* XXX should also free textlist when it is fully defined */
 		REPORT_READ_ERROR(buf);
 		break;
-	      }
+	    }
 	}
 
-      *info = (void *)makeWAISSearch(seedWords,docIDs,textList,
-				     dateFactor,beginDateRange,endDateRange,
-				     maxDocsRetrieved);
-      return(buf);
+	*info = (void *) makeWAISSearch(seedWords, docIDs, textList,
+					dateFactor, beginDateRange, endDateRange,
+					maxDocsRetrieved);
+	return (buf);
     }
 }
 
 /*----------------------------------------------------------------------*/
 
-WAISDocumentHeader*
-makeWAISDocumentHeader(docID,
-		       versionNumber,
-		       score,
-		       bestMatch,
-		       docLen,
-		       lines,
-		       types,
-		       source,
-		       date,
-		       headline,
-		       originCity)
-any* docID;
-long versionNumber;
-long score;
-long bestMatch;
-long docLen;
-long lines;
-char** types;
-char* source;
-char* date;
-char* headline;
-char* originCity;
+WAISDocumentHeader *makeWAISDocumentHeader(any *docID,
+					   long versionNumber,
+					   long score,
+					   long bestMatch,
+					   long docLen,
+					   long lines,
+					   char **types,
+					   char *source,
+					   char *date,
+					   char *headline,
+					   char *originCity)
 
 /* construct a standard document header, note that no fields are copied!
    if the application needs to save these fields, it should copy them,
    or set the field in this object to NULL before freeing it.
  */
 {
-  WAISDocumentHeader* header =
-    (WAISDocumentHeader*)s_malloc((size_t)sizeof(WAISDocumentHeader));
+    WAISDocumentHeader *header = S_MALLOC(WAISDocumentHeader);
+
+    header->DocumentID = docID;
+    header->VersionNumber = versionNumber;
+    header->Score = score;
+    header->BestMatch = bestMatch;
+    header->DocumentLength = docLen;
+    header->Lines = lines;
+    header->Types = types;
+    header->Source = source;
+    header->Date = date;
+    header->Headline = headline;
+    header->OriginCity = originCity;
+
+    return (header);
+}
+
+/*----------------------------------------------------------------------*/
+
+void freeWAISDocumentHeader(WAISDocumentHeader *header)
+{
+    freeAny(header->DocumentID);
+    doList((void **) header->Types, fs_free);	/* can't use the macro here ! */
+    s_free(header->Types);
+    s_free(header->Source);
+    s_free(header->Date);
+    s_free(header->Headline);
+    s_free(header->OriginCity);
+    s_free(header);
+}
 
-  header->DocumentID = docID;
-  header->VersionNumber = versionNumber;
-  header->Score = score;
-  header->BestMatch = bestMatch;
-  header->DocumentLength = docLen;
-  header->Lines = lines;
-  header->Types = types;
-  header->Source = source;
-  header->Date = date;
-  header->Headline = headline;
-  header->OriginCity = originCity;
-
-  return(header);
-}
-
-/*----------------------------------------------------------------------*/
-
-void
-freeWAISDocumentHeader(header)
-WAISDocumentHeader* header;
-
-{
-  freeAny(header->DocumentID);
-  doList((void**)header->Types,fs_free); /* can't use the macro here ! */
-  s_free(header->Types);
-  s_free(header->Source);
-  s_free(header->Date);
-  s_free(header->Headline);
-  s_free(header->OriginCity);
-  s_free(header);
-}
-
-/*----------------------------------------------------------------------*/
-
-char*
-writeWAISDocumentHeader(header,buffer,len)
-WAISDocumentHeader* header;
-char* buffer;
-long* len;
-{
-  unsigned long header_len = userInfoTagSize(DT_DocumentHeaderGroup ,
-					     DefWAISDocHeaderSize);
-  char* buf = buffer + header_len;
-  unsigned long size1;
-
-  RESERVE_SPACE_FOR_WAIS_HEADER(len);
-
-  buf = writeAny(header->DocumentID,DT_DocumentID,buf,len);
-  buf = writeNum(header->VersionNumber,DT_VersionNumber,buf,len);
-  buf = writeNum(header->Score,DT_Score,buf,len);
-  buf = writeNum(header->BestMatch,DT_BestMatch,buf,len);
-  buf = writeNum(header->DocumentLength,DT_DocumentLength,buf,len);
-  buf = writeNum(header->Lines,DT_Lines,buf,len);
-  if (header->Types != NULL)
-    { long size;
-      char* ptr = NULL;
-      long i;
-      buf = writeTag(DT_TYPE_BLOCK,buf,len);
-      for (i = 0,size = 0,ptr = header->Types[i]; ptr != NULL; ptr = header->Types[++i])
-	{ long typeSize = strlen(ptr);
-	  size += writtenTagSize(DT_TYPE);
-	  size += writtenCompressedIntSize(typeSize);
-	  size += typeSize;
+/*----------------------------------------------------------------------*/
+
+char *writeWAISDocumentHeader(WAISDocumentHeader *header, char *buffer,
+			      long *len)
+{
+    unsigned long header_len = userInfoTagSize(DT_DocumentHeaderGroup,
+					       DefWAISDocHeaderSize);
+    char *buf = buffer + header_len;
+    unsigned long size1;
+
+    RESERVE_SPACE_FOR_WAIS_HEADER(len);
+
+    buf = writeAny(header->DocumentID, DT_DocumentID, buf, len);
+    buf = writeNum(header->VersionNumber, DT_VersionNumber, buf, len);
+    buf = writeNum(header->Score, DT_Score, buf, len);
+    buf = writeNum(header->BestMatch, DT_BestMatch, buf, len);
+    buf = writeNum(header->DocumentLength, DT_DocumentLength, buf, len);
+    buf = writeNum(header->Lines, DT_Lines, buf, len);
+    if (header->Types != NULL) {
+	long size;
+	char *ptr = NULL;
+	long i;
+
+	buf = writeTag(DT_TYPE_BLOCK, buf, len);
+	for (i = 0, size = 0, ptr = header->Types[i];
+	     ptr != NULL;
+	     ptr = header->Types[++i]) {
+	    long typeSize = strlen(ptr);
+
+	    size += writtenTagSize(DT_TYPE);
+	    size += writtenCompressedIntSize(typeSize);
+	    size += typeSize;
 	}
-      buf = writeCompressedInteger((unsigned long)size,buf,len);
-      for (i = 0,ptr = header->Types[i]; ptr != NULL; ptr = header->Types[++i])
-	buf = writeString(ptr,DT_TYPE,buf,len);
-    }
-  buf = writeString(header->Source,DT_Source,buf,len);
-  buf = writeString(header->Date,DT_Date,buf,len);
-  buf = writeString(header->Headline,DT_Headline,buf,len);
-  buf = writeString(header->OriginCity,DT_OriginCity,buf,len);
-
-  /* now write the header and size */
-  size1 = buf - buffer;
-  buf = writeUserInfoHeader(DT_DocumentHeaderGroup,size1,header_len,buffer,len);
-
-  return(buf);
-}
-
-/*----------------------------------------------------------------------*/
-
-char*
-readWAISDocumentHeader(header,buffer)
-WAISDocumentHeader** header;
-char* buffer;
-{
-  char* buf = buffer;
-  unsigned long size1;
-  unsigned long headerSize;
-  data_tag tag1;
-  any* docID = NULL;
-  long versionNumber,score,bestMatch,docLength,lines;
-  char** types = NULL;
-  char *source = NULL;
-  char *date = NULL;
-  char *headline = NULL;
-  char *originCity = NULL;
-
-  versionNumber = score = bestMatch = docLength = lines = UNUSED;
-
-  buf = readUserInfoHeader(&tag1,&size1,buf);
-  headerSize = buf - buffer;
-
-  while (buf < (buffer + size1 + headerSize))
-    { data_tag tag = peekTag(buf);
-      switch (tag)
-	{ case DT_DocumentID:
-	    buf = readAny(&docID,buf);
-	    break;
-	  case DT_VersionNumber:
-	    buf = readNum(&versionNumber,buf);
-	    break;
-	  case DT_Score:
-	    buf = readNum(&score,buf);
-	    break;
-	  case DT_BestMatch:
-	    buf = readNum(&bestMatch,buf);
-	    break;
-	  case DT_DocumentLength:
-	    buf = readNum(&docLength,buf);
-	    break;
-	  case DT_Lines:
-	    buf = readNum(&lines,buf);
-	    break;
-	  case DT_TYPE_BLOCK:
-	    { unsigned long size = -1;
-	      long numTypes = 0;
-	      buf = readTag(&tag,buf);
-	      buf = readCompressedInteger(&size,buf);
-	      while (size > 0)
-		{ char* type = NULL;
-		  char* originalBuf = buf;
-		  buf = readString(&type,buf);
-		  types = (char**)s_realloc(types,(size_t)(sizeof(char*) * (numTypes + 2)));
-		  types[numTypes++] = type;
-		  types[numTypes] = NULL;
-		  size -= (buf - originalBuf);
+	buf = writeCompressedInteger((unsigned long) size, buf, len);
+	for (i = 0, ptr = header->Types[i]; ptr != NULL; ptr = header->Types[++i])
+	    buf = writeString(ptr, DT_TYPE, buf, len);
+    }
+    buf = writeString(header->Source, DT_Source, buf, len);
+    buf = writeString(header->Date, DT_Date, buf, len);
+    buf = writeString(header->Headline, DT_Headline, buf, len);
+    buf = writeString(header->OriginCity, DT_OriginCity, buf, len);
+
+    /* now write the header and size */
+    size1 = buf - buffer;
+    buf = writeUserInfoHeader(DT_DocumentHeaderGroup,
+			      size1,
+			      header_len,
+			      buffer,
+			      len);
+
+    return (buf);
+}
+
+/*----------------------------------------------------------------------*/
+
+char *readWAISDocumentHeader(WAISDocumentHeader **header, char *buffer)
+{
+    char *buf = buffer;
+    unsigned long size1;
+    unsigned long headerSize;
+    data_tag tag1;
+    any *docID = NULL;
+    long versionNumber, score, bestMatch, docLength, lines;
+    char **types = NULL;
+    char *source = NULL;
+    char *date = NULL;
+    char *headline = NULL;
+    char *originCity = NULL;
+
+    versionNumber = score = bestMatch = docLength = lines = UNUSED;
+
+    buf = readUserInfoHeader(&tag1, &size1, buf);
+    headerSize = buf - buffer;
+
+    while (buf < (buffer + size1 + headerSize)) {
+	data_tag tag = peekTag(buf);
+
+	switch (tag) {
+	case DT_DocumentID:
+	    buf = readAny(&docID, buf);
+	    break;
+	case DT_VersionNumber:
+	    buf = readNum(&versionNumber, buf);
+	    break;
+	case DT_Score:
+	    buf = readNum(&score, buf);
+	    break;
+	case DT_BestMatch:
+	    buf = readNum(&bestMatch, buf);
+	    break;
+	case DT_DocumentLength:
+	    buf = readNum(&docLength, buf);
+	    break;
+	case DT_Lines:
+	    buf = readNum(&lines, buf);
+	    break;
+	case DT_TYPE_BLOCK:
+	    {
+		unsigned long size = -1;
+		long numTypes = 0;
+
+		buf = readTag(&tag, buf);
+		buf = readCompressedInteger(&size, buf);
+		while (size > 0) {
+		    char *type = NULL;
+		    char *originalBuf = buf;
+
+		    buf = readString(&type, buf);
+		    types = S_REALLOC2(char *, types, numTypes);
+
+		    types[numTypes++] = type;
+		    types[numTypes] = NULL;
+		    size -= (buf - originalBuf);
 		}
 	    }
 	    /* FALLTHRU */
-	  case DT_Source:
-	    buf = readString(&source,buf);
+	case DT_Source:
+	    buf = readString(&source, buf);
 	    break;
-	  case DT_Date:
-	    buf = readString(&date,buf);
+	case DT_Date:
+	    buf = readString(&date, buf);
 	    break;
-	  case DT_Headline:
-	    buf = readString(&headline,buf);
+	case DT_Headline:
+	    buf = readString(&headline, buf);
 	    break;
-	  case DT_OriginCity:
-	    buf = readString(&originCity,buf);
+	case DT_OriginCity:
+	    buf = readString(&originCity, buf);
 	    break;
-	  default:
+	default:
 	    freeAny(docID);
 	    s_free(source);
 	    s_free(date);
@@ -886,348 +854,336 @@
 	    s_free(originCity);
 	    REPORT_READ_ERROR(buf);
 	    break;
-	  }
+	}
     }
 
-  *header = makeWAISDocumentHeader(docID,versionNumber,score,bestMatch,
-				   docLength,lines,types,source,date,headline,
-				   originCity);
-  return(buf);
+    *header = makeWAISDocumentHeader(docID, versionNumber, score, bestMatch,
+				     docLength, lines, types, source, date, headline,
+				     originCity);
+    return (buf);
 }
 
 /*----------------------------------------------------------------------*/
 
-WAISDocumentShortHeader*
-makeWAISDocumentShortHeader(docID,
-			    versionNumber,
-			    score,
-			    bestMatch,
-			    docLen,
-			    lines)
-any* docID;
-long versionNumber;
-long score;
-long bestMatch;
-long docLen;
-long lines;
+WAISDocumentShortHeader *makeWAISDocumentShortHeader(any *docID,
+						     long versionNumber,
+						     long score,
+						     long bestMatch,
+						     long docLen,
+						     long lines)
 /* construct a short document header, note that no fields are copied!
    if the application needs to save these fields, it should copy them,
    or set the field in this object to NULL before freeing it.
  */
 {
-  WAISDocumentShortHeader* header =
-    (WAISDocumentShortHeader*)s_malloc((size_t)sizeof(WAISDocumentShortHeader));
+    WAISDocumentShortHeader *header = S_MALLOC(WAISDocumentShortHeader);
 
-  header->DocumentID = docID;
-  header->VersionNumber = versionNumber;
-  header->Score = score;
-  header->BestMatch = bestMatch;
-  header->DocumentLength = docLen;
-  header->Lines = lines;
+    header->DocumentID = docID;
+    header->VersionNumber = versionNumber;
+    header->Score = score;
+    header->BestMatch = bestMatch;
+    header->DocumentLength = docLen;
+    header->Lines = lines;
 
-  return(header);
+    return (header);
 }
 
 /*----------------------------------------------------------------------*/
 
-void
-freeWAISDocumentShortHeader(header)
-WAISDocumentShortHeader* header;
+void freeWAISDocumentShortHeader(WAISDocumentShortHeader *header)
 {
-  freeAny(header->DocumentID);
-  s_free(header);
+    freeAny(header->DocumentID);
+    s_free(header);
 }
 
 /*----------------------------------------------------------------------*/
 
-char*
-writeWAISDocumentShortHeader(header,buffer,len)
-WAISDocumentShortHeader* header;
-char* buffer;
-long* len;
+char *writeWAISDocumentShortHeader(WAISDocumentShortHeader *header, char *buffer,
+				   long *len)
 {
-  unsigned long header_len = userInfoTagSize(DT_DocumentShortHeaderGroup ,
-					     DefWAISShortHeaderSize);
-  char* buf = buffer + header_len;
-  unsigned long size;
+    unsigned long header_len = userInfoTagSize(DT_DocumentShortHeaderGroup,
+					       DefWAISShortHeaderSize);
+    char *buf = buffer + header_len;
+    unsigned long size;
 
-  RESERVE_SPACE_FOR_WAIS_HEADER(len);
+    RESERVE_SPACE_FOR_WAIS_HEADER(len);
 
-  buf = writeAny(header->DocumentID,DT_DocumentID,buf,len);
-  buf = writeNum(header->VersionNumber,DT_VersionNumber,buf,len);
-  buf = writeNum(header->Score,DT_Score,buf,len);
-  buf = writeNum(header->BestMatch,DT_BestMatch,buf,len);
-  buf = writeNum(header->DocumentLength,DT_DocumentLength,buf,len);
-  buf = writeNum(header->Lines,DT_Lines,buf,len);
+    buf = writeAny(header->DocumentID, DT_DocumentID, buf, len);
+    buf = writeNum(header->VersionNumber, DT_VersionNumber, buf, len);
+    buf = writeNum(header->Score, DT_Score, buf, len);
+    buf = writeNum(header->BestMatch, DT_BestMatch, buf, len);
+    buf = writeNum(header->DocumentLength, DT_DocumentLength, buf, len);
+    buf = writeNum(header->Lines, DT_Lines, buf, len);
 
-  /* now write the header and size */
-  size = buf - buffer;
-  buf = writeUserInfoHeader(DT_DocumentShortHeaderGroup,size,header_len,buffer,len);
+    /* now write the header and size */
+    size = buf - buffer;
+    buf = writeUserInfoHeader(DT_DocumentShortHeaderGroup,
+			      size,
+			      header_len,
+			      buffer,
+			      len);
 
-  return(buf);
+    return (buf);
 }
 
 /*----------------------------------------------------------------------*/
 
-char*
-readWAISDocumentShortHeader(header,buffer)
-WAISDocumentShortHeader** header;
-char* buffer;
+char *readWAISDocumentShortHeader(WAISDocumentShortHeader **header, char *buffer)
 {
-  char* buf = buffer;
-  unsigned long size;
-  unsigned long headerSize;
-  data_tag tag1;
-  any* docID = NULL;
-  long versionNumber,score,bestMatch,docLength,lines;
+    char *buf = buffer;
+    unsigned long size;
+    unsigned long headerSize;
+    data_tag tag1;
+    any *docID = NULL;
+    long versionNumber, score, bestMatch, docLength, lines;
+
+    versionNumber = score = bestMatch = docLength = lines = UNUSED;
 
-  versionNumber = score = bestMatch = docLength = lines = UNUSED;
+    buf = readUserInfoHeader(&tag1, &size, buf);
+    headerSize = buf - buffer;
 
-  buf = readUserInfoHeader(&tag1,&size,buf);
-  headerSize = buf - buffer;
+    while (buf < (buffer + size + headerSize)) {
+	data_tag tag = peekTag(buf);
 
-  while (buf < (buffer + size + headerSize))
-    { data_tag tag = peekTag(buf);
-      switch (tag)
-	{ case DT_DocumentID:
-	    buf = readAny(&docID,buf);
+	switch (tag) {
+	case DT_DocumentID:
+	    buf = readAny(&docID, buf);
 	    break;
-	  case DT_VersionNumber:
-	    buf = readNum(&versionNumber,buf);
+	case DT_VersionNumber:
+	    buf = readNum(&versionNumber, buf);
 	    break;
-	  case DT_Score:
-	    buf = readNum(&score,buf);
+	case DT_Score:
+	    buf = readNum(&score, buf);
 	    break;
-	  case DT_BestMatch:
-	    buf = readNum(&bestMatch,buf);
+	case DT_BestMatch:
+	    buf = readNum(&bestMatch, buf);
 	    break;
-	  case DT_DocumentLength:
-	    buf = readNum(&docLength,buf);
+	case DT_DocumentLength:
+	    buf = readNum(&docLength, buf);
 	    break;
-	  case DT_Lines:
-	    buf = readNum(&lines,buf);
+	case DT_Lines:
+	    buf = readNum(&lines, buf);
 	    break;
-	  default:
+	default:
 	    freeAny(docID);
 	    REPORT_READ_ERROR(buf);
 	    break;
-	  }
+	}
     }
 
-  *header = makeWAISDocumentShortHeader(docID,versionNumber,score,bestMatch,
-					docLength,lines);
-  return(buf);
+    *header = makeWAISDocumentShortHeader(docID, versionNumber, score, bestMatch,
+					  docLength, lines);
+    return (buf);
 }
 
 /*----------------------------------------------------------------------*/
 
-WAISDocumentLongHeader*
-makeWAISDocumentLongHeader(docID,
-			   versionNumber,
-			   score,
-			   bestMatch,
-			   docLen,
-			   lines,
-			   types,
-			   source,
-			   date,
-			   headline,
-			   originCity,
-			   stockCodes,
-			   companyCodes,
-			   industryCodes)
-any* docID;
-long versionNumber;
-long score;
-long bestMatch;
-long docLen;
-long lines;
-char** types;
-char* source;
-char* date;
-char* headline;
-char* originCity;
-char* stockCodes;
-char* companyCodes;
-char* industryCodes;
+WAISDocumentLongHeader *makeWAISDocumentLongHeader(any *docID,
+						   long versionNumber,
+						   long score,
+						   long bestMatch,
+						   long docLen,
+						   long lines,
+						   char **types,
+						   char *source,
+						   char *date,
+						   char *headline,
+						   char *originCity,
+						   char *stockCodes,
+						   char *companyCodes,
+						   char *industryCodes)
 /* construct a long document header, note that no fields are copied!
    if the application needs to save these fields, it should copy them,
    or set the field in this object to NULL before freeing it.
  */
 {
-  WAISDocumentLongHeader* header =
-    (WAISDocumentLongHeader*)s_malloc((size_t)sizeof(WAISDocumentLongHeader));
+    WAISDocumentLongHeader *header = S_MALLOC(WAISDocumentLongHeader);
+
+    header->DocumentID = docID;
+    header->VersionNumber = versionNumber;
+    header->Score = score;
+    header->BestMatch = bestMatch;
+    header->DocumentLength = docLen;
+    header->Lines = lines;
+    header->Types = types;
+    header->Source = source;
+    header->Date = date;
+    header->Headline = headline;
+    header->OriginCity = originCity;
+    header->StockCodes = stockCodes;
+    header->CompanyCodes = companyCodes;
+    header->IndustryCodes = industryCodes;
+
+    return (header);
+}
+
+/*----------------------------------------------------------------------*/
 
-  header->DocumentID = docID;
-  header->VersionNumber = versionNumber;
-  header->Score = score;
-  header->BestMatch = bestMatch;
-  header->DocumentLength = docLen;
-  header->Lines = lines;
-  header->Types = types;
-  header->Source = source;
-  header->Date = date;
-  header->Headline = headline;
-  header->OriginCity = originCity;
-  header->StockCodes = stockCodes;
-  header->CompanyCodes = companyCodes;
-  header->IndustryCodes = industryCodes;
-
-  return(header);
-}
-
-/*----------------------------------------------------------------------*/
-
-void
-freeWAISDocumentLongHeader(header)
-WAISDocumentLongHeader* header;
-{
-  freeAny(header->DocumentID);
-  doList((void**)header->Types,fs_free); /* can't use the macro here! */
-  s_free(header->Source);
-  s_free(header->Date);
-  s_free(header->Headline);
-  s_free(header->OriginCity);
-  s_free(header->StockCodes);
-  s_free(header->CompanyCodes);
-  s_free(header->IndustryCodes);
-  s_free(header);
-}
-
-/*----------------------------------------------------------------------*/
-
-char*
-writeWAISDocumentLongHeader(header,buffer,len)
-WAISDocumentLongHeader* header;
-char* buffer;
-long* len;
-{
-  unsigned long header_len = userInfoTagSize(DT_DocumentLongHeaderGroup ,
-					     DefWAISLongHeaderSize);
-  char* buf = buffer + header_len;
-  unsigned long size1;
-
-  RESERVE_SPACE_FOR_WAIS_HEADER(len);
-
-  buf = writeAny(header->DocumentID,DT_DocumentID,buf,len);
-  buf = writeNum(header->VersionNumber,DT_VersionNumber,buf,len);
-  buf = writeNum(header->Score,DT_Score,buf,len);
-  buf = writeNum(header->BestMatch,DT_BestMatch,buf,len);
-  buf = writeNum(header->DocumentLength,DT_DocumentLength,buf,len);
-  buf = writeNum(header->Lines,DT_Lines,buf,len);
-  if (header->Types != NULL)
-    { long size;
-      char* ptr = NULL;
-      long i;
-      buf = writeTag(DT_TYPE_BLOCK,buf,len);
-      for (i = 0,size = 0,ptr = header->Types[i]; ptr != NULL; ptr = header->Types[++i])
-	{ long typeSize = strlen(ptr);
-	  size += writtenTagSize(DT_TYPE);
-	  size += writtenCompressedIntSize(typeSize);
-	  size += typeSize;
+void freeWAISDocumentLongHeader(WAISDocumentLongHeader *header)
+{
+    freeAny(header->DocumentID);
+    doList((void **) header->Types, fs_free);	/* can't use the macro here! */
+    s_free(header->Source);
+    s_free(header->Date);
+    s_free(header->Headline);
+    s_free(header->OriginCity);
+    s_free(header->StockCodes);
+    s_free(header->CompanyCodes);
+    s_free(header->IndustryCodes);
+    s_free(header);
+}
+
+/*----------------------------------------------------------------------*/
+
+char *writeWAISDocumentLongHeader(WAISDocumentLongHeader *header, char *buffer,
+				  long *len)
+{
+    unsigned long header_len = userInfoTagSize(DT_DocumentLongHeaderGroup,
+					       DefWAISLongHeaderSize);
+    char *buf = buffer + header_len;
+    unsigned long size1;
+
+    RESERVE_SPACE_FOR_WAIS_HEADER(len);
+
+    buf = writeAny(header->DocumentID, DT_DocumentID, buf, len);
+    buf = writeNum(header->VersionNumber, DT_VersionNumber, buf, len);
+    buf = writeNum(header->Score, DT_Score, buf, len);
+    buf = writeNum(header->BestMatch, DT_BestMatch, buf, len);
+    buf = writeNum(header->DocumentLength, DT_DocumentLength, buf, len);
+    buf = writeNum(header->Lines, DT_Lines, buf, len);
+    if (header->Types != NULL) {
+	long size;
+	char *ptr = NULL;
+	long i;
+
+	buf = writeTag(DT_TYPE_BLOCK, buf, len);
+	for (i = 0, size = 0, ptr = header->Types[i];
+	     ptr != NULL;
+	     ptr = header->Types[++i]) {
+	    long typeSize = strlen(ptr);
+
+	    size += writtenTagSize(DT_TYPE);
+	    size += writtenCompressedIntSize(typeSize);
+	    size += typeSize;
 	}
-      buf = writeCompressedInteger((unsigned long)size,buf,len);
-      for (i = 0,ptr = header->Types[i]; ptr != NULL; ptr = header->Types[++i])
-	buf = writeString(ptr,DT_TYPE,buf,len);
-    }
-  buf = writeString(header->Source,DT_Source,buf,len);
-  buf = writeString(header->Date,DT_Date,buf,len);
-  buf = writeString(header->Headline,DT_Headline,buf,len);
-  buf = writeString(header->OriginCity,DT_OriginCity,buf,len);
-  buf = writeString(header->StockCodes,DT_StockCodes,buf,len);
-  buf = writeString(header->CompanyCodes,DT_CompanyCodes,buf,len);
-  buf = writeString(header->IndustryCodes,DT_IndustryCodes,buf,len);
-
-  /* now write the header and size */
-  size1 = buf - buffer;
-  buf = writeUserInfoHeader(DT_DocumentLongHeaderGroup,size1,header_len,buffer,len);
-
-  return(buf);
-}
-
-/*----------------------------------------------------------------------*/
-
-char*
-readWAISDocumentLongHeader(header,buffer)
-WAISDocumentLongHeader** header;
-char* buffer;
-{
-  char* buf = buffer;
-  unsigned long size1;
-  unsigned long headerSize;
-  data_tag tag1;
-  any* docID;
-  long versionNumber,score,bestMatch,docLength,lines;
-  char **types;
-  char *source,*date,*headline,*originCity,*stockCodes,*companyCodes,*industryCodes;
-
-  docID = NULL;
-  versionNumber = score = bestMatch = docLength = lines = UNUSED;
-  types = NULL;
-  source = date = headline = originCity = stockCodes = companyCodes = industryCodes = NULL;
-
-  buf = readUserInfoHeader(&tag1,&size1,buf);
-  headerSize = buf - buffer;
-
-  while (buf < (buffer + size1 + headerSize))
-    { data_tag tag = peekTag(buf);
-      switch (tag)
-	{ case DT_DocumentID:
-	    buf = readAny(&docID,buf);
-	    break;
-	  case DT_VersionNumber:
-	    buf = readNum(&versionNumber,buf);
-	    break;
-	  case DT_Score:
-	    buf = readNum(&score,buf);
-	    break;
-	  case DT_BestMatch:
-	    buf = readNum(&bestMatch,buf);
-	    break;
-	  case DT_DocumentLength:
-	    buf = readNum(&docLength,buf);
-	    break;
-	  case DT_Lines:
-	    buf = readNum(&lines,buf);
-	    break;
-	  case DT_TYPE_BLOCK:
-	    { unsigned long size = -1;
-	      long numTypes = 0;
-	      buf = readTag(&tag,buf);
-	      readCompressedInteger(&size,buf);
-	      while (size > 0)
-		{ char* type = NULL;
-		  char* originalBuf = buf;
-		  buf = readString(&type,buf);
-		  types = (char**)s_realloc(types,(size_t)(sizeof(char*) * (numTypes + 2)));
-		  types[numTypes++] = type;
-		  types[numTypes] = NULL;
-		  size -= (buf - originalBuf);
+	buf = writeCompressedInteger((unsigned long) size, buf, len);
+	for (i = 0, ptr = header->Types[i]; ptr != NULL; ptr = header->Types[++i])
+	    buf = writeString(ptr, DT_TYPE, buf, len);
+    }
+    buf = writeString(header->Source, DT_Source, buf, len);
+    buf = writeString(header->Date, DT_Date, buf, len);
+    buf = writeString(header->Headline, DT_Headline, buf, len);
+    buf = writeString(header->OriginCity, DT_OriginCity, buf, len);
+    buf = writeString(header->StockCodes, DT_StockCodes, buf, len);
+    buf = writeString(header->CompanyCodes, DT_CompanyCodes, buf, len);
+    buf = writeString(header->IndustryCodes, DT_IndustryCodes, buf, len);
+
+    /* now write the header and size */
+    size1 = buf - buffer;
+    buf = writeUserInfoHeader(DT_DocumentLongHeaderGroup,
+			      size1,
+			      header_len,
+			      buffer,
+			      len);
+
+    return (buf);
+}
+
+/*----------------------------------------------------------------------*/
+
+char *readWAISDocumentLongHeader(WAISDocumentLongHeader **header, char *buffer)
+{
+    char *buf = buffer;
+    unsigned long size1;
+    unsigned long headerSize;
+    data_tag tag1;
+    any *docID;
+    long versionNumber, score, bestMatch, docLength, lines;
+    char **types;
+    char *source, *date, *headline, *originCity, *stockCodes, *companyCodes, *industryCodes;
+
+    docID = NULL;
+    versionNumber =
+	score =
+	bestMatch =
+	docLength =
+	lines = UNUSED;
+    types = NULL;
+    source =
+	date =
+	headline =
+	originCity =
+	stockCodes =
+	companyCodes =
+	industryCodes = NULL;
+
+    buf = readUserInfoHeader(&tag1, &size1, buf);
+    headerSize = buf - buffer;
+
+    while (buf < (buffer + size1 + headerSize)) {
+	data_tag tag = peekTag(buf);
+
+	switch (tag) {
+	case DT_DocumentID:
+	    buf = readAny(&docID, buf);
+	    break;
+	case DT_VersionNumber:
+	    buf = readNum(&versionNumber, buf);
+	    break;
+	case DT_Score:
+	    buf = readNum(&score, buf);
+	    break;
+	case DT_BestMatch:
+	    buf = readNum(&bestMatch, buf);
+	    break;
+	case DT_DocumentLength:
+	    buf = readNum(&docLength, buf);
+	    break;
+	case DT_Lines:
+	    buf = readNum(&lines, buf);
+	    break;
+	case DT_TYPE_BLOCK:
+	    {
+		unsigned long size = -1;
+		long numTypes = 0;
+
+		buf = readTag(&tag, buf);
+		readCompressedInteger(&size, buf);
+		while (size > 0) {
+		    char *type = NULL;
+		    char *originalBuf = buf;
+
+		    buf = readString(&type, buf);
+		    types = S_REALLOC2(char *, types, numTypes);
+
+		    types[numTypes++] = type;
+		    types[numTypes] = NULL;
+		    size -= (buf - originalBuf);
 		}
 	    }
 	    /* FALLTHRU */
-	  case DT_Source:
-	    buf = readString(&source,buf);
+	case DT_Source:
+	    buf = readString(&source, buf);
 	    break;
-	  case DT_Date:
-	    buf = readString(&date,buf);
+	case DT_Date:
+	    buf = readString(&date, buf);
 	    break;
-	  case DT_Headline:
-	    buf = readString(&headline,buf);
+	case DT_Headline:
+	    buf = readString(&headline, buf);
 	    break;
-	  case DT_OriginCity:
-	    buf = readString(&originCity,buf);
+	case DT_OriginCity:
+	    buf = readString(&originCity, buf);
 	    break;
-	  case DT_StockCodes:
-	    buf = readString(&stockCodes,buf);
+	case DT_StockCodes:
+	    buf = readString(&stockCodes, buf);
 	    break;
-	  case DT_CompanyCodes:
-	    buf = readString(&companyCodes,buf);
+	case DT_CompanyCodes:
+	    buf = readString(&companyCodes, buf);
 	    break;
-	  case DT_IndustryCodes:
-	    buf = readString(&industryCodes,buf);
+	case DT_IndustryCodes:
+	    buf = readString(&industryCodes, buf);
 	    break;
-	  default:
+	default:
 	    freeAny(docID);
 	    s_free(source);
 	    s_free(date);
@@ -1238,773 +1194,831 @@
 	    s_free(industryCodes);
 	    REPORT_READ_ERROR(buf);
 	    break;
-	  }
+	}
+    }
+
+    *header = makeWAISDocumentLongHeader(docID,
+					 versionNumber,
+					 score,
+					 bestMatch,
+					 docLength,
+					 lines,
+					 types,
+					 source,
+					 date,
+					 headline,
+					 originCity,
+					 stockCodes,
+					 companyCodes,
+					 industryCodes);
+    return (buf);
+}
+
+/*----------------------------------------------------------------------*/
+
+WAISSearchResponse *
+  makeWAISSearchResponse(
+			    char *seedWordsUsed,
+			    WAISDocumentHeader **docHeaders,
+			    WAISDocumentShortHeader **shortHeaders,
+			    WAISDocumentLongHeader **longHeaders,
+			    WAISDocumentText **text,
+			    WAISDocumentHeadlines **headlines,
+			    WAISDocumentCodes **codes,
+			    diagnosticRecord ** diagnostics)
+{
+    WAISSearchResponse *response = S_MALLOC(WAISSearchResponse);
+
+    response->SeedWordsUsed = seedWordsUsed;
+    response->DocHeaders = docHeaders;
+    response->ShortHeaders = shortHeaders;
+    response->LongHeaders = longHeaders;
+    response->Text = text;
+    response->Headlines = headlines;
+    response->Codes = codes;
+    response->Diagnostics = diagnostics;
+
+    return (response);
+}
+
+/*----------------------------------------------------------------------*/
+
+void freeWAISSearchResponse(WAISSearchResponse * response)
+{
+    void *ptr = NULL;
+    long i;
+
+    s_free(response->SeedWordsUsed);
+
+    if (response->DocHeaders != NULL)
+	for (i = 0, ptr = (void *) response->DocHeaders[i];
+	     ptr != NULL;
+	     ptr = (void *) response->DocHeaders[++i])
+	    freeWAISDocumentHeader((WAISDocumentHeader *) ptr);
+    s_free(response->DocHeaders);
+
+    if (response->ShortHeaders != NULL)
+	for (i = 0, ptr = (void *) response->ShortHeaders[i];
+	     ptr != NULL;
+	     ptr = (void *) response->ShortHeaders[++i])
+	    freeWAISDocumentShortHeader((WAISDocumentShortHeader *) ptr);
+    s_free(response->ShortHeaders);
+
+    if (response->LongHeaders != NULL)
+	for (i = 0, ptr = (void *) response->LongHeaders[i];
+	     ptr != NULL;
+	     ptr = (void *) response->LongHeaders[++i])
+	    freeWAISDocumentLongHeader((WAISDocumentLongHeader *) ptr);
+    s_free(response->LongHeaders);
+
+    if (response->Text != NULL)
+	for (i = 0, ptr = (void *) response->Text[i];
+	     ptr != NULL;
+	     ptr = (void *) response->Text[++i])
+	    freeWAISDocumentText((WAISDocumentText *) ptr);
+    s_free(response->Text);
+
+    if (response->Headlines != NULL)
+	for (i = 0, ptr = (void *) response->Headlines[i];
+	     ptr != NULL;
+	     ptr = (void *) response->Headlines[++i])
+	    freeWAISDocumentHeadlines((WAISDocumentHeadlines *) ptr);
+    s_free(response->Headlines);
+
+    if (response->Codes != NULL)
+	for (i = 0, ptr = (void *) response->Codes[i];
+	     ptr != NULL;
+	     ptr = (void *) response->Codes[++i])
+	    freeWAISDocumentCodes((WAISDocumentCodes *) ptr);
+    s_free(response->Codes);
+
+    if (response->Diagnostics != NULL)
+	for (i = 0, ptr = (void *) response->Diagnostics[i];
+	     ptr != NULL;
+	     ptr = (void *) response->Diagnostics[++i])
+	    freeDiag((diagnosticRecord *) ptr);
+    s_free(response->Diagnostics);
+
+    s_free(response);
+}
+
+/*----------------------------------------------------------------------*/
+
+char *writeSearchResponseInfo(SearchResponseAPDU *query,
+			      char *buffer,
+			      long *len)
+{
+    unsigned long header_len = userInfoTagSize(DT_UserInformationLength,
+					       DefWAISSearchResponseSize);
+    char *buf = buffer + header_len;
+    WAISSearchResponse *info = (WAISSearchResponse *) query->DatabaseDiagnosticRecords;
+    unsigned long size;
+    void *header = NULL;
+    long i;
+
+    RESERVE_SPACE_FOR_WAIS_HEADER(len);
+
+    buf = writeString(info->SeedWordsUsed, DT_SeedWordsUsed, buf, len);
+
+    /* write out all the headers */
+    if (info->DocHeaders != NULL) {
+	for (i = 0, header = (void *) info->DocHeaders[i];
+	     header != NULL;
+	     header = (void *) info->DocHeaders[++i])
+	    buf = writeWAISDocumentHeader((WAISDocumentHeader *) header, buf, len);
+    }
+
+    if (info->ShortHeaders != NULL) {
+	for (i = 0, header = (void *) info->ShortHeaders[i];
+	     header != NULL;
+	     header = (void *) info->ShortHeaders[++i])
+	    buf = writeWAISDocumentShortHeader((WAISDocumentShortHeader *) header,
+					       buf,
+					       len);
+    }
+
+    if (info->LongHeaders != NULL) {
+	for (i = 0, header = (void *) info->LongHeaders[i];
+	     header != NULL;
+	     header = (void *) info->LongHeaders[++i])
+	    buf = writeWAISDocumentLongHeader((WAISDocumentLongHeader *) header,
+					      buf,
+					      len);
+    }
+
+    if (info->Text != NULL) {
+	for (i = 0, header = (void *) info->Text[i];
+	     header != NULL;
+	     header = (void *) info->Text[++i])
+	    buf = writeWAISDocumentText((WAISDocumentText *) header, buf, len);
     }
 
-  *header = makeWAISDocumentLongHeader(docID,versionNumber,score,bestMatch,
-				       docLength,lines,types,source,date,headline,
-				       originCity,stockCodes,companyCodes,
-				       industryCodes);
-  return(buf);
-}
-
-/*----------------------------------------------------------------------*/
-
-WAISSearchResponse*
-makeWAISSearchResponse(seedWordsUsed,
-		       docHeaders,
-		       shortHeaders,
-		       longHeaders,
-		       text,
-		       headlines,
-		       codes,
-		       diagnostics)
-char* seedWordsUsed;
-WAISDocumentHeader** docHeaders;
-WAISDocumentShortHeader** shortHeaders;
-WAISDocumentLongHeader** longHeaders;
-WAISDocumentText** text;
-WAISDocumentHeadlines** headlines;
-WAISDocumentCodes** codes;
-diagnosticRecord** diagnostics;
-{
-  WAISSearchResponse* response = (WAISSearchResponse*)s_malloc((size_t)sizeof(WAISSearchResponse));
-
-  response->SeedWordsUsed = seedWordsUsed;
-  response->DocHeaders = docHeaders;
-  response->ShortHeaders = shortHeaders;
-  response->LongHeaders = longHeaders;
-  response->Text = text;
-  response->Headlines = headlines;
-  response->Codes = codes;
-  response->Diagnostics = diagnostics;
-
-  return(response);
-}
-
-/*----------------------------------------------------------------------*/
-
-void
-freeWAISSearchResponse(response)
-WAISSearchResponse* response;
-{
-  void* ptr = NULL;
-  long i;
-
-  s_free(response->SeedWordsUsed);
-
-  if (response->DocHeaders != NULL)
-    for (i = 0,ptr = (void *)response->DocHeaders[i]; ptr != NULL; ptr = (void *)response->DocHeaders[++i])
-      freeWAISDocumentHeader((WAISDocumentHeader*)ptr);
-  s_free(response->DocHeaders);
-
-  if (response->ShortHeaders != NULL)
-    for (i = 0,ptr = (void *)response->ShortHeaders[i]; ptr != NULL; ptr = (void *)response->ShortHeaders[++i])
-      freeWAISDocumentShortHeader((WAISDocumentShortHeader*)ptr);
-  s_free(response->ShortHeaders);
-
-  if (response->LongHeaders != NULL)
-    for (i = 0,ptr = (void *)response->LongHeaders[i]; ptr != NULL; ptr = (void *)response->LongHeaders[++i])
-      freeWAISDocumentLongHeader((WAISDocumentLongHeader*)ptr);
-  s_free(response->LongHeaders);
-
-  if (response->Text != NULL)
-    for (i = 0,ptr = (void *)response->Text[i]; ptr != NULL; ptr = (void *)response->Text[++i])
-      freeWAISDocumentText((WAISDocumentText*)ptr);
-  s_free(response->Text);
-
-  if (response->Headlines != NULL)
-    for (i = 0,ptr = (void *)response->Headlines[i]; ptr != NULL; ptr = (void *)response->Headlines[++i])
-      freeWAISDocumentHeadlines((WAISDocumentHeadlines*)ptr);
-  s_free(response->Headlines);
-
-  if (response->Codes != NULL)
-    for (i = 0,ptr = (void *)response->Codes[i]; ptr != NULL; ptr = (void *)response->Codes[++i])
-      freeWAISDocumentCodes((WAISDocumentCodes*)ptr);
-  s_free(response->Codes);
-
-  if (response->Diagnostics != NULL)
-    for (i = 0,ptr = (void *)response->Diagnostics[i]; ptr != NULL; ptr = (void *)response->Diagnostics[++i])
-      freeDiag((diagnosticRecord*)ptr);
-  s_free(response->Diagnostics);
-
-  s_free(response);
-}
-
-/*----------------------------------------------------------------------*/
-
-char*
-writeSearchResponseInfo(query,buffer,len)
-SearchResponseAPDU* query;
-char* buffer;
-long* len;
-{
-  unsigned long header_len = userInfoTagSize(DT_UserInformationLength,
-					     DefWAISSearchResponseSize);
-  char* buf = buffer + header_len;
-  WAISSearchResponse* info = (WAISSearchResponse*)query->DatabaseDiagnosticRecords;
-  unsigned long size;
-  void* header = NULL;
-  long i;
-
-  RESERVE_SPACE_FOR_WAIS_HEADER(len);
-
-  buf = writeString(info->SeedWordsUsed,DT_SeedWordsUsed,buf,len);
-
-  /* write out all the headers */
-  if (info->DocHeaders != NULL)
-    { for (i = 0,header = (void *)info->DocHeaders[i]; header != NULL; header = (void *)info->DocHeaders[++i])
-	buf = writeWAISDocumentHeader((WAISDocumentHeader*)header,buf,len);
-      }
-
-  if (info->ShortHeaders != NULL)
-    { for (i = 0,header = (void *)info->ShortHeaders[i]; header != NULL; header = (void *)info->ShortHeaders[++i])
-	buf = writeWAISDocumentShortHeader((WAISDocumentShortHeader*)header,buf,len);
-      }
-
-  if (info->LongHeaders != NULL)
-    { for (i = 0,header = (void *)info->LongHeaders[i]; header != NULL; header = (void *)info->LongHeaders[++i])
-	buf = writeWAISDocumentLongHeader((WAISDocumentLongHeader*)header,buf,len);
-      }
-
-  if (info->Text != NULL)
-    { for (i = 0,header = (void *)info->Text[i]; header != NULL; header = (void *)info->Text[++i])
-	buf = writeWAISDocumentText((WAISDocumentText*)header,buf,len);
-      }
-
-  if (info->Headlines != NULL)
-    { for (i = 0,header = (void *)info->Headlines[i]; header != NULL; header = (void *)info->Headlines[++i])
-	buf = writeWAISDocumentHeadlines((WAISDocumentHeadlines*)header,buf,len);
-      }
-
-  if (info->Codes != NULL)
-    { for (i = 0,header = (void *)info->Codes[i]; header != NULL;header = (void *)info->Codes[++i])
-	buf = writeWAISDocumentCodes((WAISDocumentCodes*)header,buf,len);
-      }
-
-  if (info->Diagnostics != NULL)
-    { for (i = 0, header = (void *)info->Diagnostics[i]; header != NULL; header = (void *)info->Diagnostics[++i])
-	buf = writeDiag((diagnosticRecord*)header,buf,len);
-      }
-
-  /* now write the header and size */
-  size = buf - buffer;
-  buf = writeUserInfoHeader(DT_UserInformationLength,size,header_len,buffer,len);
-
-  return(buf);
-}
-
-/*----------------------------------------------------------------------*/
-
-static void
-cleanUpWaisSearchResponse PARAMS((char* buf,char* seedWordsUsed,
-			       WAISDocumentHeader** docHeaders,
-			       WAISDocumentShortHeader** shortHeaders,
-			       WAISDocumentLongHeader** longHeaders,
-			       WAISDocumentText** text,
-			       WAISDocumentHeadlines** headlines,
-			       WAISDocumentCodes** codes,
-			       diagnosticRecord**diags));
-
-static void
-cleanUpWaisSearchResponse (buf,seedWordsUsed,docHeaders,shortHeaders,
-			   longHeaders,text,headlines,codes,diags)
-char* buf;
-char* seedWordsUsed;
-WAISDocumentHeader** docHeaders;
-WAISDocumentShortHeader** shortHeaders;
-WAISDocumentLongHeader** longHeaders;
-WAISDocumentText** text;
-WAISDocumentHeadlines** headlines;
-WAISDocumentCodes** codes;
-diagnosticRecord** diags;
+    if (info->Headlines != NULL) {
+	for (i = 0, header = (void *) info->Headlines[i];
+	     header != NULL;
+	     header = (void *) info->Headlines[++i])
+	    buf = writeWAISDocumentHeadlines((WAISDocumentHeadlines *) header,
+					     buf,
+					     len);
+    }
+
+    if (info->Codes != NULL) {
+	for (i = 0, header = (void *) info->Codes[i];
+	     header != NULL;
+	     header = (void *) info->Codes[++i])
+	    buf = writeWAISDocumentCodes((WAISDocumentCodes *) header, buf, len);
+    }
+
+    if (info->Diagnostics != NULL) {
+	for (i = 0, header = (void *) info->Diagnostics[i];
+	     header != NULL;
+	     header = (void *) info->Diagnostics[++i])
+	    buf = writeDiag((diagnosticRecord *) header, buf, len);
+    }
+
+    /* now write the header and size */
+    size = buf - buffer;
+    buf = writeUserInfoHeader(DT_UserInformationLength,
+			      size,
+			      header_len,
+			      buffer,
+			      len);
+
+    return (buf);
+}
+
+/*----------------------------------------------------------------------*/
+
+static void cleanUpWaisSearchResponse(char *buf,
+				      char *seedWordsUsed,
+				      WAISDocumentHeader **docHeaders,
+				      WAISDocumentShortHeader **shortHeaders,
+				      WAISDocumentLongHeader **longHeaders,
+				      WAISDocumentText **text,
+				      WAISDocumentHeadlines **headlines,
+				      WAISDocumentCodes **codes,
+				      diagnosticRecord ** diags)
 /* if buf is NULL, we have just gotten a read error, and need to clean up
    any state we have built.  If not, then everything is going fine, and
    we should just hang loose
  */
 {
-  void* ptr = NULL;
-  long i;
+    void *ptr = NULL;
+    long i;
+
+    if (buf == NULL) {
+	s_free(seedWordsUsed);
+	if (docHeaders != NULL)
+	    for (i = 0, ptr = (void *) docHeaders[i]; ptr != NULL;
+		 ptr = (void *) docHeaders[++i])
+		freeWAISDocumentHeader((WAISDocumentHeader *) ptr);
+	s_free(docHeaders);
+	if (shortHeaders != NULL)
+	    for (i = 0, ptr = (void *) shortHeaders[i]; ptr != NULL;
+		 ptr = (void *) shortHeaders[++i])
+		freeWAISDocumentShortHeader((WAISDocumentShortHeader *) ptr);
+	s_free(shortHeaders);
+	if (longHeaders != NULL)
+	    for (i = 0, ptr = (void *) longHeaders[i]; ptr != NULL;
+		 ptr = (void *) longHeaders[++i])
+		freeWAISDocumentLongHeader((WAISDocumentLongHeader *) ptr);
+	s_free(longHeaders);
+	if (text != NULL)
+	    for (i = 0, ptr = (void *) text[i];
+		 ptr != NULL;
+		 ptr = (void *) text[++i])
+		freeWAISDocumentText((WAISDocumentText *) ptr);
+	s_free(text);
+	if (headlines != NULL)
+	    for (i = 0, ptr = (void *) headlines[i]; ptr != NULL;
+		 ptr = (void *) headlines[++i])
+		freeWAISDocumentHeadlines((WAISDocumentHeadlines *) ptr);
+	s_free(headlines);
+	if (codes != NULL)
+	    for (i = 0, ptr = (void *) codes[i]; ptr != NULL;
+		 ptr = (void *) codes[++i])
+		freeWAISDocumentCodes((WAISDocumentCodes *) ptr);
+	s_free(codes);
+	if (diags != NULL)
+	    for (i = 0, ptr = (void *) diags[i]; ptr != NULL;
+		 ptr = (void *) diags[++i])
+		freeDiag((diagnosticRecord *) ptr);
+	s_free(diags);
+    }
+}
 
-  if (buf == NULL)
-   { s_free(seedWordsUsed);
-     if (docHeaders != NULL)
-       for (i = 0,ptr = (void *)docHeaders[i]; ptr != NULL;
-	    ptr = (void *)docHeaders[++i])
-	 freeWAISDocumentHeader((WAISDocumentHeader*)ptr);
-     s_free(docHeaders);
-     if (shortHeaders != NULL)
-       for (i = 0,ptr = (void *)shortHeaders[i]; ptr != NULL;
-	    ptr = (void *)shortHeaders[++i])
-	 freeWAISDocumentShortHeader((WAISDocumentShortHeader*)ptr);
-     s_free(shortHeaders);
-     if (longHeaders != NULL)
-       for (i = 0,ptr = (void *)longHeaders[i]; ptr != NULL;
-	    ptr = (void *)longHeaders[++i])
-	 freeWAISDocumentLongHeader((WAISDocumentLongHeader*)ptr);
-     s_free(longHeaders);
-     if (text != NULL)
-       for (i = 0,ptr = (void *)text[i]; ptr != NULL; ptr = (void *)text[++i])
-	 freeWAISDocumentText((WAISDocumentText*)ptr);
-     s_free(text);
-     if (headlines != NULL)
-       for (i = 0,ptr = (void *)headlines[i]; ptr != NULL;
-	    ptr = (void *)headlines[++i])
-	 freeWAISDocumentHeadlines((WAISDocumentHeadlines*)ptr);
-     s_free(headlines);
-     if (codes != NULL)
-       for (i = 0,ptr = (void *)codes[i]; ptr != NULL;
-	    ptr = (void *)codes[++i])
-	 freeWAISDocumentCodes((WAISDocumentCodes*)ptr);
-     s_free(codes);
-     if (diags != NULL)
-       for (i = 0,ptr = (void *)diags[i]; ptr != NULL;
-	    ptr = (void *)diags[++i])
-	 freeDiag((diagnosticRecord*)ptr);
-     s_free(diags);
-   }
-}
-
-/*----------------------------------------------------------------------*/
-
-char*
-readSearchResponseInfo(info,buffer)
-void** info;
-char* buffer;
-{
-  char* buf = buffer;
-  unsigned long size;
-  unsigned long headerSize;
-  data_tag tag1;
-  void* header = NULL;
-  WAISDocumentHeader** docHeaders = NULL;
-  WAISDocumentShortHeader** shortHeaders = NULL;
-  WAISDocumentLongHeader** longHeaders = NULL;
-  WAISDocumentText** text = NULL;
-  WAISDocumentHeadlines** headlines = NULL;
-  WAISDocumentCodes** codes = NULL;
-  long numDocHeaders,numLongHeaders,numShortHeaders,numText,numHeadlines;
-  long numCodes;
-  char* seedWordsUsed = NULL;
-  diagnosticRecord** diags = NULL;
-  diagnosticRecord* diag = NULL;
-  long numDiags = 0;
-
-  numDocHeaders = numLongHeaders = numShortHeaders = numText = numHeadlines = numCodes = 0;
-
-  buf = readUserInfoHeader(&tag1,&size,buf);
-  headerSize = buf - buffer;
-
-  while (buf < (buffer + size + headerSize))
-   { data_tag tag = peekTag(buf);
-     switch (tag)
-      { case DT_SeedWordsUsed:
-	  buf = readString(&seedWordsUsed,buf);
-	  break;
+/*----------------------------------------------------------------------*/
+
+char *readSearchResponseInfo(void **info,
+			     char *buffer)
+{
+    char *buf = buffer;
+    unsigned long size;
+    unsigned long headerSize;
+    data_tag tag1;
+    void *header = NULL;
+    WAISDocumentHeader **docHeaders = NULL;
+    WAISDocumentShortHeader **shortHeaders = NULL;
+    WAISDocumentLongHeader **longHeaders = NULL;
+    WAISDocumentText **text = NULL;
+    WAISDocumentHeadlines **headlines = NULL;
+    WAISDocumentCodes **codes = NULL;
+    long numDocHeaders, numLongHeaders, numShortHeaders, numText, numHeadlines;
+    long numCodes;
+    char *seedWordsUsed = NULL;
+    diagnosticRecord **diags = NULL;
+    diagnosticRecord *diag = NULL;
+    long numDiags = 0;
+
+    numDocHeaders =
+	numLongHeaders =
+	numShortHeaders =
+	numText =
+	numHeadlines =
+	numCodes = 0;
+
+    buf = readUserInfoHeader(&tag1, &size, buf);
+    headerSize = buf - buffer;
+
+    while (buf < (buffer + size + headerSize)) {
+	data_tag tag = peekTag(buf);
+
+	switch (tag) {
+	case DT_SeedWordsUsed:
+	    buf = readString(&seedWordsUsed, buf);
+	    break;
 	case DT_DatabaseDiagnosticRecords:
-	  if (diags == NULL) /* create a new diag list */
-	   { diags = (diagnosticRecord**)s_malloc((size_t)sizeof(diagnosticRecord*) * 2);
-	   }
-	  else /* grow the diag list */
-	   { diags = (diagnosticRecord**)s_realloc((char*)diags,(size_t)(sizeof(diagnosticRecord*) * (numDiags + 2)));
-	   }
-	  buf = readDiag(&diag,buf);
-	  diags[numDiags++] = diag; /* put it in the list */
-	  diags[numDiags] = NULL;
-	  break;
+	    if (diags == NULL)	/* create a new diag list */
+	    {
+		diags = S_MALLOC2(diagnosticRecord *);
+	    } else {		/* grow the diag list */
+		diags = S_REALLOC2(diagnosticRecord *, diags, numDiags);
+	    }
+	    buf = readDiag(&diag, buf);
+	    diags[numDiags++] = diag;	/* put it in the list */
+	    diags[numDiags] = NULL;
+	    break;
 	case DT_DocumentHeaderGroup:
-		  if (docHeaders == NULL) /* create a new header list */
-		   { docHeaders = (WAISDocumentHeader**)s_malloc((size_t)sizeof(WAISDocumentHeader*) * 2);
-		   }
-		  else /* grow the doc list */
-		   { docHeaders = (WAISDocumentHeader**)s_realloc((char*)docHeaders,(size_t)(sizeof(WAISDocumentHeader*) * (numDocHeaders + 2)));
-		   }
-		  buf = readWAISDocumentHeader((WAISDocumentHeader**)&header,buf);
-		  cleanUpWaisSearchResponse(buf,seedWordsUsed,docHeaders,shortHeaders,longHeaders,text,headlines,codes,diags);
-		  RETURN_ON_NULL(buf);
-		  docHeaders[numDocHeaders++] =
-		    (WAISDocumentHeader*)header; /* put it in the list */
-		  docHeaders[numDocHeaders] = NULL;
-		  break;
-		case DT_DocumentShortHeaderGroup:
-		  if (shortHeaders == NULL) /* create a new header list */
-		   { shortHeaders = (WAISDocumentShortHeader**)s_malloc((size_t)sizeof(WAISDocumentShortHeader*) * 2);
-		   }
-		  else /* grow the doc list */
-		   { shortHeaders = (WAISDocumentShortHeader**)s_realloc((char*)shortHeaders,(size_t)(sizeof(WAISDocumentShortHeader*) * (numShortHeaders + 2)));
-		   }
-		  buf = readWAISDocumentShortHeader((WAISDocumentShortHeader**)&header,buf);
-		  cleanUpWaisSearchResponse(buf,seedWordsUsed,docHeaders,shortHeaders,longHeaders,text,headlines,codes,diags);
-		  RETURN_ON_NULL(buf);
-		  shortHeaders[numShortHeaders++] =
-		    (WAISDocumentShortHeader*)header; /* put it in the list */
-		  shortHeaders[numShortHeaders] = NULL;
-		  break;
-		case DT_DocumentLongHeaderGroup:
-		  if (longHeaders == NULL) /* create a new header list */
-		   { longHeaders = (WAISDocumentLongHeader**)s_malloc((size_t)sizeof(WAISDocumentLongHeader*) * 2);
-		   }
-		  else /* grow the doc list */
-		   { longHeaders = (WAISDocumentLongHeader**)s_realloc((char*)longHeaders,(size_t)(sizeof(WAISDocumentLongHeader*) * (numLongHeaders + 2)));
-		   }
-		  buf = readWAISDocumentLongHeader((WAISDocumentLongHeader**)&header,buf);
-		  cleanUpWaisSearchResponse(buf,seedWordsUsed,docHeaders,shortHeaders,longHeaders,text,headlines,codes,diags);
-		  RETURN_ON_NULL(buf);
-		  longHeaders[numLongHeaders++] =
-		    (WAISDocumentLongHeader*)header; /* put it in the list */
-		  longHeaders[numLongHeaders] = NULL;
-		  break;
+	    if (docHeaders == NULL)	/* create a new header list */
+	    {
+		docHeaders = S_MALLOC2(WAISDocumentHeader *);
+	    } else {		/* grow the doc list */
+		docHeaders = S_REALLOC2(WAISDocumentHeader *, docHeaders, numDocHeaders);
+	    }
+	    buf = readWAISDocumentHeader((WAISDocumentHeader **) &header, buf);
+	    cleanUpWaisSearchResponse(buf,
+				      seedWordsUsed,
+				      docHeaders,
+				      shortHeaders,
+				      longHeaders,
+				      text,
+				      headlines,
+				      codes,
+				      diags);
+	    RETURN_ON_NULL(buf);
+	    docHeaders[numDocHeaders++] =
+		(WAISDocumentHeader *) header;	/* put it in the list */
+	    docHeaders[numDocHeaders] = NULL;
+	    break;
+	case DT_DocumentShortHeaderGroup:
+	    if (shortHeaders == NULL)	/* create a new header list */
+	    {
+		shortHeaders = S_MALLOC2(WAISDocumentShortHeader *);
+	    } else {		/* grow the doc list */
+		shortHeaders = S_REALLOC2(WAISDocumentShortHeader *,
+					  shortHeaders,
+					  numShortHeaders);
+	    }
+	    buf = readWAISDocumentShortHeader((WAISDocumentShortHeader **) &header,
+					      buf);
+	    cleanUpWaisSearchResponse(buf,
+				      seedWordsUsed,
+				      docHeaders,
+				      shortHeaders,
+				      longHeaders,
+				      text,
+				      headlines,
+				      codes,
+				      diags);
+	    RETURN_ON_NULL(buf);
+	    shortHeaders[numShortHeaders++] =
+		(WAISDocumentShortHeader *) header;	/* put it in the list */
+	    shortHeaders[numShortHeaders] = NULL;
+	    break;
+	case DT_DocumentLongHeaderGroup:
+	    if (longHeaders == NULL)	/* create a new header list */
+	    {
+		longHeaders = S_MALLOC2(WAISDocumentLongHeader *);
+	    } else {		/* grow the doc list */
+		longHeaders = S_REALLOC2(WAISDocumentLongHeader *,
+					 longHeaders,
+					 numLongHeaders);
+	    }
+	    buf = readWAISDocumentLongHeader((WAISDocumentLongHeader **) &header,
+					     buf);
+	    cleanUpWaisSearchResponse(buf,
+				      seedWordsUsed,
+				      docHeaders,
+				      shortHeaders,
+				      longHeaders,
+				      text,
+				      headlines,
+				      codes,
+				      diags);
+	    RETURN_ON_NULL(buf);
+	    longHeaders[numLongHeaders++] =
+		(WAISDocumentLongHeader *) header;	/* put it in the list */
+	    longHeaders[numLongHeaders] = NULL;
+	    break;
 	case DT_DocumentTextGroup:
-		  if (text == NULL) /* create a new list */
-		   { text = (WAISDocumentText**)s_malloc((size_t)sizeof(WAISDocumentText*) * 2);
-		   }
-		  else /* grow the list */
-		   { text = (WAISDocumentText**)s_realloc((char*)text,(size_t)(sizeof(WAISDocumentText*) * (numText + 2)));
-		   }
-		  buf = readWAISDocumentText((WAISDocumentText**)&header,buf);
-		  cleanUpWaisSearchResponse(buf,seedWordsUsed,docHeaders,shortHeaders,longHeaders,text,headlines,codes,diags);
-		  RETURN_ON_NULL(buf);
-		  text[numText++] =
-		    (WAISDocumentText*)header; /* put it in the list */
-		  text[numText] = NULL;
-		  break;
-		case DT_DocumentHeadlineGroup:
-		  if (headlines == NULL) /* create a new list */
-		   { headlines = (WAISDocumentHeadlines**)s_malloc((size_t)sizeof(WAISDocumentHeadlines*) * 2);
-		   }
-		  else /* grow the list */
-		   { headlines = (WAISDocumentHeadlines**)s_realloc((char*)headlines,(size_t)(sizeof(WAISDocumentHeadlines*) * (numHeadlines + 2)));
-		   }
-		  buf = readWAISDocumentHeadlines((WAISDocumentHeadlines**)&header,buf);
-		  cleanUpWaisSearchResponse(buf,seedWordsUsed,docHeaders,shortHeaders,longHeaders,text,headlines,codes,diags);
-		  RETURN_ON_NULL(buf);
-		  headlines[numHeadlines++] =
-		    (WAISDocumentHeadlines*)header; /* put it in the list */
-		  headlines[numHeadlines] = NULL;
-		  break;
-		case DT_DocumentCodeGroup:
-		  if (codes == NULL) /* create a new list */
-		   { codes = (WAISDocumentCodes**)s_malloc((size_t)sizeof(WAISDocumentCodes*) * 2);
-		   }
-		  else /* grow the list */
-		   { codes = (WAISDocumentCodes**)s_realloc((char*)codes,(size_t)(sizeof(WAISDocumentCodes*) * (numCodes + 2)));
-		   }
-		  buf = readWAISDocumentCodes((WAISDocumentCodes**)&header,buf);
-		  cleanUpWaisSearchResponse(buf,seedWordsUsed,docHeaders,shortHeaders,longHeaders,text,headlines,codes,diags);
-		  RETURN_ON_NULL(buf);
-		  codes[numCodes++] =
-		    (WAISDocumentCodes*)header; /* put it in the list */
-		  codes[numCodes] = NULL;
-		  break;
+	    if (text == NULL)	/* create a new list */
+	    {
+		text = S_MALLOC2(WAISDocumentText *);
+	    } else {		/* grow the list */
+		text = S_REALLOC2(WAISDocumentText *, text, numText);
+	    }
+	    buf = readWAISDocumentText((WAISDocumentText **) &header, buf);
+	    cleanUpWaisSearchResponse(buf,
+				      seedWordsUsed,
+				      docHeaders,
+				      shortHeaders,
+				      longHeaders,
+				      text,
+				      headlines,
+				      codes,
+				      diags);
+	    RETURN_ON_NULL(buf);
+	    text[numText++] =
+		(WAISDocumentText *) header;	/* put it in the list */
+	    text[numText] = NULL;
+	    break;
+	case DT_DocumentHeadlineGroup:
+	    if (headlines == NULL)	/* create a new list */
+	    {
+		headlines = S_MALLOC2(WAISDocumentHeadlines *);
+	    } else {		/* grow the list */
+		headlines = S_REALLOC2(WAISDocumentHeadlines *, headlines, numHeadlines);
+	    }
+	    buf = readWAISDocumentHeadlines((WAISDocumentHeadlines **) &header,
+					    buf);
+	    cleanUpWaisSearchResponse(buf,
+				      seedWordsUsed,
+				      docHeaders,
+				      shortHeaders,
+				      longHeaders,
+				      text,
+				      headlines,
+				      codes,
+				      diags);
+	    RETURN_ON_NULL(buf);
+	    headlines[numHeadlines++] =
+		(WAISDocumentHeadlines *) header;	/* put it in the list */
+	    headlines[numHeadlines] = NULL;
+	    break;
+	case DT_DocumentCodeGroup:
+	    if (codes == NULL)	/* create a new list */
+	    {
+		codes = S_MALLOC2(WAISDocumentCodes *);
+	    } else {		/* grow the list */
+		codes = S_REALLOC2(WAISDocumentCodes *, codes, numCodes);
+	    }
+	    buf = readWAISDocumentCodes((WAISDocumentCodes **) &header, buf);
+	    cleanUpWaisSearchResponse(buf,
+				      seedWordsUsed,
+				      docHeaders,
+				      shortHeaders,
+				      longHeaders,
+				      text,
+				      headlines,
+				      codes,
+				      diags);
+	    RETURN_ON_NULL(buf);
+	    codes[numCodes++] =
+		(WAISDocumentCodes *) header;	/* put it in the list */
+	    codes[numCodes] = NULL;
+	    break;
 	default:
-	  cleanUpWaisSearchResponse(buf,seedWordsUsed,docHeaders,shortHeaders,longHeaders,text,headlines,codes,diags);
-	  REPORT_READ_ERROR(buf);
-	  break;
-      }
-   }
+	    cleanUpWaisSearchResponse(buf,
+				      seedWordsUsed,
+				      docHeaders,
+				      shortHeaders,
+				      longHeaders,
+				      text,
+				      headlines,
+				      codes,
+				      diags);
+	    REPORT_READ_ERROR(buf);
+	    break;
+	}
+    }
 
-  *info = (void *)makeWAISSearchResponse(seedWordsUsed,docHeaders,shortHeaders,
-				 longHeaders,text,headlines,codes,diags);
+    *info = (void *) makeWAISSearchResponse(seedWordsUsed,
+					    docHeaders,
+					    shortHeaders,
+					    longHeaders,
+					    text,
+					    headlines,
+					    codes,
+					    diags);
 
-  return(buf);
+    return (buf);
 }
 
 /*----------------------------------------------------------------------*/
 
-WAISDocumentText*
-makeWAISDocumentText(docID,versionNumber,documentText)
-any* docID;
-long versionNumber;
-any* documentText;
+WAISDocumentText *makeWAISDocumentText(any *docID,
+				       long versionNumber,
+				       any *documentText)
 {
-  WAISDocumentText* docText = (WAISDocumentText*)s_malloc((size_t)sizeof(WAISDocumentText));
+    WAISDocumentText *docText = S_MALLOC(WAISDocumentText);
 
-  docText->DocumentID = docID;
-  docText->VersionNumber = versionNumber;
-  docText->DocumentText = documentText;
+    docText->DocumentID = docID;
+    docText->VersionNumber = versionNumber;
+    docText->DocumentText = documentText;
 
-  return(docText);
+    return (docText);
 }
 
 /*----------------------------------------------------------------------*/
 
-void
-freeWAISDocumentText(docText)
-WAISDocumentText* docText;
+void freeWAISDocumentText(WAISDocumentText *docText)
 {
-  freeAny(docText->DocumentID);
-  freeAny(docText->DocumentText);
-  s_free(docText);
+    freeAny(docText->DocumentID);
+    freeAny(docText->DocumentText);
+    s_free(docText);
 }
 
 /*----------------------------------------------------------------------*/
 
-char*
-writeWAISDocumentText(docText,buffer,len)
-WAISDocumentText* docText;
-char* buffer;
-long* len;
+char *writeWAISDocumentText(WAISDocumentText *docText, char *buffer,
+			    long *len)
 {
-  unsigned long header_len = userInfoTagSize(DT_DocumentTextGroup,
-											DefWAISDocTextSize);
-  char* buf = buffer + header_len;
-  unsigned long size;
+    unsigned long header_len = userInfoTagSize(DT_DocumentTextGroup,
+					       DefWAISDocTextSize);
+    char *buf = buffer + header_len;
+    unsigned long size;
 
-  RESERVE_SPACE_FOR_WAIS_HEADER(len);
+    RESERVE_SPACE_FOR_WAIS_HEADER(len);
 
-  buf = writeAny(docText->DocumentID,DT_DocumentID,buf,len);
-  buf = writeNum(docText->VersionNumber,DT_VersionNumber,buf,len);
-  buf = writeAny(docText->DocumentText,DT_DocumentText,buf,len);
+    buf = writeAny(docText->DocumentID, DT_DocumentID, buf, len);
+    buf = writeNum(docText->VersionNumber, DT_VersionNumber, buf, len);
+    buf = writeAny(docText->DocumentText, DT_DocumentText, buf, len);
 
-  /* now write the header and size */
-  size = buf - buffer;
-  buf = writeUserInfoHeader(DT_DocumentTextGroup,size,header_len,buffer,len);
+    /* now write the header and size */
+    size = buf - buffer;
+    buf = writeUserInfoHeader(DT_DocumentTextGroup, size, header_len, buffer, len);
 
-  return(buf);
+    return (buf);
 }
 
 /*----------------------------------------------------------------------*/
 
-char*
-readWAISDocumentText(docText,buffer)
-WAISDocumentText** docText;
-char* buffer;
+char *readWAISDocumentText(WAISDocumentText **docText, char *buffer)
 {
-  char* buf = buffer;
-  unsigned long size;
-  unsigned long headerSize;
-  data_tag tag1;
-  any *docID,*documentText;
-  long versionNumber;
+    char *buf = buffer;
+    unsigned long size;
+    unsigned long headerSize;
+    data_tag tag1;
+    any *docID, *documentText;
+    long versionNumber;
 
-  docID = documentText = NULL;
-  versionNumber = UNUSED;
+    docID = documentText = NULL;
+    versionNumber = UNUSED;
 
-  buf = readUserInfoHeader(&tag1,&size,buf);
-  headerSize = buf - buffer;
+    buf = readUserInfoHeader(&tag1, &size, buf);
+    headerSize = buf - buffer;
 
-  while (buf < (buffer + size + headerSize))
-   { data_tag tag = peekTag(buf);
-     switch (tag)
-      { case DT_DocumentID:
-		  buf = readAny(&docID,buf);
-		  break;
-		case DT_VersionNumber:
-		  buf = readNum(&versionNumber,buf);
-		  break;
-		case DT_DocumentText:
-		  buf = readAny(&documentText,buf);
-		  break;
+    while (buf < (buffer + size + headerSize)) {
+	data_tag tag = peekTag(buf);
+
+	switch (tag) {
+	case DT_DocumentID:
+	    buf = readAny(&docID, buf);
+	    break;
+	case DT_VersionNumber:
+	    buf = readNum(&versionNumber, buf);
+	    break;
+	case DT_DocumentText:
+	    buf = readAny(&documentText, buf);
+	    break;
 	default:
-	  freeAny(docID);
-	  freeAny(documentText);
-	  REPORT_READ_ERROR(buf);
-	  break;
-      }
-   }
-
-  *docText = makeWAISDocumentText(docID,versionNumber,documentText);
-  return(buf);
-}
-
-/*----------------------------------------------------------------------*/
-
-WAISDocumentHeadlines*
-makeWAISDocumentHeadlines(docID,
-			  versionNumber,
-			  source,
-			  date,
-			  headline,
-			  originCity)
-any* docID;
-long versionNumber;
-char* source;
-char* date;
-char* headline;
-char* originCity;
-{
-  WAISDocumentHeadlines* docHeadline =
-    (WAISDocumentHeadlines*)s_malloc((size_t)sizeof(WAISDocumentHeadlines));
-
-  docHeadline->DocumentID = docID;
-  docHeadline->VersionNumber = versionNumber;
-  docHeadline->Source = source;
-  docHeadline->Date = date;
-  docHeadline->Headline = headline;
-  docHeadline->OriginCity = originCity;
-
-  return(docHeadline);
-}
-
-/*----------------------------------------------------------------------*/
-
-void
-freeWAISDocumentHeadlines(docHeadline)
-WAISDocumentHeadlines* docHeadline;
-{
-  freeAny(docHeadline->DocumentID);
-  s_free(docHeadline->Source);
-  s_free(docHeadline->Date);
-  s_free(docHeadline->Headline);
-  s_free(docHeadline->OriginCity);
-  s_free(docHeadline);
-}
-
-/*----------------------------------------------------------------------*/
-
-char*
-writeWAISDocumentHeadlines(docHeadline,buffer,len)
-WAISDocumentHeadlines* docHeadline;
-char* buffer;
-long* len;
-{
-  unsigned long header_len = userInfoTagSize(DT_DocumentHeadlineGroup,
-											DefWAISDocHeadlineSize);
-  char* buf = buffer + header_len;
-  unsigned long size;
-
-  RESERVE_SPACE_FOR_WAIS_HEADER(len);
-
-  buf = writeAny(docHeadline->DocumentID,DT_DocumentID,buf,len);
-  buf = writeNum(docHeadline->VersionNumber,DT_VersionNumber,buf,len);
-  buf = writeString(docHeadline->Source,DT_Source,buf,len);
-  buf = writeString(docHeadline->Date,DT_Date,buf,len);
-  buf = writeString(docHeadline->Headline,DT_Headline,buf,len);
-  buf = writeString(docHeadline->OriginCity,DT_OriginCity,buf,len);
-
-  /* now write the header and size */
-  size = buf - buffer;
-  buf = writeUserInfoHeader(DT_DocumentHeadlineGroup,size,header_len,buffer,len);
-
-  return(buf);
-}
-
-/*----------------------------------------------------------------------*/
-
-char*
-readWAISDocumentHeadlines(docHeadline,buffer)
-WAISDocumentHeadlines** docHeadline;
-char* buffer;
-{
-  char* buf = buffer;
-  unsigned long size;
-  unsigned long headerSize;
-  data_tag tag1;
-  any* docID;
-  long versionNumber;
-  char *source,*date,*headline,*originCity;
-
-  docID = NULL;
-  versionNumber = UNUSED;
-  source = date = headline = originCity = NULL;
-
-  buf = readUserInfoHeader(&tag1,&size,buf);
-  headerSize = buf - buffer;
-
-  while (buf < (buffer + size + headerSize))
-   { data_tag tag = peekTag(buf);
-     switch (tag)
-      { case DT_DocumentID:
-		  buf = readAny(&docID,buf);
-		  break;
-		case DT_VersionNumber:
-		  buf = readNum(&versionNumber,buf);
-		  break;
-		case DT_Source:
-		  buf = readString(&source,buf);
-		  break;
-		case DT_Date:
-		  buf = readString(&date,buf);
-		  break;
-		case DT_Headline:
-		  buf = readString(&headline,buf);
-		  break;
-		case DT_OriginCity:
-		  buf = readString(&originCity,buf);
-		  break;
+	    freeAny(docID);
+	    freeAny(documentText);
+	    REPORT_READ_ERROR(buf);
+	    break;
+	}
+    }
+
+    *docText = makeWAISDocumentText(docID, versionNumber, documentText);
+    return (buf);
+}
+
+/*----------------------------------------------------------------------*/
+
+WAISDocumentHeadlines *makeWAISDocumentHeadlines(any *docID,
+						 long versionNumber,
+						 char *source,
+						 char *date,
+						 char *headline,
+						 char *originCity)
+{
+    WAISDocumentHeadlines *docHeadline = S_MALLOC(WAISDocumentHeadlines);
+
+    docHeadline->DocumentID = docID;
+    docHeadline->VersionNumber = versionNumber;
+    docHeadline->Source = source;
+    docHeadline->Date = date;
+    docHeadline->Headline = headline;
+    docHeadline->OriginCity = originCity;
+
+    return (docHeadline);
+}
+
+/*----------------------------------------------------------------------*/
+
+void freeWAISDocumentHeadlines(WAISDocumentHeadlines *docHeadline)
+{
+    freeAny(docHeadline->DocumentID);
+    s_free(docHeadline->Source);
+    s_free(docHeadline->Date);
+    s_free(docHeadline->Headline);
+    s_free(docHeadline->OriginCity);
+    s_free(docHeadline);
+}
+
+/*----------------------------------------------------------------------*/
+
+char *writeWAISDocumentHeadlines(WAISDocumentHeadlines *docHeadline, char *buffer,
+				 long *len)
+{
+    unsigned long header_len = userInfoTagSize(DT_DocumentHeadlineGroup,
+					       DefWAISDocHeadlineSize);
+    char *buf = buffer + header_len;
+    unsigned long size;
+
+    RESERVE_SPACE_FOR_WAIS_HEADER(len);
+
+    buf = writeAny(docHeadline->DocumentID, DT_DocumentID, buf, len);
+    buf = writeNum(docHeadline->VersionNumber, DT_VersionNumber, buf, len);
+    buf = writeString(docHeadline->Source, DT_Source, buf, len);
+    buf = writeString(docHeadline->Date, DT_Date, buf, len);
+    buf = writeString(docHeadline->Headline, DT_Headline, buf, len);
+    buf = writeString(docHeadline->OriginCity, DT_OriginCity, buf, len);
+
+    /* now write the header and size */
+    size = buf - buffer;
+    buf = writeUserInfoHeader(DT_DocumentHeadlineGroup,
+			      size,
+			      header_len,
+			      buffer,
+			      len);
+
+    return (buf);
+}
+
+/*----------------------------------------------------------------------*/
+
+char *readWAISDocumentHeadlines(WAISDocumentHeadlines **docHeadline, char *buffer)
+{
+    char *buf = buffer;
+    unsigned long size;
+    unsigned long headerSize;
+    data_tag tag1;
+    any *docID;
+    long versionNumber;
+    char *source, *date, *headline, *originCity;
+
+    docID = NULL;
+    versionNumber = UNUSED;
+    source = date = headline = originCity = NULL;
+
+    buf = readUserInfoHeader(&tag1, &size, buf);
+    headerSize = buf - buffer;
+
+    while (buf < (buffer + size + headerSize)) {
+	data_tag tag = peekTag(buf);
+
+	switch (tag) {
+	case DT_DocumentID:
+	    buf = readAny(&docID, buf);
+	    break;
+	case DT_VersionNumber:
+	    buf = readNum(&versionNumber, buf);
+	    break;
+	case DT_Source:
+	    buf = readString(&source, buf);
+	    break;
+	case DT_Date:
+	    buf = readString(&date, buf);
+	    break;
+	case DT_Headline:
+	    buf = readString(&headline, buf);
+	    break;
+	case DT_OriginCity:
+	    buf = readString(&originCity, buf);
+	    break;
 	default:
-	  freeAny(docID);
-	  s_free(source);
-	  s_free(date);
-	  s_free(headline);
-	  s_free(originCity);
-	  REPORT_READ_ERROR(buf);
-	  break;
-      }
-   }
-
-  *docHeadline = makeWAISDocumentHeadlines(docID,versionNumber,source,date,
-									       headline,originCity);
-  return(buf);
-}
-
-/*----------------------------------------------------------------------*/
-
-WAISDocumentCodes*
-makeWAISDocumentCodes(docID,
-		      versionNumber,
-		      stockCodes,
-		      companyCodes,
-		      industryCodes)
-any* docID;
-long versionNumber;
-char* stockCodes;
-char* companyCodes;
-char* industryCodes;
-{
-  WAISDocumentCodes* docCodes = (WAISDocumentCodes*)s_malloc((size_t)sizeof(WAISDocumentCodes));
-
-  docCodes->DocumentID = docID;
-  docCodes->VersionNumber = versionNumber;
-  docCodes->StockCodes = stockCodes;
-  docCodes->CompanyCodes = companyCodes;
-  docCodes->IndustryCodes = industryCodes;
-
-  return(docCodes);
-}
-
-/*----------------------------------------------------------------------*/
-
-void
-freeWAISDocumentCodes(docCodes)
-WAISDocumentCodes* docCodes;
-{
-  freeAny(docCodes->DocumentID);
-  s_free(docCodes->StockCodes);
-  s_free(docCodes->CompanyCodes);
-  s_free(docCodes->IndustryCodes);
-  s_free(docCodes);
-}
-
-/*----------------------------------------------------------------------*/
-
-char*
-writeWAISDocumentCodes(docCodes,buffer,len)
-WAISDocumentCodes* docCodes;
-char* buffer;
-long* len;
-{
-  unsigned long header_len = userInfoTagSize(DT_DocumentCodeGroup ,
-											DefWAISDocCodeSize);
-  char* buf = buffer + header_len;
-  unsigned long size;
-
-  RESERVE_SPACE_FOR_WAIS_HEADER(len);
-
-  buf = writeAny(docCodes->DocumentID,DT_DocumentID,buf,len);
-  buf = writeNum(docCodes->VersionNumber,DT_VersionNumber,buf,len);
-  buf = writeString(docCodes->StockCodes,DT_StockCodes,buf,len);
-  buf = writeString(docCodes->CompanyCodes,DT_CompanyCodes,buf,len);
-  buf = writeString(docCodes->IndustryCodes,DT_IndustryCodes,buf,len);
-
-  /* now write the header and size */
-  size = buf - buffer;
-  buf = writeUserInfoHeader(DT_DocumentCodeGroup,size,header_len,buffer,len);
-
-  return(buf);
-}
-
-/*----------------------------------------------------------------------*/
-
-char*
-readWAISDocumentCodes(docCodes,buffer)
-WAISDocumentCodes** docCodes;
-char* buffer;
-{
-  char* buf = buffer;
-  unsigned long size;
-  unsigned long headerSize;
-  data_tag tag1;
-  any* docID;
-  long versionNumber;
-  char *stockCodes,*companyCodes,*industryCodes;
-
-  docID = NULL;
-  versionNumber = UNUSED;
-  stockCodes = companyCodes = industryCodes = NULL;
-
-  buf = readUserInfoHeader(&tag1,&size,buf);
-  headerSize = buf - buffer;
-
-  while (buf < (buffer + size + headerSize))
-   { data_tag tag = peekTag(buf);
-     switch (tag)
-      { case DT_DocumentID:
-		  buf = readAny(&docID,buf);
-		  break;
-		case DT_VersionNumber:
-		  buf = readNum(&versionNumber,buf);
-		  break;
-		case DT_StockCodes:
-		  buf = readString(&stockCodes,buf);
-		  break;
-		case DT_CompanyCodes:
-		  buf = readString(&companyCodes,buf);
-		  break;
-		case DT_IndustryCodes:
-		  buf = readString(&industryCodes,buf);
-		  break;
+	    freeAny(docID);
+	    s_free(source);
+	    s_free(date);
+	    s_free(headline);
+	    s_free(originCity);
+	    REPORT_READ_ERROR(buf);
+	    break;
+	}
+    }
+
+    *docHeadline = makeWAISDocumentHeadlines(docID, versionNumber, source, date,
+					     headline, originCity);
+    return (buf);
+}
+
+/*----------------------------------------------------------------------*/
+
+WAISDocumentCodes *makeWAISDocumentCodes(any *docID,
+					 long versionNumber,
+					 char *stockCodes,
+					 char *companyCodes,
+					 char *industryCodes)
+{
+    WAISDocumentCodes *docCodes = S_MALLOC(WAISDocumentCodes);
+
+    docCodes->DocumentID = docID;
+    docCodes->VersionNumber = versionNumber;
+    docCodes->StockCodes = stockCodes;
+    docCodes->CompanyCodes = companyCodes;
+    docCodes->IndustryCodes = industryCodes;
+
+    return (docCodes);
+}
+
+/*----------------------------------------------------------------------*/
+
+void freeWAISDocumentCodes(WAISDocumentCodes *docCodes)
+{
+    freeAny(docCodes->DocumentID);
+    s_free(docCodes->StockCodes);
+    s_free(docCodes->CompanyCodes);
+    s_free(docCodes->IndustryCodes);
+    s_free(docCodes);
+}
+
+/*----------------------------------------------------------------------*/
+
+char *writeWAISDocumentCodes(WAISDocumentCodes *docCodes,
+			     char *buffer,
+			     long *len)
+{
+    unsigned long header_len = userInfoTagSize(DT_DocumentCodeGroup,
+					       DefWAISDocCodeSize);
+    char *buf = buffer + header_len;
+    unsigned long size;
+
+    RESERVE_SPACE_FOR_WAIS_HEADER(len);
+
+    buf = writeAny(docCodes->DocumentID, DT_DocumentID, buf, len);
+    buf = writeNum(docCodes->VersionNumber, DT_VersionNumber, buf, len);
+    buf = writeString(docCodes->StockCodes, DT_StockCodes, buf, len);
+    buf = writeString(docCodes->CompanyCodes, DT_CompanyCodes, buf, len);
+    buf = writeString(docCodes->IndustryCodes, DT_IndustryCodes, buf, len);
+
+    /* now write the header and size */
+    size = buf - buffer;
+    buf = writeUserInfoHeader(DT_DocumentCodeGroup, size, header_len, buffer, len);
+
+    return (buf);
+}
+
+/*----------------------------------------------------------------------*/
+
+char *readWAISDocumentCodes(WAISDocumentCodes **docCodes,
+			    char *buffer)
+{
+    char *buf = buffer;
+    unsigned long size;
+    unsigned long headerSize;
+    data_tag tag1;
+    any *docID;
+    long versionNumber;
+    char *stockCodes, *companyCodes, *industryCodes;
+
+    docID = NULL;
+    versionNumber = UNUSED;
+    stockCodes = companyCodes = industryCodes = NULL;
+
+    buf = readUserInfoHeader(&tag1, &size, buf);
+    headerSize = buf - buffer;
+
+    while (buf < (buffer + size + headerSize)) {
+	data_tag tag = peekTag(buf);
+
+	switch (tag) {
+	case DT_DocumentID:
+	    buf = readAny(&docID, buf);
+	    break;
+	case DT_VersionNumber:
+	    buf = readNum(&versionNumber, buf);
+	    break;
+	case DT_StockCodes:
+	    buf = readString(&stockCodes, buf);
+	    break;
+	case DT_CompanyCodes:
+	    buf = readString(&companyCodes, buf);
+	    break;
+	case DT_IndustryCodes:
+	    buf = readString(&industryCodes, buf);
+	    break;
 	default:
-	  freeAny(docID);
-	  s_free(stockCodes);
-	  s_free(companyCodes);
-	  s_free(industryCodes);
-	  REPORT_READ_ERROR(buf);
-	  break;
-      }
-   }
+	    freeAny(docID);
+	    s_free(stockCodes);
+	    s_free(companyCodes);
+	    s_free(industryCodes);
+	    REPORT_READ_ERROR(buf);
+	    break;
+	}
+    }
 
-  *docCodes = makeWAISDocumentCodes(docID,versionNumber,stockCodes,
-									companyCodes,industryCodes);
-  return(buf);
+    *docCodes = makeWAISDocumentCodes(docID, versionNumber, stockCodes,
+				      companyCodes, industryCodes);
+    return (buf);
 }
 
 /*----------------------------------------------------------------------*/
 
-char*
-writePresentInfo(present,buffer,len)
-PresentAPDU* present GCC_UNUSED;
-char* buffer;
-long* len GCC_UNUSED;
+char *writePresentInfo(PresentAPDU * present GCC_UNUSED, char *buffer,
+		       long *len GCC_UNUSED)
 {
-  /* The WAIS protocol doesn't use present info */
-  return(buffer);
+    /* The WAIS protocol doesn't use present info */
+    return (buffer);
 }
 
 /*----------------------------------------------------------------------*/
 
-char*
-readPresentInfo(info,buffer)
-void** info;
-char* buffer;
+char *readPresentInfo(void **info,
+		      char *buffer)
 {
-  /* The WAIS protocol doesn't use present info */
-  *info = NULL;
-  return(buffer);
+    /* The WAIS protocol doesn't use present info */
+    *info = NULL;
+    return (buffer);
 }
 
 /*----------------------------------------------------------------------*/
 
-char*
-writePresentResponseInfo(response,buffer,len)
-PresentResponseAPDU* response GCC_UNUSED;
-char* buffer;
-long* len GCC_UNUSED;
+char *writePresentResponseInfo(PresentResponseAPDU * response GCC_UNUSED, char *buffer,
+			       long *len GCC_UNUSED)
 {
-  /* The WAIS protocol doesn't use presentResponse info */
-  return(buffer);
+    /* The WAIS protocol doesn't use presentResponse info */
+    return (buffer);
 }
 
 /*----------------------------------------------------------------------*/
 
-char*
-readPresentResponseInfo(info,buffer)
-void** info;
-char* buffer;
+char *readPresentResponseInfo(void **info,
+			      char *buffer)
 {
-  /* The WAIS protocol doesn't use presentResponse info */
-  *info = NULL;
-  return(buffer);
+    /* The WAIS protocol doesn't use presentResponse info */
+    *info = NULL;
+    return (buffer);
 }
 
 /*----------------------------------------------------------------------*/
@@ -2046,263 +2060,246 @@
 	( XXX return type could be in the element set)
 */
 
-static query_term** makeWAISQueryTerms PARAMS((DocObj** docs));
-
-static query_term**
-makeWAISQueryTerms(docs)
-DocObj** docs;
+static query_term **makeWAISQueryTerms(DocObj **docs)
 /* given a null terminated list of docObjs, construct the appropriate
    query of the form given above
  */
 {
-  query_term** terms = NULL;
-  long numTerms = 0;
-  DocObj* doc = NULL;
-  long i;
-
-  if (docs == NULL)
-    return((query_term**)NULL);
-
-  terms = (query_term**)s_malloc((size_t)(sizeof(query_term*) * 1));
-  terms[numTerms] = NULL;
-
-  /* loop through the docs making terms for them all */
-  for (i = 0,doc = docs[i]; doc != NULL; doc = docs[++i])
-    { any* type = NULL;
-
-      if (doc->Type != NULL)
-	type = stringToAny(doc->Type);
-
-      if (doc->ChunkCode == CT_document) /* a whole document */
-	{ terms = (query_term**)s_realloc((char*)terms,
-					  (size_t)(sizeof(query_term*) *
-						   (numTerms + 3 + 1)));
-	  terms[numTerms++] = makeAttributeTerm(SYSTEM_CONTROL_NUMBER,
-						EQUAL,IGNORE,IGNORE,
-						IGNORE,IGNORE,doc->DocumentID);
-	  if (type != NULL)
-	   { terms[numTerms++] = makeAttributeTerm(DATA_TYPE,EQUAL,
-						   IGNORE,IGNORE,IGNORE,
-						   IGNORE,type);
-	     terms[numTerms++] = makeOperatorTerm(AND);
-	   }
-	  terms[numTerms] = NULL;
-	}
-      else			/* a document fragment */
-	{	char chunk_att[ATTRIBUTE_SIZE];
-		any* startChunk = NULL;
-		any* endChunk = NULL;
-
-		terms = (query_term**)s_realloc((char*)terms,
-						(size_t)(sizeof(query_term*) *
-							 (numTerms + 7 + 1)));
-
-		switch (doc->ChunkCode)
-		  { case CT_byte:
-		    case CT_line:
-		      { char start[20],end[20];
-			(doc->ChunkCode == CT_byte) ?
-			  strncpy(chunk_att,BYTE,ATTRIBUTE_SIZE) :
-			strncpy(chunk_att,LINE,ATTRIBUTE_SIZE);
-			sprintf(start,"%ld",doc->ChunkStart.Pos);
-			startChunk = stringToAny(start);
-			sprintf(end,"%ld",doc->ChunkEnd.Pos);
-			endChunk = stringToAny(end);
-		      }
-		      break;
-		    case CT_paragraph:
-		      strncpy(chunk_att,PARAGRAPH,ATTRIBUTE_SIZE);
-		      startChunk = doc->ChunkStart.ID;
-		      endChunk = doc->ChunkEnd.ID;
-		      break;
-		    default:
-		      /* error */
-		      break;
-		    }
-
-		terms[numTerms++] = makeAttributeTerm(SYSTEM_CONTROL_NUMBER,
-						      EQUAL,IGNORE,IGNORE,
-						      IGNORE,
-						      IGNORE,doc->DocumentID);
-		if (type != NULL)
-		 { terms[numTerms++] = makeAttributeTerm(DATA_TYPE,EQUAL,IGNORE,
-							 IGNORE,IGNORE,IGNORE,
-							 type);
-		   terms[numTerms++] = makeOperatorTerm(AND);
-		 }
-		terms[numTerms++] = makeAttributeTerm(chunk_att,
-						      GREATER_THAN_OR_EQUAL,
-						      IGNORE,IGNORE,IGNORE,
-						      IGNORE,
-						      startChunk);
+    query_term **terms = NULL;
+    long numTerms = 0;
+    DocObj *doc = NULL;
+    long i;
+
+    if (docs == NULL)
+	return ((query_term **) NULL);
+
+    terms = (query_term **) s_malloc((size_t) (sizeof(query_term *) * 1));
+
+    terms[numTerms] = NULL;
+
+    /* loop through the docs making terms for them all */
+    for (i = 0, doc = docs[i]; doc != NULL; doc = docs[++i]) {
+	any *type = NULL;
+
+	if (doc->Type != NULL)
+	    type = stringToAny(doc->Type);
+
+	if (doc->ChunkCode == CT_document)	/* a whole document */
+	{
+	    terms = S_REALLOC2(query_term *, terms, numTerms + 2);
+
+	    terms[numTerms++] = makeAttributeTerm(SYSTEM_CONTROL_NUMBER,
+						  EQUAL, IGNORE, IGNORE,
+						  IGNORE, IGNORE, doc->DocumentID);
+	    if (type != NULL) {
+		terms[numTerms++] = makeAttributeTerm(DATA_TYPE, EQUAL,
+						      IGNORE, IGNORE, IGNORE,
+						      IGNORE, type);
 		terms[numTerms++] = makeOperatorTerm(AND);
-		terms[numTerms++] = makeAttributeTerm(chunk_att,LESS_THAN,
-						      IGNORE,IGNORE,IGNORE,
-						      IGNORE,
-						      endChunk);
+	    }
+	    terms[numTerms] = NULL;
+	} else {		/* a document fragment */
+	    char chunk_att[ATTRIBUTE_SIZE];
+	    any *startChunk = NULL;
+	    any *endChunk = NULL;
+
+	    terms = S_REALLOC2(query_term *, terms, numTerms + 6);
+
+	    switch (doc->ChunkCode) {
+	    case CT_byte:
+	    case CT_line:
+		{
+		    char start[20], end[20];
+
+		    (doc->ChunkCode == CT_byte) ?
+			strncpy(chunk_att, BYTE, ATTRIBUTE_SIZE) :
+			strncpy(chunk_att, LINE, ATTRIBUTE_SIZE);
+		    sprintf(start, "%ld", doc->ChunkStart.Pos);
+		    startChunk = stringToAny(start);
+		    sprintf(end, "%ld", doc->ChunkEnd.Pos);
+		    endChunk = stringToAny(end);
+		}
+		break;
+	    case CT_paragraph:
+		strncpy(chunk_att, PARAGRAPH, ATTRIBUTE_SIZE);
+		startChunk = doc->ChunkStart.ID;
+		endChunk = doc->ChunkEnd.ID;
+		break;
+	    default:
+		/* error */
+		break;
+	    }
+
+	    terms[numTerms++] = makeAttributeTerm(SYSTEM_CONTROL_NUMBER,
+						  EQUAL, IGNORE, IGNORE,
+						  IGNORE,
+						  IGNORE, doc->DocumentID);
+	    if (type != NULL) {
+		terms[numTerms++] = makeAttributeTerm(DATA_TYPE, EQUAL, IGNORE,
+						      IGNORE, IGNORE, IGNORE,
+						      type);
 		terms[numTerms++] = makeOperatorTerm(AND);
-		terms[numTerms] = NULL;
+	    }
+	    terms[numTerms++] = makeAttributeTerm(chunk_att,
+						  GREATER_THAN_OR_EQUAL,
+						  IGNORE, IGNORE, IGNORE,
+						  IGNORE,
+						  startChunk);
+	    terms[numTerms++] = makeOperatorTerm(AND);
+	    terms[numTerms++] = makeAttributeTerm(chunk_att, LESS_THAN,
+						  IGNORE, IGNORE, IGNORE,
+						  IGNORE,
+						  endChunk);
+	    terms[numTerms++] = makeOperatorTerm(AND);
+	    terms[numTerms] = NULL;
+
+	    if (doc->ChunkCode == CT_byte || doc->ChunkCode == CT_line) {
+		freeAny(startChunk);
+		freeAny(endChunk);
+	    }
+	}
+
+	freeAny(type);
 
-		if (doc->ChunkCode == CT_byte || doc->ChunkCode == CT_line)
-		  { freeAny(startChunk);
-		    freeAny(endChunk);
-		  }
-	      }
-
-      freeAny(type);
-
-     if (i != 0) /* multiple independent queries, need a disjunction */
-	{ terms = (query_term**)s_realloc((char*)terms,
-					  (size_t)(sizeof(query_term*) *
-						   (numTerms + 1 + 1)));
-	  terms[numTerms++] = makeOperatorTerm(OR);
-	  terms[numTerms] = NULL;
+	if (i != 0)		/* multiple independent queries, need a disjunction */
+	{
+	    terms = S_REALLOC2(query_term *, terms, numTerms);
+
+	    terms[numTerms++] = makeOperatorTerm(OR);
+	    terms[numTerms] = NULL;
 	}
     }
 
-  return(terms);
+    return (terms);
 }
 
 /*----------------------------------------------------------------------*/
 
-static DocObj** makeWAISQueryDocs PARAMS((query_term** terms));
-
-static DocObj**
-makeWAISQueryDocs(terms)
-query_term** terms;
+static DocObj **makeWAISQueryDocs(query_term **terms)
 /* given a list of terms in the form given above, convert them to
    DocObjs.
  */
 {
-  query_term* docTerm = NULL;
-  query_term* fragmentTerm = NULL;
-  DocObj** docs = NULL;
-  DocObj* doc = NULL;
-  long docNum,termNum;
+    query_term *docTerm = NULL;
+    query_term *fragmentTerm = NULL;
+    DocObj **docs = NULL;
+    DocObj *doc = NULL;
+    long docNum, termNum;
 
-  docNum = termNum = 0;
+    docNum = termNum = 0;
 
-  docs = (DocObj**)s_malloc((size_t)(sizeof(DocObj*) * 1));
-  docs[docNum] = NULL;
+    docs = S_MALLOC(DocObj *);
 
-  /* translate the terms into DocObjs */
-  while (true)
-    {
-      query_term* typeTerm = NULL;
-      char* type = NULL;
-      long startTermOffset;
-
-      docTerm = terms[termNum];
-
-      if (docTerm == NULL)
-	break;			/* we're done converting */
-
-      typeTerm = terms[termNum + 1]; /* get the lead Term if it exists */
-
-      if (strcmp(typeTerm->Use,DATA_TYPE) == 0)	/* we do have a type */
-       { startTermOffset = 3;
-	 type = anyToString(typeTerm->Term);
-       }
-      else			/* no type */
-       { startTermOffset = 1;
-	 typeTerm = NULL;
-	 type = NULL;
-       }
-
-      /* grow the doc list */
-      docs = (DocObj**)s_realloc((char*)docs,(size_t)(sizeof(DocObj*) *
-						      (docNum + 1 + 1)));
-
-      /* figure out what kind of docObj to build - and build it */
-      fragmentTerm = terms[termNum + startTermOffset];
-      if (fragmentTerm != NULL && fragmentTerm->TermType == TT_Attribute)
-	{			/* build a document fragment */
-	  query_term* startTerm = fragmentTerm;
-	  query_term* endTerm = terms[termNum + startTermOffset + 2];
-
-	  if (strcmp(startTerm->Use,BYTE) == 0){ /* a byte chunk */
-	    doc = makeDocObjUsingBytes(duplicateAny(docTerm->Term),
-				       type,
-				       anyToLong(startTerm->Term),
-				       anyToLong(endTerm->Term));
-	   log_write("byte");
-	  }else if (strcmp(startTerm->Use,LINE) == 0){ /* a line chunk */
-	    doc = makeDocObjUsingLines(duplicateAny(docTerm->Term),
-				       type,
-				       anyToLong(startTerm->Term),
-				       anyToLong(endTerm->Term));
-	    log_write("line");
-	  }else{
-	log_write("chunk");			/* a paragraph chunk */
-	    doc = makeDocObjUsingParagraphs(duplicateAny(docTerm->Term),
-					    type,
-					    duplicateAny(startTerm->Term),
-					    duplicateAny(endTerm->Term));
-}
-	  termNum += (startTermOffset + 4);	/* point to next term */
-	}
-      else			/* build a full document */
+    docs[docNum] = NULL;
+
+    /* translate the terms into DocObjs */
+    while (true) {
+	query_term *typeTerm = NULL;
+	char *type = NULL;
+	long startTermOffset;
+
+	docTerm = terms[termNum];
+
+	if (docTerm == NULL)
+	    break;		/* we're done converting */
+
+	typeTerm = terms[termNum + 1];	/* get the lead Term if it exists */
+
+	if (strcmp(typeTerm->Use, DATA_TYPE) == 0)	/* we do have a type */
 	{
-	  doc = makeDocObjUsingWholeDocument(duplicateAny(docTerm->Term),
-					     type);
-log_write("whole doc");
-	  termNum += startTermOffset;	/* point to next term */
+	    startTermOffset = 3;
+	    type = anyToString(typeTerm->Term);
+	} else {		/* no type */
+	    startTermOffset = 1;
+	    typeTerm = NULL;
+	    type = NULL;
 	}
 
-      docs[docNum++] = doc;	/* insert the new document */
+	/* grow the doc list */
+	docs = S_REALLOC2(DocObj *, docs, docNum);
+
+	/* figure out what kind of docObj to build - and build it */
+	fragmentTerm = terms[termNum + startTermOffset];
+	if (fragmentTerm != NULL && fragmentTerm->TermType == TT_Attribute) {	/* build a document fragment */
+	    query_term *startTerm = fragmentTerm;
+	    query_term *endTerm = terms[termNum + startTermOffset + 2];
+
+	    if (strcmp(startTerm->Use, BYTE) == 0) {	/* a byte chunk */
+		doc = makeDocObjUsingBytes(duplicateAny(docTerm->Term),
+					   type,
+					   anyToLong(startTerm->Term),
+					   anyToLong(endTerm->Term));
+		log_write("byte");
+	    } else if (strcmp(startTerm->Use, LINE) == 0) {	/* a line chunk */
+		doc = makeDocObjUsingLines(duplicateAny(docTerm->Term),
+					   type,
+					   anyToLong(startTerm->Term),
+					   anyToLong(endTerm->Term));
+		log_write("line");
+	    } else {
+		log_write("chunk");	/* a paragraph chunk */
+		doc = makeDocObjUsingParagraphs(duplicateAny(docTerm->Term),
+						type,
+						duplicateAny(startTerm->Term),
+						duplicateAny(endTerm->Term));
+	    }
+	    termNum += (startTermOffset + 4);	/* point to next term */
+	} else {		/* build a full document */
+	    doc = makeDocObjUsingWholeDocument(duplicateAny(docTerm->Term),
+					       type);
+	    log_write("whole doc");
+	    termNum += startTermOffset;		/* point to next term */
+	}
 
-      docs[docNum] = NULL;	/* keep the doc list terminated */
+	docs[docNum++] = doc;	/* insert the new document */
 
+	docs[docNum] = NULL;	/* keep the doc list terminated */
 
-      if (terms[termNum] != NULL)
-	termNum++; /* skip the OR operator it necessary */
-      else
-	break; /* we are done */
+	if (terms[termNum] != NULL)
+	    termNum++;		/* skip the OR operator it necessary */
+	else
+	    break;		/* we are done */
     }
 
-  return(docs);
+    return (docs);
 }
 
 /*----------------------------------------------------------------------*/
 
-any*
-makeWAISTextQuery(docs)
-DocObj** docs;
+any *makeWAISTextQuery(DocObj **docs)
 /* given a list of DocObjs, return an any whose contents is the corresponding
    type 1 query
  */
 {
-  any *buf = NULL;
-  query_term** terms = NULL;
+    any *buf = NULL;
+    query_term **terms = NULL;
 
-  terms = makeWAISQueryTerms(docs);
-  buf = writeQuery(terms);
+    terms = makeWAISQueryTerms(docs);
+    buf = writeQuery(terms);
 
-  doList((void**)terms,freeTerm);
-  s_free(terms);
+    doList((void **) terms, freeTerm);
+    s_free(terms);
 
-  return(buf);
+    return (buf);
 }
 
 /*----------------------------------------------------------------------*/
 
-DocObj**
-readWAISTextQuery(buf)
-any* buf;
+DocObj **readWAISTextQuery(any *buf)
 /* given an any whose contents are type 1 queries of the WAIS sort,
    construct a list of the corresponding DocObjs
  */
 {
-  query_term** terms = NULL;
-  DocObj** docs = NULL;
+    query_term **terms = NULL;
+    DocObj **docs = NULL;
 
-  terms = readQuery(buf);
-  docs = makeWAISQueryDocs(terms);
+    terms = readQuery(buf);
+    docs = makeWAISQueryDocs(terms);
 
-  doList((void**)terms,freeTerm);
-  s_free(terms);
+    doList((void **) terms, freeTerm);
+    s_free(terms);
 
-  return(docs);
+    return (docs);
 }
 
 /*----------------------------------------------------------------------*/
@@ -2315,29 +2312,23 @@
 /*   caller to assign nulls to the pointer fields of the WAIS object.  */
 /*----------------------------------------------------------------------*/
 
-void
-CSTFreeWAISInitResponse(init)
-WAISInitResponse* init;
+void CSTFreeWAISInitResponse(WAISInitResponse *init)
 /* free an object made with makeWAISInitResponse */
 {
-  s_free(init);
+    s_free(init);
 }
 
 /*----------------------------------------------------------------------*/
 
-void
-CSTFreeWAISSearch(query)
-WAISSearch* query;
+void CSTFreeWAISSearch(WAISSearch *query)
 /* destroy an object made with makeWAISSearch() */
 {
-  s_free(query);
+    s_free(query);
 }
 
 /*----------------------------------------------------------------------*/
 
-void
-CSTFreeDocObj(doc)
-DocObj* doc;
+void CSTFreeDocObj(DocObj *doc)
 /* free a docObj */
 {
     s_free(doc);
@@ -2345,87 +2336,71 @@
 
 /*----------------------------------------------------------------------*/
 
-void
-CSTFreeWAISDocumentHeader(header)
-WAISDocumentHeader* header;
+void CSTFreeWAISDocumentHeader(WAISDocumentHeader *header)
 {
     s_free(header);
 }
 
 /*----------------------------------------------------------------------*/
 
-void
-CSTFreeWAISDocumentShortHeader(header)
-WAISDocumentShortHeader* header;
+void CSTFreeWAISDocumentShortHeader(WAISDocumentShortHeader *header)
 {
-  s_free(header);
+    s_free(header);
 }
+
 /*----------------------------------------------------------------------*/
 
-void
-CSTFreeWAISDocumentLongHeader(header)
-WAISDocumentLongHeader* header;
+void CSTFreeWAISDocumentLongHeader(WAISDocumentLongHeader *header)
 {
-  s_free(header);
+    s_free(header);
 }
 
 /*----------------------------------------------------------------------*/
 
-void
-CSTFreeWAISSearchResponse(response)
-WAISSearchResponse* response;
+void CSTFreeWAISSearchResponse(WAISSearchResponse * response)
 {
-  s_free(response);
+    s_free(response);
 }
 
 /*----------------------------------------------------------------------*/
 
-void
-CSTFreeWAISDocumentText(docText)
-WAISDocumentText* docText;
+void CSTFreeWAISDocumentText(WAISDocumentText *docText)
 {
-  s_free(docText);
+    s_free(docText);
 }
 
 /*----------------------------------------------------------------------*/
 
-void
-CSTFreeWAISDocHeadlines(docHeadline)
-WAISDocumentHeadlines* docHeadline;
+void CSTFreeWAISDocHeadlines(WAISDocumentHeadlines *docHeadline)
 {
-  s_free(docHeadline);
+    s_free(docHeadline);
 }
 
 /*----------------------------------------------------------------------*/
 
-void
-CSTFreeWAISDocumentCodes(docCodes)
-WAISDocumentCodes* docCodes;
+void CSTFreeWAISDocumentCodes(WAISDocumentCodes *docCodes)
 {
-  s_free(docCodes);
+    s_free(docCodes);
 }
 
 /*----------------------------------------------------------------------*/
 
-void
-CSTFreeWAISTextQuery(query)
-any* query;
+void CSTFreeWAISTextQuery(any *query)
 {
-   freeAny(query);
+    freeAny(query);
 }
 
 /*----------------------------------------------------------------------*/
 
-
 /*
-**	Routines originally from WMessage.c -- FM
-**
-**----------------------------------------------------------------------*/
+ *	Routines originally from WMessage.c -- FM
+ *
+ *----------------------------------------------------------------------*/
 /* WIDE AREA INFORMATION SERVER SOFTWARE
-   No guarantees or restrictions.  See the readme file for the full standard
-   disclaimer.
-   3.26.90
-*/
+ * No guarantees or restrictions.  See the readme file for the full standard
+ * disclaimer.
+ * 3.26.90
+ */
 
 /* This file is for reading and writing the wais packet header.
  * Morris@think.com
@@ -2438,20 +2413,18 @@
 
 /*---------------------------------------------------------------------*/
 
-void
-readWAISPacketHeader(msgBuffer,header_struct)
-char* msgBuffer;
-WAISMessage *header_struct;
-{
-  /* msgBuffer is a string containing at least HEADER_LENGTH bytes. */
-
-  memmove(header_struct->msg_len,msgBuffer,(size_t)10);
-  header_struct->msg_type = char_downcase((unsigned long)msgBuffer[10]);
-  header_struct->hdr_vers = char_downcase((unsigned long)msgBuffer[11]);
-  memmove(header_struct->server,(void*)(msgBuffer + 12),(size_t)10);
-  header_struct->compression = char_downcase((unsigned long)msgBuffer[22]);
-  header_struct->encoding = char_downcase((unsigned long)msgBuffer[23]);
-  header_struct->msg_checksum = char_downcase((unsigned long)msgBuffer[24]);
+void readWAISPacketHeader(char *msgBuffer,
+			  WAISMessage * header_struct)
+{
+    /* msgBuffer is a string containing at least HEADER_LENGTH bytes. */
+
+    memmove(header_struct->msg_len, msgBuffer, (size_t) 10);
+    header_struct->msg_type = char_downcase((unsigned long) msgBuffer[10]);
+    header_struct->hdr_vers = char_downcase((unsigned long) msgBuffer[11]);
+    memmove(header_struct->server, (void *) (msgBuffer + 12), (size_t) 10);
+    header_struct->compression = char_downcase((unsigned long) msgBuffer[22]);
+    header_struct->encoding = char_downcase((unsigned long) msgBuffer[23]);
+    header_struct->msg_checksum = char_downcase((unsigned long) msgBuffer[24]);
 }
 
 /*---------------------------------------------------------------------*/
@@ -2460,43 +2433,35 @@
  * options for the arguments.
  */
 
-void
-writeWAISPacketHeader(header,
-		      dataLen,
-		      type,
-		      server,
-		      compression,
-		      encoding,
-		      version)
-char* header;
-long dataLen;
-long type;
-char* server;
-long compression;
-long encoding;
-long version;
+void writeWAISPacketHeader(char *header,
+			   long dataLen,
+			   long type,
+			   char *server,
+			   long compression,
+			   long encoding,
+			   long version)
 /* Puts together the new wais before-the-z39-packet header. */
 {
-  char lengthBuf[11];
-  char serverBuf[11];
+    char lengthBuf[11];
+    char serverBuf[11];
 
-  long serverLen = strlen(server);
-  if (serverLen > 10)
-    serverLen = 10;
+    long serverLen = strlen(server);
 
-  sprintf(lengthBuf, "%010ld", dataLen);
-  strncpy(header,lengthBuf,10);
+    if (serverLen > 10)
+	serverLen = 10;
 
-  header[10] = type & 0xFF;
-  header[11] = version & 0xFF;
+    sprintf(lengthBuf, "%010ld", dataLen);
+    strncpy(header, lengthBuf, 10);
 
-  strncpy(serverBuf,server,serverLen);
-  strncpy((char*)(header + 12),serverBuf,serverLen);
+    header[10] = type & 0xFF;
+    header[11] = version & 0xFF;
 
-  header[22] = compression & 0xFF;
-  header[23] = encoding & 0xFF;
-  header[24] = '0'; /* checkSum(header + HEADER_LENGTH,dataLen);   XXX the result must be ascii */
+    strncpy(serverBuf, server, serverLen);
+    strncpy((char *) (header + 12), serverBuf, serverLen);
+
+    header[22] = compression & 0xFF;
+    header[23] = encoding & 0xFF;
+    header[24] = '0';		/* checkSum(header + HEADER_LENGTH,dataLen);   XXX the result must be ascii */
 }
 
 /*---------------------------------------------------------------------*/
-
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/HTVMSUtils.h
+++ lynx-cur-2.8.6/WWW/Library/Implementation/HTVMSUtils.h
@@ -11,91 +11,91 @@
 
 #include <HTAnchor.h>
 
-extern BOOL HTVMSFileVersions;	/* Include version numbers in listing? */
+#ifdef __cplusplus
+extern "C" {
+#endif
+    extern BOOL HTVMSFileVersions;	/* Include version numbers in listing? */
 
 /* PUBLIC							HTVMS_authSysPrv()
-**		CHECKS IF THIS PROCESS IS AUTHORIZED TO ENABLE SYSPRV
-** ON ENTRY:
-**	No arguments.
-**
-** ON EXIT:
-**	returns	YES if SYSPRV is authorized
-*/
-PUBLIC BOOL HTVMS_authSysPrv NOPARAMS;
-
+ *		CHECKS IF THIS PROCESS IS AUTHORIZED TO ENABLE SYSPRV
+ * ON ENTRY:
+ *	No arguments.
+ *
+ * ON EXIT:
+ *	returns	YES if SYSPRV is authorized
+ */
+    extern BOOL HTVMS_authSysPrv(void);
 
 /* PUBLIC							HTVMS_enableSysPrv()
-**		ENABLES SYSPRV
-** ON ENTRY:
-**	No arguments.
-**
-** ON EXIT:
-**
-*/
-PUBLIC void HTVMS_enableSysPrv NOPARAMS;
-
+ *		ENABLES SYSPRV
+ * ON ENTRY:
+ *	No arguments.
+ *
+ * ON EXIT:
+ *
+ */
+    extern void HTVMS_enableSysPrv(void);
 
 /* PUBLIC							HTVMS_disableSysPrv()
-**		DISABLES SYSPRV
-** ON ENTRY:
-**	No arguments.
-**
-** ON EXIT:
-**
-*/
-PUBLIC void HTVMS_disableSysPrv NOPARAMS;
+ *		DISABLES SYSPRV
+ * ON ENTRY:
+ *	No arguments.
+ *
+ * ON EXIT:
+ *
+ */
+    extern void HTVMS_disableSysPrv(void);
 
 /* PUBLIC							HTVMS_checkAccess()
-**		CHECKS ACCESS TO FILE FOR CERTAIN USER
-** ON ENTRY:
-**	FileName	The file to be accessed
-**	UserName	Name of the user to check access for
-**
-** ON EXIT:
-**	returns YES if access is allowed
-**
-*/
-PUBLIC BOOL HTVMS_checkAccess PARAMS((
-	CONST char * FileName,
-	CONST char * UserName,
-	CONST char * Method));
-
+ *		CHECKS ACCESS TO FILE FOR CERTAIN USER
+ * ON ENTRY:
+ *	FileName	The file to be accessed
+ *	UserName	Name of the user to check access for
+ *
+ * ON EXIT:
+ *	returns YES if access is allowed
+ *
+ */
+    extern BOOL HTVMS_checkAccess(const char *FileName,
+				  const char *UserName,
+				  const char *Method);
 
 /* PUBLIC							HTVMS_wwwName()
-**		CONVERTS VMS Name into WWW Name
-** ON ENTRY:
-**	vmsname		VMS file specification (NO NODE)
-**
-** ON EXIT:
-**	returns		www file specification
-**
-** EXAMPLES:
-**	vmsname				wwwname
-**	DISK$USER			disk$user
-**	DISK$USER:			/disk$user/
-**	DISK$USER:[DUNS]		/disk$user/duns
-**	DISK$USER:[DUNS.ECHO]		/disk$user/duns/echo
-**	[DUNS]				duns
-**	[DUNS.ECHO]			duns/echo
-**	[DUNS.ECHO.-.TRANS]		duns/echo/../trans
-**	[DUNS.ECHO.--.TRANS]		duns/echo/../../trans
-**	[.DUNS]				duns
-**	[.DUNS.ECHO]			duns/echo
-**	[.DUNS.ECHO]TEST.COM		duns/echo/test.com
-**	TEST.COM			test.com
-**
-**
-*/
-PUBLIC char * HTVMS_wwwName PARAMS((
-	CONST char *	vmsname));
-
-PUBLIC int HTVMSBrowseDir PARAMS((
-	CONST char * address,
-	HTParentAnchor * anchor,
-	HTFormat format_out,
-	HTStream * sink));
-
-extern int HTVMS_remove(char *filename);
-extern void HTVMS_purge(char *filename);
-
-#endif /* not HTVMSUTIL_H */
+ *		CONVERTS VMS Name into WWW Name
+ * ON ENTRY:
+ *	vmsname		VMS file specification (NO NODE)
+ *
+ * ON EXIT:
+ *	returns		www file specification
+ *
+ * EXAMPLES:
+ *	vmsname				wwwname
+ *	DISK$USER			disk$user
+ *	DISK$USER:			/disk$user/
+ *	DISK$USER:[DUNS]		/disk$user/duns
+ *	DISK$USER:[DUNS.ECHO]		/disk$user/duns/echo
+ *	[DUNS]				duns
+ *	[DUNS.ECHO]			duns/echo
+ *	[DUNS.ECHO.-.TRANS]		duns/echo/../trans
+ *	[DUNS.ECHO.--.TRANS]		duns/echo/../../trans
+ *	[.DUNS]				duns
+ *	[.DUNS.ECHO]			duns/echo
+ *	[.DUNS.ECHO]TEST.COM		duns/echo/test.com
+ *	TEST.COM			test.com
+ *
+ *
+ */
+    const extern char *HTVMS_wwwName(const char *vmsname);
+
+    extern int HTVMSBrowseDir(const char *address,
+			      HTParentAnchor *anchor,
+			      HTFormat format_out,
+			      HTStream *sink);
+
+    extern int HTVMS_remove(char *filename);
+    extern void HTVMS_purge(char *filename);
+
+#ifdef __cplusplus
+}
+#endif
+#endif				/* not HTVMSUTIL_H */
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/HTUU.h
+++ lynx-cur-2.8.6/WWW/Library/Implementation/HTUU.h
@@ -1,10 +1,11 @@
 /*                              ENCODING TO PRINTABLE CHARACTERS
 
-   File module provides functions HTUU_encode() and HTUU_decode() which convert a buffer
-   of bytes to/from RFC 1113 printable encoding format.  This technique is similar to the
-   familiar Unix uuencode format in that it maps 6 binary bits to one ASCII character (or
-   more aptly, 3 binary bytes to 4 ASCII characters).  However, RFC 1113 does not use the
-   same mapping to printable characters as uuencode.
+   File module provides functions HTUU_encode() and HTUU_decode() which convert
+   a buffer of bytes to/from RFC 1113 printable encoding format.  This
+   technique is similar to the familiar Unix uuencode format in that it maps 6
+   binary bits to one ASCII character (or more aptly, 3 binary bytes to 4 ASCII
+   characters).  However, RFC 1113 does not use the same mapping to printable
+   characters as uuencode.
 
  */
 
@@ -14,13 +15,19 @@
 #ifndef HTUTILS_H
 #include <HTUtils.h>
 #endif
- 
-PUBLIC int HTUU_encode PARAMS((unsigned char *bufin,
-                               unsigned int nbytes,
-                               char *bufcoded));
-
-PUBLIC int HTUU_decode PARAMS((char *bufcoded,
-                               unsigned char *bufplain,
-                               int outbufsize));
 
-#endif /* HTUU_H */
+#ifdef __cplusplus
+extern "C" {
+#endif
+    extern int HTUU_encode(unsigned char *bufin,
+			   unsigned int nbytes,
+			   char *bufcoded);
+
+    extern int HTUU_decode(char *bufcoded,
+			   unsigned char *bufplain,
+			   int outbufsize);
+
+#ifdef __cplusplus
+}
+#endif
+#endif				/* HTUU_H */
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/HTLex.h
+++ lynx-cur-2.8.6/WWW/Library/Implementation/HTLex.h
@@ -8,22 +8,25 @@
 #ifndef HTUTILS_H
 #include <HTUtils.h>
 #endif
- 
-typedef enum {
-    LEX_NONE,		/* Internally used      */
-    LEX_EOF,		/* End of file          */
-    LEX_REC_SEP,	/* Record separator     */
-    LEX_FIELD_SEP,	/* Field separator      */
-    LEX_ITEM_SEP,	/* List item separator  */
-    LEX_OPEN_PAREN,	/* Group start tag      */
-    LEX_CLOSE_PAREN,	/* Group end tag        */
-    LEX_AT_SIGN,	/* Address qualifier    */
-    LEX_ALPH_STR,	/* Alphanumeric string  */
-    LEX_TMPL_STR	/* Template string      */
-} LexItem;
 
-extern char HTlex_buffer[];	/* Read lexical string          */
-extern int HTlex_line;		/* Line number in source file   */
+#ifdef __cplusplus
+extern "C" {
+#endif
+    typedef enum {
+	LEX_NONE,		/* Internally used      */
+	LEX_EOF,		/* End of file          */
+	LEX_REC_SEP,		/* Record separator     */
+	LEX_FIELD_SEP,		/* Field separator      */
+	LEX_ITEM_SEP,		/* List item separator  */
+	LEX_OPEN_PAREN,		/* Group start tag      */
+	LEX_CLOSE_PAREN,	/* Group end tag        */
+	LEX_AT_SIGN,		/* Address qualifier    */
+	LEX_ALPH_STR,		/* Alphanumeric string  */
+	LEX_TMPL_STR		/* Template string      */
+    } LexItem;
+
+    extern char HTlex_buffer[];	/* Read lexical string          */
+    extern int HTlex_line;	/* Line number in source file   */
 
 /*
 
@@ -33,23 +36,29 @@
 
  */
 
-PUBLIC LexItem lex PARAMS((FILE * fp));
+    extern LexItem lex(FILE *fp);
+
 /*
 
 Push Back Latest Item
 
  */
 
-PUBLIC void unlex PARAMS((LexItem lex_item));
+    extern void unlex(LexItem lex_item);
+
 /*
 
 Get the Name for Lexical Item
 
  */
 
-PUBLIC char *lex_verbose PARAMS((LexItem lex_item));
+    extern const char *lex_verbose(LexItem lex_item);
+
 /*
 
  */
 
-#endif /* not HTLEX_H */
+#ifdef __cplusplus
+}
+#endif
+#endif				/* not HTLEX_H */
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/HTAssoc.h
+++ lynx-cur-2.8.6/WWW/Library/Implementation/HTAssoc.h
@@ -9,22 +9,27 @@
 
 #include <HTList.h>
 
-typedef HTList HTAssocList;
-
-typedef struct {
-    char * name;
-    char * value;
-} HTAssoc;
-
-
-PUBLIC HTAssocList *HTAssocList_new NOPARAMS;
-PUBLIC void HTAssocList_delete PARAMS((HTAssocList * alist));
-
-PUBLIC void HTAssocList_add PARAMS((HTAssocList *       alist,
-                                    CONST char *        name,
-                                    CONST char *        value));
-
-PUBLIC char *HTAssocList_lookup PARAMS((HTAssocList *   alist,
-                                        CONST char *    name));
-
-#endif /* not HTASSOC_H */
+#ifdef __cplusplus
+extern "C" {
+#endif
+    typedef HTList HTAssocList;
+
+    typedef struct {
+	char *name;
+	char *value;
+    } HTAssoc;
+
+    extern HTAssocList *HTAssocList_new(void);
+    extern void HTAssocList_delete(HTAssocList *alist);
+
+    extern void HTAssocList_add(HTAssocList *alist,
+				const char *name,
+				const char *value);
+
+    extern char *HTAssocList_lookup(HTAssocList *alist,
+				    const char *name);
+
+#ifdef __cplusplus
+}
+#endif
+#endif				/* not HTASSOC_H */
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/HTAAProt.h
+++ lynx-cur-2.8.6/WWW/Library/Implementation/HTAAProt.h
@@ -8,22 +8,24 @@
 #include <HTGroup.h>
 #include <HTAssoc.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
 /*
 
 Server's Representation of Document (Tree) Protections
 
- */
+ */ typedef struct {
+	char *ctemplate;	/* Template for this protection         */
+	char *filename;		/* Current document file                */
+	char *uid_name;		/* Effective uid (name of it)           */
+	char *gid_name;		/* Effective gid (name of it)           */
+	GroupDef *mask_group;	/* Allowed users and IP addresses       */
+	HTList *valid_schemes;	/* Valid authentication schemes         */
+	HTAssocList *values;	/* Association list for scheme specific */
+	/* parameters.                          */
+    } HTAAProt;
 
-typedef struct {
-    char *        template;     /* Template for this protection         */
-    char *        filename;     /* Current document file                */
-    char *        uid_name;     /* Effective uid (name of it)           */
-    char *        gid_name;     /* Effective gid (name of it)           */
-    GroupDef *    mask_group;   /* Allowed users and IP addresses       */
-    HTList *      valid_schemes;/* Valid authentication schemes         */
-    HTAssocList * values;       /* Association list for scheme specific */
-                                /* parameters.                          */
-} HTAAProt;
 /*
 
 Callbacks for rule system
@@ -41,66 +43,64 @@
  */
 
 /* PUBLIC                                       HTAA_setDefaultProtection()
-**              SET THE DEFAULT PROTECTION MODE
-**              (called by rule system when a
-**              "defprot" rule is matched)
-** ON ENTRY:
-**      cur_docname     is the current result of rule translations.
-**      prot_filename   is the protection setup file (second argument
-**                      for "defprot" rule, optional)
-**      eff_ids         contains user and group names separated by
-**                      a dot, corresponding to the effective uid
-**                      gid under which the server should run,
-**                      default is "nobody.nogroup" (third argument
-**                      for "defprot" rule, optional; can be given
-**                      only if protection setup file is also given).
-**
-** ON EXIT:
-**      returns         nothing.
-**                      Sets the module-wide variable default_prot.
-*/
-extern void HTAA_setDefaultProtection PARAMS((CONST char *      cur_docname,
-                                              CONST char *      prot_filename,
-                                              CONST char *      eff_ids));
-
-
+ *              SET THE DEFAULT PROTECTION MODE
+ *              (called by rule system when a
+ *              "defprot" rule is matched)
+ * ON ENTRY:
+ *      cur_docname     is the current result of rule translations.
+ *      prot_filename   is the protection setup file (second argument
+ *                      for "defprot" rule, optional)
+ *      eff_ids         contains user and group names separated by
+ *                      a dot, corresponding to the effective uid
+ *                      gid under which the server should run,
+ *                      default is "nobody.nogroup" (third argument
+ *                      for "defprot" rule, optional; can be given
+ *                      only if protection setup file is also given).
+ *
+ * ON EXIT:
+ *      returns         nothing.
+ *                      Sets the module-wide variable default_prot.
+ */
+    extern void HTAA_setDefaultProtection(const char *cur_docname,
+					  const char *prot_filename,
+					  const char *eff_ids);
 
 /* PUBLIC                                       HTAA_setCurrentProtection()
-**              SET THE CURRENT PROTECTION MODE
-**              (called by rule system when a
-**              "protect" rule is matched)
-** ON ENTRY:
-**      cur_docname     is the current result of rule translations.
-**      prot_filename   is the protection setup file (second argument
-**                      for "protect" rule, optional)
-**      eff_ids         contains user and group names separated by
-**                      a dot, corresponding to the effective uid
-**                      gid under which the server should run,
-**                      default is "nobody.nogroup" (third argument
-**                      for "protect" rule, optional; can be given
-**                      only if protection setup file is also given).
-**
-** ON EXIT:
-**      returns         nothing.
-**                      Sets the module-wide variable current_prot.
-*/
-extern void HTAA_setCurrentProtection PARAMS((CONST char *      cur_docname,
-                                              CONST char *      prot_filename,
-                                              CONST char *      eff_ids));
-
+ *              SET THE CURRENT PROTECTION MODE
+ *              (called by rule system when a
+ *              "protect" rule is matched)
+ * ON ENTRY:
+ *      cur_docname     is the current result of rule translations.
+ *      prot_filename   is the protection setup file (second argument
+ *                      for "protect" rule, optional)
+ *      eff_ids         contains user and group names separated by
+ *                      a dot, corresponding to the effective uid
+ *                      gid under which the server should run,
+ *                      default is "nobody.nogroup" (third argument
+ *                      for "protect" rule, optional; can be given
+ *                      only if protection setup file is also given).
+ *
+ * ON EXIT:
+ *      returns         nothing.
+ *                      Sets the module-wide variable current_prot.
+ */
+    extern void HTAA_setCurrentProtection(const char *cur_docname,
+					  const char *prot_filename,
+					  const char *eff_ids);
 
 /* SERVER INTERNAL                                      HTAA_clearProtections()
-**              CLEAR DOCUMENT PROTECTION MODE
-**              (ALSO DEFAULT PROTECTION)
-**              (called by the rule system)
-** ON ENTRY:
-**      No arguments.
-**
-** ON EXIT:
-**      returns nothing.
-**              Frees the memory used by protection information.
-*/
-extern void HTAA_clearProtections NOPARAMS;
+ *              CLEAR DOCUMENT PROTECTION MODE
+ *              (ALSO DEFAULT PROTECTION)
+ *              (called by the rule system)
+ * ON ENTRY:
+ *      No arguments.
+ *
+ * ON EXIT:
+ *      returns nothing.
+ *              Frees the memory used by protection information.
+ */
+    extern void HTAA_clearProtections(void);
+
 /*
 
 Getting Protection Settings
@@ -115,42 +115,41 @@
  */
 
 /* PUBLIC                                       HTAA_getCurrentProtection()
-**              GET CURRENT PROTECTION SETUP STRUCTURE
-**              (this is set up by callbacks made from
-**               the rule system when matching "protect"
-**               (and "defprot") rules)
-** ON ENTRY:
-**      HTTranslate() must have been called before calling
-**      this function.
-**
-** ON EXIT:
-**      returns a HTAAProt structure representing the
-**              protection setup of the HTTranslate()'d file.
-**              This must not be free()'d.
-*/
-extern HTAAProt *HTAA_getCurrentProtection NOPARAMS;
-
-
+ *              GET CURRENT PROTECTION SETUP STRUCTURE
+ *              (this is set up by callbacks made from
+ *               the rule system when matching "protect"
+ *               (and "defprot") rules)
+ * ON ENTRY:
+ *      HTTranslate() must have been called before calling
+ *      this function.
+ *
+ * ON EXIT:
+ *      returns a HTAAProt structure representing the
+ *              protection setup of the HTTranslate()'d file.
+ *              This must not be free()'d.
+ */
+    extern HTAAProt *HTAA_getCurrentProtection(void);
 
 /* PUBLIC                                       HTAA_getDefaultProtection()
-**              GET DEFAULT PROTECTION SETUP STRUCTURE
-**              (this is set up by callbacks made from
-**               the rule system when matching "defprot"
-**               rules)
-** ON ENTRY:
-**      HTTranslate() must have been called before calling
-**      this function.
-**
-** ON EXIT:
-**      returns a HTAAProt structure representing the
-**              default protection setup of the HTTranslate()'d
-**              file (if HTAA_getCurrentProtection() returned
-**              NULL, i.e., if there is no "protect" rule
-**              but ACL exists, and we need to know default
-**              protection settings).
-**              This must not be free()'d.
-*/
-extern HTAAProt *HTAA_getDefaultProtection NOPARAMS;
+ *              GET DEFAULT PROTECTION SETUP STRUCTURE
+ *              (this is set up by callbacks made from
+ *               the rule system when matching "defprot"
+ *               rules)
+ * ON ENTRY:
+ *      HTTranslate() must have been called before calling
+ *      this function.
+ *
+ * ON EXIT:
+ *      returns a HTAAProt structure representing the
+ *              default protection setup of the HTTranslate()'d
+ *              file (if HTAA_getCurrentProtection() returned
+ *              NULL, i.e., if there is no "protect" rule
+ *              but ACL exists, and we need to know default
+ *              protection settings).
+ *              This must not be free()'d.
+ */
+    extern HTAAProt *HTAA_getDefaultProtection(void);
+
 /*
 
 Get User and Group IDs to Which Set to
@@ -159,28 +158,27 @@
 
 #ifndef VMS
 /* PUBLIC                                                       HTAA_getUid()
-**              GET THE USER ID TO CHANGE THE PROCESS UID TO
-** ON ENTRY:
-**      No arguments.
-**
-** ON EXIT:
-**      returns the uid number to give to setuid() system call.
-**              Default is 65534 (nobody).
-*/
-extern int HTAA_getUid NOPARAMS;
-
+ *              GET THE USER ID TO CHANGE THE PROCESS UID TO
+ * ON ENTRY:
+ *      No arguments.
+ *
+ * ON EXIT:
+ *      returns the uid number to give to setuid() system call.
+ *              Default is 65534 (nobody).
+ */
+    extern int HTAA_getUid(void);
 
 /* PUBLIC                                                       HTAA_getGid()
-**              GET THE GROUP ID TO CHANGE THE PROCESS GID TO
-** ON ENTRY:
-**      No arguments.
-**
-** ON EXIT:
-**      returns the uid number to give to setgid() system call.
-**              Default is 65534 (nogroup).
-*/
-extern int HTAA_getGid NOPARAMS;
-#endif /* not VMS */
+ *              GET THE GROUP ID TO CHANGE THE PROCESS GID TO
+ * ON ENTRY:
+ *      No arguments.
+ *
+ * ON EXIT:
+ *      returns the uid number to give to setgid() system call.
+ *              Default is 65534 (nogroup).
+ */
+    extern int HTAA_getGid(void);
+#endif				/* not VMS */
 /*
 
    For VMS:
@@ -189,62 +187,68 @@
 
 #ifdef VMS
 /* PUBLIC                                                       HTAA_getUidName()
-**              GET THE USER ID NAME (VMS ONLY)
-** ON ENTRY:
-**      No arguments.
-**
-** ON EXIT:
-**      returns the user name
-**              Default is "" (nobody).
-*/
-extern char * HTAA_getUidName NOPARAMS;
+ *              GET THE USER ID NAME (VMS ONLY)
+ * ON ENTRY:
+ *      No arguments.
+ *
+ * ON EXIT:
+ *      returns the user name
+ *              Default is "" (nobody).
+ */
+    extern const char *HTAA_getUidName(void);
 
 /* PUBLIC                                                       HTAA_getFileName
-**              GET THE FILENAME (VMS ONLY)
-** ON ENTRY:
-**      No arguments.
-**
-** ON EXIT:
-**      returns the filename
-*/
-extern char * HTAA_getFileName NOPARAMS;
-#endif /* VMS */
+ *              GET THE FILENAME (VMS ONLY)
+ * ON ENTRY:
+ *      No arguments.
+ *
+ * ON EXIT:
+ *      returns the filename
+ */
+    extern const char *HTAA_getFileName(void);
+#endif				/* VMS */
 
 /* PUBLIC                                                       HTAA_UidToName
-**              GET THE USER NAME
-** ON ENTRY:
-**      The user-id
-**
-** ON EXIT:
-**      returns the user name
-*/
-extern char * HTAA_UidToName PARAMS((int uid));
+ *              GET THE USER NAME
+ * ON ENTRY:
+ *      The user-id
+ *
+ * ON EXIT:
+ *      returns the user name
+ */
+    extern const char *HTAA_UidToName(int uid);
+
 /* PUBLIC                                                       HTAA_NameToUid
-**              GET THE USER ID
-** ON ENTRY:
-**      The user-name
-**
-** ON EXIT:
-**      returns the user id
-*/
-extern int HTAA_NameToUid PARAMS((char *name));
+ *              GET THE USER ID
+ * ON ENTRY:
+ *      The user-name
+ *
+ * ON EXIT:
+ *      returns the user id
+ */
+    extern int HTAA_NameToUid(const char *name);
+
 /* PUBLIC                                                       HTAA_GidToName
-**              GET THE GROUP NAME
-** ON ENTRY:
-**      The group-id
-**
-** ON EXIT:
-**      returns the group name
-*/
-extern char * HTAA_GidToName PARAMS((int gid));
+ *              GET THE GROUP NAME
+ * ON ENTRY:
+ *      The group-id
+ *
+ * ON EXIT:
+ *      returns the group name
+ */
+    extern const char *HTAA_GidToName(int gid);
+
 /* PUBLIC                                                       HTAA_NameToGid
-**              GET THE GROUP ID
-** ON ENTRY:
-**      The group-name
-**
-** ON EXIT:
-**      returns the group id
-*/
-extern int HTAA_NameToGid PARAMS((char *name));
+ *              GET THE GROUP ID
+ * ON ENTRY:
+ *      The group-name
+ *
+ * ON EXIT:
+ *      returns the group id
+ */
+    extern int HTAA_NameToGid(const char *name);
 
-#endif /* not HTAAPROT_H */
+#ifdef __cplusplus
+}
+#endif
+#endif				/* not HTAAPROT_H */
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/HTGroup.h
+++ lynx-cur-2.8.6/WWW/Library/Implementation/HTGroup.h
@@ -7,33 +7,34 @@
 
 #include <HTList.h>
 
-
-typedef HTList GroupDefList;
-typedef HTList ItemList;
-
-typedef struct {
-    char *      group_name;
-    ItemList *  item_list;
-} GroupDef;
-
-
-/*
-** Access Authorization failure reasons
-*/
-typedef enum {
-    HTAA_OK,            /* 200 OK                               */
-    HTAA_OK_GATEWAY,    /* 200 OK, acting as a gateway          */
-    HTAA_NO_AUTH,       /* 401 Unauthorized, not authenticated  */
-    HTAA_NOT_MEMBER,    /* 401 Unauthorized, not authorized     */
-    HTAA_IP_MASK,       /* 403 Forbidden by IP mask             */
-    HTAA_BY_RULE,       /* 403 Forbidden by rule                */
-    HTAA_NO_ACL,        /* 403 Forbidden, ACL non-existent      */
-    HTAA_NO_ENTRY,      /* 403 Forbidden, no ACL entry          */
-    HTAA_SETUP_ERROR,   /* 403 Forbidden, server setup error    */
-    HTAA_DOTDOT,        /* 403 Forbidden, URL with /../ illegal */
-    HTAA_HTBIN,         /* 403 Forbidden, /htbin not enabled    */
-    HTAA_NOT_FOUND      /* 404 Not found, or read protected     */
-} HTAAFailReasonType;
+#ifdef __cplusplus
+extern "C" {
+#endif
+    typedef HTList GroupDefList;
+    typedef HTList ItemList;
+
+    typedef struct {
+	char *group_name;
+	ItemList *item_list;
+    } GroupDef;
+
+/*
+ * Access Authorization failure reasons
+ */
+    typedef enum {
+	HTAA_OK,		/* 200 OK                               */
+	HTAA_OK_GATEWAY,	/* 200 OK, acting as a gateway          */
+	HTAA_NO_AUTH,		/* 401 Unauthorized, not authenticated  */
+	HTAA_NOT_MEMBER,	/* 401 Unauthorized, not authorized     */
+	HTAA_IP_MASK,		/* 403 Forbidden by IP mask             */
+	HTAA_BY_RULE,		/* 403 Forbidden by rule                */
+	HTAA_NO_ACL,		/* 403 Forbidden, ACL non-existent      */
+	HTAA_NO_ENTRY,		/* 403 Forbidden, no ACL entry          */
+	HTAA_SETUP_ERROR,	/* 403 Forbidden, server setup error    */
+	HTAA_DOTDOT,		/* 403 Forbidden, URL with /../ illegal */
+	HTAA_HTBIN,		/* 403 Forbidden, /htbin not enabled    */
+	HTAA_NOT_FOUND		/* 404 Not found, or read protected     */
+    } HTAAFailReasonType;
 
 /*
 
@@ -100,7 +101,8 @@
 
  */
 
-PUBLIC GroupDef *HTAA_parseGroupDef PARAMS((FILE * fp));
+    extern GroupDef *HTAA_parseGroupDef(FILE *fp);
+
 /*
 
 Fill in Pointers to referenced Group Definitions in a Group Definition
@@ -110,8 +112,9 @@
 
  */
 
-PUBLIC void HTAA_resolveGroupReferences PARAMS((GroupDef *     group_def,
-                                                GroupDefList * group_def_list));
+    extern void HTAA_resolveGroupReferences(GroupDef *group_def,
+					    GroupDefList *group_def_list);
+
 /*
 
 Read Group File (and do caching)
@@ -121,7 +124,8 @@
 
  */
 
-PUBLIC GroupDefList *HTAA_readGroupFile PARAMS((CONST char * filename));
+    extern GroupDefList *HTAA_readGroupFile(const char *filename);
+
 /*
 
 Delete Group Definition
@@ -131,14 +135,16 @@
 
  */
 
-PUBLIC void GroupDef_delete PARAMS((GroupDef * group_def));
+    extern void GroupDef_delete(GroupDef *group_def);
+
 /*
 
 Print Out Group Definition (for trace purposes)
 
  */
 
-PUBLIC void HTAA_printGroupDef PARAMS((GroupDef * group_def));
+    extern void HTAA_printGroupDef(GroupDef *group_def);
+
 /*
 
 Does a User Belong to a Given Set of Groups
@@ -148,26 +154,29 @@
  */
 
 /* PUBLIC                                       HTAA_userAndInetInGroup()
-**              CHECK IF USER BELONGS TO TO A GIVEN GROUP
-**              AND THAT THE CONNECTION COMES FROM AN
-**              ADDRESS THAT IS ALLOWED BY THAT GROUP
-** ON ENTRY:
-**      group           the group definition structure.
-**      username        connecting user.
-**      ip_number       browser host IP number, optional.
-**      ip_name         browser host IP name, optional.
-**                      However, one of ip_number or ip_name
-**                      must be given.
-** ON EXIT:
-**      returns         HTAA_IP_MASK, if IP address mask was
-**                      reason for failing.
-**                      HTAA_NOT_MEMBER, if user does not belong
-**                      to the group.
-**                      HTAA_OK if both IP address and user are ok.
-*/
-PUBLIC HTAAFailReasonType HTAA_userAndInetInGroup PARAMS((GroupDef * group,
-                                                          char *     username,
-                                                          char *     ip_number,
-                                                          char *     ip_name));
-
-#endif /* not HTGROUP_H */
+ *              CHECK IF USER BELONGS TO TO A GIVEN GROUP
+ *              AND THAT THE CONNECTION COMES FROM AN
+ *              ADDRESS THAT IS ALLOWED BY THAT GROUP
+ * ON ENTRY:
+ *      group           the group definition structure.
+ *      username        connecting user.
+ *      ip_number       browser host IP number, optional.
+ *      ip_name         browser host IP name, optional.
+ *                      However, one of ip_number or ip_name
+ *                      must be given.
+ * ON EXIT:
+ *      returns         HTAA_IP_MASK, if IP address mask was
+ *                      reason for failing.
+ *                      HTAA_NOT_MEMBER, if user does not belong
+ *                      to the group.
+ *                      HTAA_OK if both IP address and user are ok.
+ */
+    extern HTAAFailReasonType HTAA_userAndInetInGroup(GroupDef *group,
+						      char *username,
+						      char *ip_number,
+						      char *ip_name);
+
+#ifdef __cplusplus
+}
+#endif
+#endif				/* not HTGROUP_H */
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/HTAABrow.h
+++ lynx-cur-2.8.6/WWW/Library/Implementation/HTAABrow.h
@@ -31,8 +31,11 @@
 #ifndef HTAABROW_H
 #define HTAABROW_H
 
-#include <HTAAUtil.h>           /* Common parts of AA */
+#include <HTAAUtil.h>		/* Common parts of AA */
 
+#ifdef __cplusplus
+extern "C" {
+#endif
 /*
 
 Routines for Browser Side Recording of AA Info
@@ -49,71 +52,65 @@
       HTAA_shouldRetryWithAuth() determines whether to retry the request with AA or with a
       new AA (in case username or password was misspelled).
 
- */
-
-/* PUBLIC                                               HTAA_composeAuth()
-**
-**      COMPOSE THE ENTIRE AUTHORIZATION HEADER LINE IF WE
-**      ALREADY KNOW, THAT THE HOST MIGHT REQUIRE AUTHORIZATION
-**
-** ON ENTRY:
-**      hostname        is the hostname of the server.
-**      portnumber      is the portnumber in which the server runs.
-**      docname         is the pathname of the document (as in URL)
-**
-** ON EXIT:
-**      returns NULL, if no authorization seems to be needed, or
-**              if it is the entire Authorization: line, e.g.
-**
-**                 "Authorization: basic username:password"
-**
-**              As usual, this string is automatically freed.
-*/
-extern char *HTAA_composeAuth PARAMS((
-	CONST char *	hostname,
-	CONST int	portnumber,
-	CONST char *	docname,
-	BOOL		IsProxy));
-
+ *//* PUBLIC                                               HTAA_composeAuth()
+   *
+   *      COMPOSE THE ENTIRE AUTHORIZATION HEADER LINE IF WE
+   *      ALREADY KNOW, THAT THE HOST MIGHT REQUIRE AUTHORIZATION
+   *
+   * ON ENTRY:
+   *      hostname        is the hostname of the server.
+   *      portnumber      is the portnumber in which the server runs.
+   *      docname         is the pathname of the document (as in URL)
+   *
+   * ON EXIT:
+   *      returns NULL, if no authorization seems to be needed, or
+   *              if it is the entire Authorization: line, e.g.
+   *
+   *                 "Authorization: basic username:password"
+   *
+   *              As usual, this string is automatically freed.
+ */ extern char *HTAA_composeAuth(const char *hostname,
+				  const int portnumber,
+				  const char *docname,
+				  BOOL IsProxy);
 
 /* BROWSER PUBLIC                               HTAA_shouldRetryWithAuth()
-**
-**              DETERMINES IF WE SHOULD RETRY THE SERVER
-**              WITH AUTHORIZATION
-**              (OR IF ALREADY RETRIED, WITH A DIFFERENT
-**              USERNAME AND/OR PASSWORD (IF MISSPELLED))
-** ON ENTRY:
-**      start_of_headers is the first block already read from socket,
-**                      but status line skipped; i.e., points to the
-**                      start of the header section.
-**      length          is the remaining length of the first block.
-**      soc             is the socket to read the rest of server reply.
-**
-**                      This function should only be called when
-**                      server has replied with a 401 (Unauthorized)
-**                      status code.
-** ON EXIT:
-**      returns         YES, if connection should be retried.
-**                           The node containing all the necessary
-**                           information is
-**                              * either constructed if it does not exist
-**                              * or password is reset to NULL to indicate
-**                                that username and password should be
-**                                reprompted when composing Authorization:
-**                                field (in function HTAA_composeAuth()).
-**                      NO, otherwise.
-*/
-extern BOOL HTAA_shouldRetryWithAuth PARAMS((
-	char *		start_of_headers,
-	int		length,
-	int		soc,
-	BOOL		IsProxy));
+ *
+ *              DETERMINES IF WE SHOULD RETRY THE SERVER
+ *              WITH AUTHORIZATION
+ *              (OR IF ALREADY RETRIED, WITH A DIFFERENT
+ *              USERNAME AND/OR PASSWORD (IF MISSPELLED))
+ * ON ENTRY:
+ *      start_of_headers is the first block already read from socket,
+ *                      but status line skipped; i.e., points to the
+ *                      start of the header section.
+ *      length          is the remaining length of the first block.
+ *      soc             is the socket to read the rest of server reply.
+ *
+ *                      This function should only be called when
+ *                      server has replied with a 401 (Unauthorized)
+ *                      status code.
+ * ON EXIT:
+ *      returns         YES, if connection should be retried.
+ *                           The node containing all the necessary
+ *                           information is
+ *                              * either constructed if it does not exist
+ *                              * or password is reset to NULL to indicate
+ *                                that username and password should be
+ *                                reprompted when composing Authorization:
+ *                                field (in function HTAA_composeAuth()).
+ *                      NO, otherwise.
+ */
+    extern BOOL HTAA_shouldRetryWithAuth(char *start_of_headers,
+					 int length,
+					 int soc,
+					 BOOL IsProxy);
 
 /*
-**  Function to allow clearing of all Authorization info
-**  via a browser command. - FM
-*/
-extern void HTClearHTTPAuthInfo NOPARAMS;
+ *  Function to allow clearing of all Authorization info
+ *  via a browser command. - FM
+ */
+    extern void HTClearHTTPAuthInfo(void);
 
 /*
 
@@ -126,9 +123,11 @@
 
  */
 
-extern void HTAAForwardAuth_set PARAMS((
-	CONST char *	scheme_name,
-	CONST char *	scheme_specifics));
-extern void HTAAForwardAuth_reset NOPARAMS;
-
-#endif  /* NOT HTAABROW_H */
+    extern void HTAAForwardAuth_set(const char *scheme_name,
+				    const char *scheme_specifics);
+    extern void HTAAForwardAuth_reset(void);
+
+#ifdef __cplusplus
+}
+#endif
+#endif				/* NOT HTAABROW_H */
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/HTAAUtil.h
+++ lynx-cur-2.8.6/WWW/Library/Implementation/HTAAUtil.h
@@ -32,38 +32,37 @@
 
 #include <HTList.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
 /*
-** Numeric constants
-*/
-#define MAX_USERNAME_LEN        16      /* @@ Longest allowed username    */
-#define MAX_PASSWORD_LEN        3*13    /* @@ Longest allowed password    */
-                                        /* (encrypted, so really only 3*8)*/
-#define MAX_METHODNAME_LEN      12      /* @@ Longest allowed method name */
-#define MAX_FIELDNAME_LEN       16      /* @@ Longest field name in       */
-                                        /* protection setup file          */
-#define MAX_PATHNAME_LEN        80      /* @@ Longest passwd/group file   */
-                                        /* pathname to allow               */
-
-/*
+ * Numeric constants
+ */
+#define MAX_USERNAME_LEN        16	/* @@ Longest allowed username    */
+#define MAX_PASSWORD_LEN        3*13	/* @@ Longest allowed password    */
+    /* (encrypted, so really only 3*8) */
+#define MAX_METHODNAME_LEN      12	/* @@ Longest allowed method name */
+#define MAX_FIELDNAME_LEN       16	/* @@ Longest field name in       */
+    /* protection setup file          */
+#define MAX_PATHNAME_LEN        80	/* @@ Longest passwd/group file   */
+/* pathname to allow               *//*
 
-Datatype definitions
+   Datatype definitions
 
-  HTAASCHEME
+   HTAASCHEME
 
    The enumeration HTAAScheme represents the possible authentication schemes used by the
    WWW Access Authorization.
 
- */
-
-typedef enum {
-    HTAA_UNKNOWN,
-    HTAA_NONE,
-    HTAA_BASIC,
-    HTAA_PUBKEY,
-    HTAA_KERBEROS_V4,
-    HTAA_KERBEROS_V5,
-    HTAA_MAX_SCHEMES /* THIS MUST ALWAYS BE LAST! Number of schemes */
-} HTAAScheme;
+ */ typedef enum {
+	HTAA_UNKNOWN,
+	HTAA_NONE,
+	HTAA_BASIC,
+	HTAA_PUBKEY,
+	HTAA_KERBEROS_V4,
+	HTAA_KERBEROS_V5,
+	HTAA_MAX_SCHEMES	/* THIS MUST ALWAYS BE LAST! Number of schemes */
+    } HTAAScheme;
 
 /*
 
@@ -71,11 +70,11 @@
 
  */
 
-typedef enum {
-    METHOD_UNKNOWN,
-    METHOD_GET,
-    METHOD_PUT
-} HTAAMethod;
+    typedef enum {
+	METHOD_UNKNOWN,
+	METHOD_GET,
+	METHOD_PUT
+    } HTAAMethod;
 
 /*
 
@@ -84,27 +83,26 @@
  */
 
 /* PUBLIC                                               HTAAScheme_enum()
-**              TRANSLATE SCHEME NAME TO A SCHEME ENUMERATION
-** ON ENTRY:
-**      name            is a string representing the scheme name.
-**
-** ON EXIT:
-**      returns         the enumerated constant for that scheme.
-*/
-PUBLIC HTAAScheme HTAAScheme_enum PARAMS((CONST char* name));
-
+ *              TRANSLATE SCHEME NAME TO A SCHEME ENUMERATION
+ * ON ENTRY:
+ *      name            is a string representing the scheme name.
+ *
+ * ON EXIT:
+ *      returns         the enumerated constant for that scheme.
+ */
+    extern HTAAScheme HTAAScheme_enum(const char *name);
 
 /* PUBLIC                                               HTAAScheme_name()
-**                      GET THE NAME OF A GIVEN SCHEME
-** ON ENTRY:
-**      scheme          is one of the scheme enum values:
-**                      HTAA_NONE, HTAA_BASIC, HTAA_PUBKEY, ...
-**
-** ON EXIT:
-**      returns         the name of the scheme, i.e.
-**                      "none", "basic", "pubkey", ...
-*/
-PUBLIC char *HTAAScheme_name PARAMS((HTAAScheme scheme));
+ *                      GET THE NAME OF A GIVEN SCHEME
+ * ON ENTRY:
+ *      scheme          is one of the scheme enum values:
+ *                      HTAA_NONE, HTAA_BASIC, HTAA_PUBKEY, ...
+ *
+ * ON EXIT:
+ *      returns         the name of the scheme, i.e.
+ *                      "none", "basic", "pubkey", ...
+ */
+    extern const char *HTAAScheme_name(HTAAScheme scheme);
 
 /*
 
@@ -113,42 +111,40 @@
  */
 
 /* PUBLIC                                                   HTAAMethod_enum()
-**              TRANSLATE METHOD NAME INTO AN ENUMERATED VALUE
-** ON ENTRY:
-**      name            is the method name to translate.
-**
-** ON EXIT:
-**      returns         HTAAMethod enumerated value corresponding
-**                      to the given name.
-*/
-PUBLIC HTAAMethod HTAAMethod_enum PARAMS((CONST char * name));
-
+ *              TRANSLATE METHOD NAME INTO AN ENUMERATED VALUE
+ * ON ENTRY:
+ *      name            is the method name to translate.
+ *
+ * ON EXIT:
+ *      returns         HTAAMethod enumerated value corresponding
+ *                      to the given name.
+ */
+    extern HTAAMethod HTAAMethod_enum(const char *name);
 
 /* PUBLIC                                               HTAAMethod_name()
-**                      GET THE NAME OF A GIVEN METHOD
-** ON ENTRY:
-**      method          is one of the method enum values:
-**                      METHOD_GET, METHOD_PUT, ...
-**
-** ON EXIT:
-**      returns         the name of the scheme, i.e.
-**                      "GET", "PUT", ...
-*/
-PUBLIC char *HTAAMethod_name PARAMS((HTAAMethod method));
-
+ *                      GET THE NAME OF A GIVEN METHOD
+ * ON ENTRY:
+ *      method          is one of the method enum values:
+ *                      METHOD_GET, METHOD_PUT, ...
+ *
+ * ON EXIT:
+ *      returns         the name of the scheme, i.e.
+ *                      "GET", "PUT", ...
+ */
+    extern const char *HTAAMethod_name(HTAAMethod method);
 
 /* PUBLIC                                               HTAAMethod_inList()
-**              IS A METHOD IN A LIST OF METHOD NAMES
-** ON ENTRY:
-**      method          is the method to look for.
-**      list            is a list of method names.
-**
-** ON EXIT:
-**      returns         YES, if method was found.
-**                      NO, if not found.
-*/
-PUBLIC BOOL HTAAMethod_inList PARAMS((HTAAMethod        method,
-                                     HTList *           list));
+ *              IS A METHOD IN A LIST OF METHOD NAMES
+ * ON ENTRY:
+ *      method          is the method to look for.
+ *      list            is a list of method names.
+ *
+ * ON EXIT:
+ *      returns         YES, if method was found.
+ *                      NO, if not found.
+ */
+    extern BOOL HTAAMethod_inList(HTAAMethod method, HTList *list);
+
 /*
 
 Match Template Against Filename
@@ -156,111 +152,109 @@
  */
 
 /* PUBLIC                                               HTAA_templateMatch()
-**              STRING COMPARISON FUNCTION FOR FILE NAMES
-**                 WITH ONE WILDCARD * IN THE TEMPLATE
-** NOTE:
-**      This is essentially the same code as in HTRules.c, but it
-**      cannot be used because it is embedded in between other code.
-**      (In fact, HTRules.c should use this routine, but then this
-**       routine would have to be more sophisticated... why is life
-**       sometimes so hard...)
-**
-** ON ENTRY:
-**      template        is a template string to match the file name
-**                      against, may contain a single wildcard
-**                      character * which matches zero or more
-**                      arbitrary characters.
-**      filename        is the filename (or pathname) to be matched
-**                      against the template.
-**
-** ON EXIT:
-**      returns         YES, if filename matches the template.
-**                      NO, otherwise.
-*/
-PUBLIC BOOL HTAA_templateMatch PARAMS((CONST char * template,
-                                       CONST char * filename));
-
+ *              STRING COMPARISON FUNCTION FOR FILE NAMES
+ *                 WITH ONE WILDCARD * IN THE TEMPLATE
+ * NOTE:
+ *      This is essentially the same code as in HTRules.c, but it
+ *      cannot be used because it is embedded in between other code.
+ *      (In fact, HTRules.c should use this routine, but then this
+ *       routine would have to be more sophisticated... why is life
+ *       sometimes so hard...)
+ *
+ * ON ENTRY:
+ *      ctemplate       is a template string to match the file name
+ *                      against, may contain a single wildcard
+ *                      character * which matches zero or more
+ *                      arbitrary characters.
+ *      filename        is the filename (or pathname) to be matched
+ *                      against the template.
+ *
+ * ON EXIT:
+ *      returns         YES, if filename matches the template.
+ *                      NO, otherwise.
+ */
+    extern BOOL HTAA_templateMatch(const char *ctemplate,
+				   const char *filename);
 
 /* PUBLIC                                               HTAA_templateCaseMatch()
-**              STRING COMPARISON FUNCTION FOR FILE NAMES
-**                 WITH ONE WILDCARD * IN THE TEMPLATE (Case Insensitive)
-** NOTE:
-**      This is essentially the same code as in HTAA_templateMatch, but
-**      it compares case insensitive (for VMS). Reason for this routine
-**      is that HTAA_templateMatch gets called from several places, also
-**      there where a case sensitive match is needed, so one cannot just
-**      change the HTAA_templateMatch routine for VMS.
-**
-** ON ENTRY:
-**      template        is a template string to match the file name
-**                      against, may contain a single wildcard
-**                      character * which matches zero or more
-**                      arbitrary characters.
-**      filename        is the filename (or pathname) to be matched
-**                      against the template.
-**
-** ON EXIT:
-**      returns         YES, if filename matches the template.
-**                      NO, otherwise.
-*/
-PUBLIC BOOL HTAA_templateCaseMatch PARAMS((CONST char * template,
-                                         CONST char * filename));
-
+ *              STRING COMPARISON FUNCTION FOR FILE NAMES
+ *                 WITH ONE WILDCARD * IN THE TEMPLATE (Case Insensitive)
+ * NOTE:
+ *      This is essentially the same code as in HTAA_templateMatch, but
+ *      it compares case insensitive (for VMS). Reason for this routine
+ *      is that HTAA_templateMatch gets called from several places, also
+ *      there where a case sensitive match is needed, so one cannot just
+ *      change the HTAA_templateMatch routine for VMS.
+ *
+ * ON ENTRY:
+ *      ctemplate       is a template string to match the file name
+ *                      against, may contain a single wildcard
+ *                      character * which matches zero or more
+ *                      arbitrary characters.
+ *      filename        is the filename (or pathname) to be matched
+ *                      against the template.
+ *
+ * ON EXIT:
+ *      returns         YES, if filename matches the template.
+ *                      NO, otherwise.
+ */
+    extern BOOL HTAA_templateCaseMatch(const char *ctemplate,
+				       const char *filename);
 
 /* PUBLIC                                       HTAA_makeProtectionTemplate()
-**              CREATE A PROTECTION TEMPLATE FOR THE FILES
-**              IN THE SAME DIRECTORY AS THE GIVEN FILE
-**              (Used by server if there is no fancier way for
-**              it to tell the client, and by browser if server
-**              didn't send WWW-ProtectionTemplate: field)
-** ON ENTRY:
-**      docname is the document pathname (from URL).
-**
-** ON EXIT:
-**      returns a template matching docname, and other files
-**              files in that directory.
-**
-**              E.g.  /foo/bar/x.html  =>  /foo/bar/ *
-**                                                  ^
-**                              Space only to prevent it from
-**                              being a comment marker here,
-**                              there really isn't any space.
-*/
-PUBLIC char *HTAA_makeProtectionTemplate PARAMS((CONST char * docname));
+ *              CREATE A PROTECTION TEMPLATE FOR THE FILES
+ *              IN THE SAME DIRECTORY AS THE GIVEN FILE
+ *              (Used by server if there is no fancier way for
+ *              it to tell the client, and by browser if server
+ *              didn't send WWW-ProtectionTemplate: field)
+ * ON ENTRY:
+ *      docname is the document pathname (from URL).
+ *
+ * ON EXIT:
+ *      returns a template matching docname, and other files
+ *              files in that directory.
+ *
+ *              E.g.  /foo/bar/x.html  =>  /foo/bar/ *
+ *                                                  ^
+ *                              Space only to prevent it from
+ *                              being a comment marker here,
+ *                              there really isn't any space.
+ */
+    extern char *HTAA_makeProtectionTemplate(const char *docname);
+
 /*
 
 MIME Argument List Parser
 
  */
 
-
 /* PUBLIC                                               HTAA_parseArgList()
-**              PARSE AN ARGUMENT LIST GIVEN IN A HEADER FIELD
-** ON ENTRY:
-**      str     is a comma-separated list:
-**
-**                      item, item, item
-**              where
-**                      item ::= value
-**                             | name=value
-**                             | name="value"
-**
-**              Leading and trailing whitespace is ignored
-**              everywhere except inside quotes, so the following
-**              examples are equal:
-**
-**                      name=value,foo=bar
-**                       name="value",foo="bar"
-**                        name = value ,  foo = bar
-**                         name = "value" ,  foo = "bar"
-**
-** ON EXIT:
-**      returns a list of name-value pairs (actually HTAssocList*).
-**              For items with no name, just value, the name is
-**              the number of order number of that item. E.g.
-**              "1" for the first, etc.
-*/
-PUBLIC HTList *HTAA_parseArgList PARAMS((char * str));
+ *              PARSE AN ARGUMENT LIST GIVEN IN A HEADER FIELD
+ * ON ENTRY:
+ *      str     is a comma-separated list:
+ *
+ *                      item, item, item
+ *              where
+ *                      item ::= value
+ *                             | name=value
+ *                             | name="value"
+ *
+ *              Leading and trailing whitespace is ignored
+ *              everywhere except inside quotes, so the following
+ *              examples are equal:
+ *
+ *                      name=value,foo=bar
+ *                       name="value",foo="bar"
+ *                        name = value ,  foo = bar
+ *                         name = "value" ,  foo = "bar"
+ *
+ * ON EXIT:
+ *      returns a list of name-value pairs (actually HTAssocList*).
+ *              For items with no name, just value, the name is
+ *              the number of order number of that item. E.g.
+ *              "1" for the first, etc.
+ */
+    extern HTList *HTAA_parseArgList(char *str);
 
 /*
 
@@ -269,50 +263,52 @@
  */
 
 /* PUBLIC                                               HTAA_setupReader()
-**              SET UP HEADER LINE READER, i.e., give
-**              the already-read-but-not-yet-processed
-**              buffer of text to be read before more
-**              is read from the socket.
-** ON ENTRY:
-**      start_of_headers is a pointer to a buffer containing
-**                      the beginning of the header lines
-**                      (rest will be read from a socket).
-**      length          is the number of valid characters in
-**                      'start_of_headers' buffer.
-**      soc             is the socket to use when start_of_headers
-**                      buffer is used up.
-** ON EXIT:
-**      returns         nothing.
-**                      Subsequent calls to HTAA_getUnfoldedLine()
-**                      will use this buffer first and then
-**                      proceed to read from socket.
-*/
-PUBLIC void HTAA_setupReader PARAMS((char *     start_of_headers,
-                                     int        length,
-                                     int        soc));
-
+ *              SET UP HEADER LINE READER, i.e., give
+ *              the already-read-but-not-yet-processed
+ *              buffer of text to be read before more
+ *              is read from the socket.
+ * ON ENTRY:
+ *      start_of_headers is a pointer to a buffer containing
+ *                      the beginning of the header lines
+ *                      (rest will be read from a socket).
+ *      length          is the number of valid characters in
+ *                      'start_of_headers' buffer.
+ *      soc             is the socket to use when start_of_headers
+ *                      buffer is used up.
+ * ON EXIT:
+ *      returns         nothing.
+ *                      Subsequent calls to HTAA_getUnfoldedLine()
+ *                      will use this buffer first and then
+ *                      proceed to read from socket.
+ */
+    extern void HTAA_setupReader(char *start_of_headers,
+				 int length,
+				 int soc);
 
 /* PUBLIC                                               HTAA_getUnfoldedLine()
-**              READ AN UNFOLDED HEADER LINE FROM SOCKET
-** ON ENTRY:
-**      HTAA_setupReader must absolutely be called before
-**      this function to set up internal buffer.
-**
-** ON EXIT:
-**      returns a newly-allocated character string representing
-**              the read line.  The line is unfolded, i.e.
-**              lines that begin with whitespace are appended
-**              to current line.  E.g.
-**
-**                      Field-Name: Blaa-Blaa
-**                       This-Is-A-Continuation-Line
-**                       Here-Is_Another
-**
-**              is seen by the caller as:
-**
-**      Field-Name: Blaa-Blaa This-Is-A-Continuation-Line Here-Is_Another
-**
-*/
-PUBLIC char *HTAA_getUnfoldedLine NOPARAMS;
+ *              READ AN UNFOLDED HEADER LINE FROM SOCKET
+ * ON ENTRY:
+ *      HTAA_setupReader must absolutely be called before
+ *      this function to set up internal buffer.
+ *
+ * ON EXIT:
+ *      returns a newly-allocated character string representing
+ *              the read line.  The line is unfolded, i.e.
+ *              lines that begin with whitespace are appended
+ *              to current line.  E.g.
+ *
+ *                      Field-Name: Blaa-Blaa
+ *                       This-Is-A-Continuation-Line
+ *                       Here-Is_Another
+ *
+ *              is seen by the caller as:
+ *
+ *      Field-Name: Blaa-Blaa This-Is-A-Continuation-Line Here-Is_Another
+ *
+ */
+    extern char *HTAA_getUnfoldedLine(void);
 
-#endif  /* NOT HTAAUTIL_H */
+#ifdef __cplusplus
+}
+#endif
+#endif				/* NOT HTAAUTIL_H */
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/HTWSRC.h
+++ lynx-cur-2.8.6/WWW/Library/Implementation/HTWSRC.h
@@ -1,11 +1,11 @@
 /*                                                             A parser for WAIS source files
                                  WAIS SOURCE FILE PARSER
 
-   This converter returns a stream object into which a WAIS source file can be written.
-   The result is put via a structured stream into whatever format was required for the
-   output stream.
+   This converter returns a stream object into which a WAIS source file can be
+   written.  The result is put via a structured stream into whatever format was
+   required for the output stream.
 
-   See also: HTWAIS protocol interface module
+   See also:  HTWAIS protocol interface module
 
  */
 #ifndef HTWSRC_H
@@ -13,26 +13,31 @@
 
 #include <HTFormat.h>
 
-extern  char from_hex PARAMS((char c));
-
-extern  HTStream* HTWSRCConvert PARAMS((
-        HTPresentation *        pres,
-        HTParentAnchor *        anchor,
-        HTStream *              sink));
+#ifdef __cplusplus
+extern "C" {
+#endif
+    extern char from_hex(char c);
+
+    extern HTStream *HTWSRCConvert(HTPresentation *pres,
+				   HTParentAnchor *anchor,
+				   HTStream *sink);
 
 /*
 
 Escaping Strings
 
-   HTDeSlash takes out the invlaid characters in a URL path ELEMENT by converting them
-   into hex-escaped characters.  HTEnSlash does the reverse.
+   HTDeSlash takes out the invlaid characters in a URL path ELEMENT by
+   converting them into hex-escaped characters.  HTEnSlash does the reverse.
 
-   Each returns a pointer to a newly allocated string which must eventually be freed by
-   the caller.
+   Each returns a pointer to a newly allocated string which must eventually be
+   freed by the caller.
 
  */
-extern char * HTDeSlash PARAMS((CONST char * str));
+    extern char *HTDeSlash(const char *str);
 
-extern char * HTEnSlash PARAMS((CONST char * str));
+    extern char *HTEnSlash(const char *str);
 
-#endif /* HTWSRC_H */
+#ifdef __cplusplus
+}
+#endif
+#endif				/* HTWSRC_H */
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/HTWAIS.h
+++ lynx-cur-2.8.6/WWW/Library/Implementation/HTWAIS.h
@@ -27,10 +27,17 @@
 
 #include <HTAccess.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
 #ifdef GLOBALREF_IS_MACRO
-extern GLOBALREF(HTProtocol, HTWAIS);
+    extern GLOBALREF (HTProtocol, HTWAIS);
+
 #else
-GLOBALREF HTProtocol HTWAIS;
-#endif /* GLOBALDEF_IS_MACRO */
+    GLOBALREF HTProtocol HTWAIS;
+#endif				/* GLOBALDEF_IS_MACRO */
 
-#endif /* HTWAIS_H */
+#ifdef __cplusplus
+}
+#endif
+#endif				/* HTWAIS_H */
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/HTTelnet.h
+++ lynx-cur-2.8.6/WWW/Library/Implementation/HTTelnet.h
@@ -8,14 +8,21 @@
 
 #include <HTAccess.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
 #ifdef GLOBALREF_IS_MACRO
-extern GLOBALREF(HTProtocol,HTTelnet);
-extern GLOBALREF(HTProtocol,HTRlogin);
-extern GLOBALREF(HTProtocol,HTTn3270);
+    extern GLOBALREF (HTProtocol, HTTelnet);
+    extern GLOBALREF (HTProtocol, HTRlogin);
+    extern GLOBALREF (HTProtocol, HTTn3270);
+
 #else
-GLOBALREF HTProtocol HTTelnet;
-GLOBALREF HTProtocol HTRlogin;
-GLOBALREF HTProtocol HTTn3270;
-#endif /* GLOBALREF_IS_MACRO */
+    GLOBALREF HTProtocol HTTelnet;
+    GLOBALREF HTProtocol HTRlogin;
+    GLOBALREF HTProtocol HTTn3270;
+#endif				/* GLOBALREF_IS_MACRO */
 
-#endif /* HTTELNET_H */
+#ifdef __cplusplus
+}
+#endif
+#endif				/* HTTELNET_H */
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/HText.h
+++ lynx-cur-2.8.6/WWW/Library/Implementation/HText.h
@@ -5,29 +5,36 @@
 
 /*
 
-   This is the C interface to the Objective-C (or whatever) Style-oriented HyperText
-   class.  It is used when a style-oriented text object is available or craeted in order to
-   display hypertext.
+   This is the C interface to the Objective-C (or whatever) Style-oriented
+   HyperText class.  It is used when a style-oriented text object is available
+   or craeted in order to display hypertext.
 
  */
 #ifndef HTEXT_H
 #define HTEXT_H
+
 #include <HTAnchor.h>
 #include <HTStyle.h>
 #include <HTStream.h>
 #include <SGML.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
 #ifndef THINK_C
-#ifndef HyperText               /* Objective C version defined HyperText */
-typedef struct _HText HText;    /* Normal Library */
+#ifndef HyperText		/* Objective C version defined HyperText */
+    typedef struct _HText HText;	/* Normal Library */
 #endif
 #else
-class CHyperText;               /* Mac Think-C browser hook */
-typedef CHyperText HText;
+    class CHyperText;		/* Mac Think-C browser hook */
+    typedef CHyperText HText;
 #endif
 
-extern HText * HTMainText;              /* Pointer to current main text */
-extern HTParentAnchor * HTMainAnchor;   /* Pointer to current text's anchor */
+    extern HText *HTMainText;	/* Pointer to current main text */
+    extern HTParentAnchor *HTMainAnchor;	/* Pointer to current text's anchor */
+
+    extern const char *HTAppName;	/* Application name */
+    extern const char *HTAppVersion;	/* Application version */
 
 /*
 
@@ -35,40 +42,41 @@
 
   HTEXT_NEW: CREATE HYPERTEXT OBJECT
 
-   There are several methods depending on how much you want to specify.  The output stream
-   is used with objects which need to output the hypertext to a stream.  The structure is
-   for objects which need to refer to the structure which is kep by the creating stream.
+   There are several methods depending on how much you want to specify.  The
+   output stream is used with objects which need to output the hypertext to a
+   stream.  The structure is for objects which need to refer to the structure
+   which is kep by the creating stream.
 
  */
- extern HText * HText_new PARAMS((HTParentAnchor * anchor));
+    extern HText *HText_new(HTParentAnchor *anchor);
 
- extern HText * HText_new2 PARAMS((HTParentAnchor * anchor,
-                                HTStream * output_stream));
+    extern HText *HText_new2(HTParentAnchor *anchor,
+			     HTStream *output_stream);
 
- extern HText * HText_new3 PARAMS((HTParentAnchor * anchor,
-                                HTStream * output_stream,
-                                HTStructured * structure));
+    extern HText *HText_new3(HTParentAnchor *anchor,
+			     HTStream *output_stream,
+			     HTStructured * structure);
 
 /*
 
   FREE HYPERTEXT OBJECT
 
  */
-extern void     HText_free PARAMS((HText * me));
-
+    extern void HText_free(HText *me);
 
 /*
 
 Object Building methods
 
-   These are used by a parser to build the text in an object HText_beginAppend must be
-   called, then any combination of other append calls, then HText_endAppend. This allows
-   optimised handling using buffers and caches which are flushed at the end.
+   These are used by a parser to build the text in an object HText_beginAppend
+   must be called, then any combination of other append calls, then
+   HText_endAppend.  This allows optimised handling using buffers and caches
+   which are flushed at the end.
 
  */
-extern void HText_beginAppend PARAMS((HText * text));
+    extern void HText_beginAppend(HText *text);
 
-extern void HText_endAppend PARAMS((HText * text));
+    extern void HText_endAppend(HText *text);
 
 /*
 
@@ -76,14 +84,14 @@
 
  */
 
-extern void HText_setStyle PARAMS((HText * text, HTStyle * style));
+    extern void HText_setStyle(HText *text, HTStyle *style);
 
 /*
 
   ADD ONE CHARACTER
 
  */
-extern void HText_appendCharacter PARAMS((HText * text, int ch));
+    extern void HText_appendCharacter(HText *text, int ch);
 
 /*
 
@@ -91,7 +99,7 @@
 
  */
 
-extern void HText_appendText PARAMS((HText * text, CONST char * str));
+    extern void HText_appendText(HText *text, const char *str);
 
 /*
 
@@ -100,13 +108,11 @@
    and similar things
 
  */
-extern void HText_appendParagraph PARAMS((HText * text));
-
-extern void HText_appendLineBreak PARAMS((HText * text));
-
-extern void HText_appendHorizontalRule PARAMS((HText * text));
+    extern void HText_appendParagraph(HText *text);
 
+    extern void HText_appendLineBreak(HText *text);
 
+    extern void HText_appendHorizontalRule(HText *text);
 
 /*
 
@@ -116,44 +122,40 @@
 
 /*
 
-   The anchor object is created and passed to HText_beginAnchor.  The senstive text is
-   added to the text object, and then HText_endAnchor is called. Anchors may not be
-   nested.
+   The anchor object is created and passed to HText_beginAnchor.  The senstive
+   text is added to the text object, and then HText_endAnchor is called. 
+   Anchors may not be nested.
 
  */
-extern int HText_beginAnchor PARAMS((
-	HText *		text,
-	BOOL		underline,
-	HTChildAnchor *	anc));
-extern void HText_endAnchor PARAMS((HText * text, int number));
-extern BOOL HText_isAnchorBlank PARAMS((HText * text, int number));
+    extern int HText_beginAnchor(HText *text, BOOL underline,
+				 HTChildAnchor *anc);
+    extern void HText_endAnchor(HText *text, int number);
+    extern BOOL HText_isAnchorBlank(HText *text, int number);
 
 /*
 
   APPEND AN INLINE IMAGE
 
-   The image is handled by the creation of an anchor whose destination is the image
-   document to be included. The semantics is the intended inline display of the image.
-
-   An alternative implementation could be, for example, to begin an anchor, append the
-   alternative text or "IMAGE", then end the anchor.  This would simply generate some text
-   linked to the image itself as a separate document.
+   The image is handled by the creation of an anchor whose destination is the
+   image document to be included.  The semantics is the intended inline display
+   of the image.
+
+   An alternative implementation could be, for example, to begin an anchor,
+   append the alternative text or "IMAGE", then end the anchor.  This would
+   simply generate some text linked to the image itself as a separate document.
 
  */
-extern void HText_appendImage PARAMS((
-        HText *         text,
-        HTChildAnchor * anc,
-        CONST char *    alternative_text,
-        int             alignment,
-        BOOL            isMap));
+    extern void HText_appendImage(HText *text, HTChildAnchor *anc,
+				  const char *alternative_text,
+				  int alignment,
+				  BOOL isMap);
 
 /*
 
   RETURN THE ANCHOR ASSOCIATED WITH THIS NODE
 
  */
-extern HTParentAnchor * HText_nodeAnchor PARAMS((HText * me));
-
+    extern HTParentAnchor *HText_nodeAnchor(HText *me);
 
 /*
 
@@ -161,63 +163,60 @@
 
  */
 
-
 /*
 
   BRING TO FRONT AND HIGHLIGHT IT
 
  */
 
-
-extern BOOL HText_select PARAMS((HText * text));
-extern BOOL HText_selectAnchor PARAMS((HText * text, HTChildAnchor* anchor));
+    extern BOOL HText_select(HText *text);
+    extern BOOL HText_selectAnchor(HText *text, HTChildAnchor *anchor);
 
 /*
 
 Editing functions
 
-   These are called from the application.  There are many more functions not included here
-   from the orginal text object.  These functions NEED NOT BE IMPLEMENTED in a browser
-   which cannot edit.
+   These are called from the application.  There are many more functions not
+   included here from the orginal text object.  These functions NEED NOT BE
+   IMPLEMENTED in a browser which cannot edit.
 
  */
 /*      Style handling:
 */
 /*      Apply this style to the selection
 */
-extern void HText_applyStyle PARAMS((HText * me, HTStyle *style));
+    extern void HText_applyStyle(HText *me, HTStyle *style);
 
 /*      Update all text with changed style.
 */
-extern void HText_updateStyle PARAMS((HText * me, HTStyle *style));
+    extern void HText_updateStyle(HText *me, HTStyle *style);
 
 /*      Return style of  selection
 */
-extern HTStyle * HText_selectionStyle PARAMS((
-        HText * me,
-        HTStyleSheet* sheet));
+    extern HTStyle *HText_selectionStyle(HText *me, HTStyleSheet *sheet);
 
 /*      Paste in styled text
 */
-extern void HText_replaceSel PARAMS((HText * me,
-        CONST char *aString,
-        HTStyle* aStyle));
+    extern void HText_replaceSel(HText *me, const char *aString,
+				 HTStyle *aStyle);
 
 /*      Apply this style to the selection and all similarly formatted text
-**      (style recovery only)
-*/
-extern void HTextApplyToSimilar PARAMS((HText * me, HTStyle *style));
+ *      (style recovery only)
+ */
+    extern void HTextApplyToSimilar(HText *me, HTStyle *style);
 
 /*      Select the first unstyled run.
-**      (style recovery only)
-*/
-extern void HTextSelectUnstyled PARAMS((HText * me, HTStyleSheet *sheet));
-
+ *      (style recovery only)
+ */
+    extern void HTextSelectUnstyled(HText *me, HTStyleSheet *sheet);
 
 /*      Anchor handling:
 */
-extern void             HText_unlinkSelection PARAMS((HText * me));
-extern HTAnchor *       HText_referenceSelected PARAMS((HText * me));
-extern HTAnchor *       HText_linkSelTo PARAMS((HText * me, HTAnchor* anchor));
+    extern void HText_unlinkSelection(HText *me);
+    extern HTAnchor *HText_referenceSelected(HText *me);
+    extern HTAnchor *HText_linkSelTo(HText *me, HTAnchor * anchor);
 
-#endif /* HTEXT_H */
+#ifdef __cplusplus
+}
+#endif
+#endif				/* HTEXT_H */
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/HTUtils.h
+++ lynx-cur-2.8.6/WWW/Library/Implementation/HTUtils.h
@@ -6,14 +6,14 @@
  */
 
 #ifndef NO_LYNX_TRACE
-#define DEBUG   /* Turns on trace; turn off for smaller binary */
+#define DEBUG			/* Turns on trace; turn off for smaller binary */
 #endif
 
 #ifndef HTUTILS_H
 #define HTUTILS_H
 
 #ifdef HAVE_CONFIG_H
-#include <lynx_cfg.h>	/* generated by autoconf 'configure' script */
+#include <lynx_cfg.h>		/* generated by autoconf 'configure' script */
 
 /* see AC_FUNC_ALLOCA macro */
 #ifdef __GNUC__
@@ -27,10 +27,11 @@
 #   include <alloca.h>
 #  else
 #   ifdef _AIX
- #pragma alloca
+#pragma alloca
 #   else
-#    ifndef alloca /* predefined by HP cc +Olibcalls */
-char *alloca ();
+#    ifndef alloca		/* predefined by HP cc +Olibcalls */
+char *alloca();
+
 #    endif
 #   endif
 #  endif
@@ -40,10 +41,10 @@
 #include <sys/types.h>
 #include <stdio.h>
 
-#else  /* HAVE_CONFIG_H */
+#else /* HAVE_CONFIG_H */
 
 #ifdef DJGPP
-#include <sys/config.h>	/* pseudo-autoconf values for DJGPP libc/headers */
+#include <sys/config.h>		/* pseudo-autoconf values for DJGPP libc/headers */
 #define HAVE_TRUNCATE 1
 #define HAVE_ALLOCA 1
 #include <limits.h>
@@ -57,20 +58,19 @@
 #ifdef VMS
 #define NO_SIZECHANGE
 #if defined(VAXC) && !defined(__DECC)
-#define NO_UNISTD_H	/* DEC C has unistd.h, but not VAX C */
+#define NO_UNISTD_H		/* DEC C has unistd.h, but not VAX C */
 #endif
 #define NO_KEYPAD
 #define NO_UTMP
 #define NO_FILIO_H
 #define NOUSERS
-#define DISP_PARTIAL	/* experimental */
+#define DISP_PARTIAL		/* experimental */
 #endif
 
-#if defined(__STDC__) || defined(VMS) || defined(_WINDOWS)
+/* since 2.8.6dev.1, Lynx requires an ANSI C (c89) compiler */
 #define ANSI_VARARGS 1
 #undef HAVE_STDARG_H
 #define HAVE_STDARG_H 1
-#endif
 
 #if defined(VMS) || defined(_WINDOWS)
 #define HAVE_STDLIB_H 1
@@ -147,16 +147,11 @@
 #endif
 
 #ifndef	GCC_NORETURN
-#define	GCC_NORETURN /* nothing */
+#define	GCC_NORETURN		/* nothing */
 #endif
 
 #ifndef	GCC_UNUSED
-#define	GCC_UNUSED /* nothing */
-#endif
-
-/* FIXME: need a configure-test */
-#if defined(__STDC__) || defined(__DECC) || defined(_WINDOWS) || _WIN_CC
-#define ANSI_PREPRO 1
+#define	GCC_UNUSED		/* nothing */
 #endif
 
 #if defined(__CYGWIN32__) && ! defined(__CYGWIN__)
@@ -183,6 +178,7 @@
 #endif
 #undef sleep			/* 1998/06/23 (Tue) 16:54:53 */
 extern void sleep(unsigned __seconds);
+
 #define popen _popen
 #define pclose _pclose
 
@@ -192,6 +188,11 @@
 
 #endif /* _WINDOWS */
 
+#if defined(USE_DEFAULT_COLORS) && !defined(HAVE_USE_DEFAULT_COLORS)
+    /* if we don't have use_default_colors() */
+#  undef USE_DEFAULT_COLORS
+#endif
+
 #ifndef USE_COLOR_STYLE
     /* it's useless for such setup */
 #  define NO_EMPTY_HREFLESS_A
@@ -226,7 +227,7 @@
    placeholder for something more sophisticated.
 
  */
-typedef void * HTError;                 /* Unused at present -- best definition? */
+typedef void *HTError;		/* Unused at present -- best definition? */
 
 /*
 
@@ -246,14 +247,14 @@
 #endif
 
 #ifdef __EMX__
-#include <unistd.h> /* should be re-include protected under EMX */
+#include <unistd.h>		/* should be re-include protected under EMX */
 #define getcwd _getcwd2
 #define chdir _chdir2
 #endif
 
 #ifdef vax
 #ifdef unix
-#define ultrix  /* Assume vax+unix=ultrix */
+#define ultrix			/* Assume vax+unix=ultrix */
 #endif /* unix */
 #endif /* vax */
 
@@ -261,7 +262,7 @@
 #ifndef ultrix
 
 #ifdef NeXT
-#include <libc.h>       /* NeXT */
+#include <libc.h>		/* NeXT */
 #endif /* NeXT */
 
 #else /* ultrix: */
@@ -270,7 +271,7 @@
 #include <memory.h>
 
 #endif /* !ultrix */
-#else   /* VMS: */
+#else /* VMS: */
 
 #include <unixlib.h>
 #if defined(VAXC) && !defined(__DECC)
@@ -283,72 +284,6 @@
 
 #endif /* !VMS */
 
-/*
-
-Macros for declarations
-
- */
-#define PUBLIC                  /* Accessible outside this module     */
-#define PRIVATE static          /* Accessible only within this module */
-
-#if defined(__STDC__) || defined(__BORLANDC__) || defined(_MSC_VER)
-#define CONST const             /* "const" only exists in STDC */
-#define NOPARAMS (void)
-#define PARAMS(parameter_list) parameter_list
-#define NOARGS (void)
-#define ARGS1(t,a) \
-                (t a)
-#define ARGS2(t,a,u,b) \
-                (t a, u b)
-#define ARGS3(t,a,u,b,v,c) \
-                (t a, u b, v c)
-#define ARGS4(t,a,u,b,v,c,w,d) \
-                (t a, u b, v c, w d)
-#define ARGS5(t,a,u,b,v,c,w,d,x,e) \
-                (t a, u b, v c, w d, x e)
-#define ARGS6(t,a,u,b,v,c,w,d,x,e,y,f) \
-                (t a, u b, v c, w d, x e, y f)
-#define ARGS7(t,a,u,b,v,c,w,d,x,e,y,f,z,g) \
-                (t a, u b, v c, w d, x e, y f, z g)
-#define ARGS8(t,a,u,b,v,c,w,d,x,e,y,f,z,g,s,h) \
-                (t a, u b, v c, w d, x e, y f, z g, s h)
-#define ARGS9(t,a,u,b,v,c,w,d,x,e,y,f,z,g,s,h,r,i) \
-                (t a, u b, v c, w d, x e, y f, z g, s h, r i)
-#define ARGS10(t,a,u,b,v,c,w,d,x,e,y,f,z,g,s,h,r,i,q,j) \
-                (t a, u b, v c, w d, x e, y f, z g, s h, r i, q j)
-
-#else  /* not ANSI */
-
-#ifndef _WINDOWS
-#define CONST
-#endif
-#define NOPARAMS ()
-#define PARAMS(parameter_list) ()
-#define NOARGS ()
-#define ARGS1(t,a) (a) \
-                t a;
-#define ARGS2(t,a,u,b) (a,b) \
-                t a; u b;
-#define ARGS3(t,a,u,b,v,c) (a,b,c) \
-                t a; u b; v c;
-#define ARGS4(t,a,u,b,v,c,w,d) (a,b,c,d) \
-                t a; u b; v c; w d;
-#define ARGS5(t,a,u,b,v,c,w,d,x,e) (a,b,c,d,e) \
-                t a; u b; v c; w d; x e;
-#define ARGS6(t,a,u,b,v,c,w,d,x,e,y,f) (a,b,c,d,e,f) \
-                t a; u b; v c; w d; x e; y f;
-#define ARGS7(t,a,u,b,v,c,w,d,x,e,y,f,z,g) (a,b,c,d,e,f,g) \
-                t a; u b; v c; w d; x e; y f; z g;
-#define ARGS8(t,a,u,b,v,c,w,d,x,e,y,f,z,g,s,h) (a,b,c,d,e,f,g,h) \
-                t a; u b; v c; w d; x e; y f; z g; s h;
-#define ARGS9(t,a,u,b,v,c,w,d,x,e,y,f,z,g,s,h,r,i) (a,b,c,d,e,f,g,h,i) \
-                t a; u b; v c; w d; x e; y f; z g; s h; r i;
-#define ARGS10(t,a,u,b,v,c,w,d,x,e,y,f,z,g,s,h,r,i,q,j) (a,b,c,d,e,f,g,h,i,j) \
-                t a; u b; v c; w d; x e; y f; z g; s h; r i; q j;
-
-
-#endif /* __STDC__ (ANSI) */
-
 #ifndef NULL
 #define NULL ((void *)0)
 #endif
@@ -364,8 +299,10 @@
 #define	typecalloc(cast)		(cast *)calloc(1,sizeof(cast))
 #define	typecallocn(cast,ntypes)	(cast *)calloc(ntypes,sizeof(cast))
 
+#define typeRealloc(cast,ptr,ntypes)    (cast *)realloc(ptr, (ntypes)*sizeof(cast))
+
 #define typeMalloc(cast)                (cast *)malloc(sizeof(cast))
-#define typeMallocn(cast,ntypes)        (cast *)malloc(ntypes*sizeof(cast))
+#define typeMallocn(cast,ntypes)        (cast *)malloc((ntypes)*sizeof(cast))
 
 /*
 
@@ -389,16 +326,17 @@
 
 #ifndef _WINDOWS
 #ifndef BOOLEAN_DEFINED
-    typedef char    BOOLEAN;	/* Logical value */
+typedef char BOOLEAN;		/* Logical value */
+
 #ifndef CURSES
 #ifndef TRUE
 #define TRUE    (BOOLEAN)1
 #define FALSE   (BOOLEAN)0
 #endif
-#endif   /*  CURSES  */
-#endif	 /*  BOOLEAN_DEFINED */
+#endif /*  CURSES  */
+#endif /*  BOOLEAN_DEFINED */
 #define BOOLEAN_DEFINED
-#endif   /* _WINDOWS */
+#endif /* _WINDOWS */
 
 #ifndef BOOL
 #define BOOL BOOLEAN
@@ -411,10 +349,10 @@
 
 extern BOOL LYOutOfMemory;	/* Declared in LYexit.c - FM */
 
-#define TCP_PORT 80     /* Allocated to http by Jon Postel/ISI 24-Jan-92 */
-#define OLD_TCP_PORT 2784       /* Try the old one if no answer on 80 */
-#define DNP_OBJ 80      /* This one doesn't look busy, but we must check */
-                        /* That one was for decnet */
+#define TCP_PORT 80		/* Allocated to http by Jon Postel/ISI 24-Jan-92 */
+#define OLD_TCP_PORT 2784	/* Try the old one if no answer on 80 */
+#define DNP_OBJ 80		/* This one doesn't look busy, but we must check */
+			/* That one was for decnet */
 
 /*      Inline Function WHITE: Is character c white space? */
 /*      For speed, include all control characters */
@@ -422,7 +360,7 @@
 #define WHITE(c) ((UCH(TOASCII(c))) <= 32)
 
 /*     Inline Function LYIsASCII: Is character c a traditional ASCII
-**     character (i.e. <128) after converting from host character set.  */
+ *     character (i.e. <128) after converting from host character set.  */
 
 #define LYIsASCII(c) (TOASCII(UCH(c)) < 128)
 
@@ -435,29 +373,27 @@
 
  */
 
-#define HT_REDIRECTING 399
-#define HT_LOADED 200                   /* Instead of a socket */
-#define HT_PARTIAL_CONTENT      206     /* Partial Content */
-#define HT_INTERRUPTED -29998
-#define HT_NOT_LOADED -29999
-#define HT_OK           0               /* Generic success*/
-
-#define HT_ERROR                -1      /* Generic failure */
-
-#define HT_CANNOT_TRANSLATE -4
-
-#define HT_NO_DATA		-204	/* OK but no data was loaded - */
+#define HT_PARSER_OTHER_CONTENT  701	/* tells SGML to change content model */
+#define HT_PARSER_REOPEN_ELT     700	/* tells SGML parser to keep tag open */
+#define HT_REDIRECTING           399
+#define HT_PARTIAL_CONTENT       206	/* Partial Content */
+#define HT_LOADED                200	/* Instead of a socket */
+
+#define HT_OK                      0	/* Generic success */
+
+#define HT_ERROR                  -1	/* Generic failure */
+#define HT_CANNOT_TRANSLATE       -4
+#define HT_BAD_EOF               -12	/* Premature EOF */
+#define HT_NO_CONNECTION         -99	/* ERR no connection available - */
+#define HT_NO_DATA              -204	/* OK but no data was loaded - */
 					/* possibly other app started or forked */
-#define HT_NO_ACCESS            -401    /* Access not available */
-#define HT_FORBIDDEN            -403    /* Access forbidden */
-#define HT_NOT_ACCEPTABLE       -406    /* Not Acceptable */
-
-#define HT_PARSER_REOPEN_ELT     700    /* tells SGML parser to keep tag open */
-#define HT_PARSER_OTHER_CONTENT  701    /* tells SGML to change content model */
-#define HT_H_ERRNO_VALID        -800    /* see h_errno for resolver error */
-
-#define HT_INTERNAL             -900    /* Weird -- should never happen. */
-#define HT_BAD_EOF      -12             /* Premature EOF */
+#define HT_NO_ACCESS            -401	/* Access not available */
+#define HT_FORBIDDEN            -403	/* Access forbidden */
+#define HT_NOT_ACCEPTABLE       -406	/* Not Acceptable */
+#define HT_H_ERRNO_VALID        -800	/* see h_errno for resolver error */
+#define HT_INTERNAL             -900	/* Weird -- should never happen. */
+#define HT_INTERRUPTED        -29998
+#define HT_NOT_LOADED         -29999
 
 #ifndef va_arg
 # if defined(HAVE_STDARG_H) && defined(ANSI_VARARGS)
@@ -483,11 +419,11 @@
 #if defined(GCC_PRINTF) && !defined(printf) && !defined(HAVE_LIBUTF8_H)
 #define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
 #else
-#define GCC_PRINTFLIKE(fmt,var) /*nothing*/
+#define GCC_PRINTFLIKE(fmt,var)	/*nothing */
 #endif
 #endif
 
-#include <HTString.h>   /* String utilities */
+#include <HTString.h>		/* String utilities */
 
 /*
 
@@ -501,8 +437,6 @@
 
 #include <LYexit.h>
 
-extern void outofmem PARAMS((CONST char *fname, CONST char *func));
-
 /*
  * Upper- and Lowercase macros
  *
@@ -523,10 +457,6 @@
 #define TOUPPER(c) ascii_toupper(UCH(c))
 #define ISUPPER(c) ascii_isupper(UCH(c))
 
-extern int ascii_toupper PARAMS((int));
-extern int ascii_tolower PARAMS((int));
-extern int ascii_isupper PARAMS((int));
-
 #else
 
 #define TOLOWER(c) (isupper(UCH(c)) ? tolower(UCH(c)) : UCH(c))
@@ -548,8 +478,8 @@
    translation.
 
  */
-#define LF   FROMASCII('\012')  /* ASCII line feed LOCAL EQUIVALENT */
-#define CR   FROMASCII('\015')  /* Will be converted to ^M for transmission */
+#define LF   FROMASCII('\012')	/* ASCII line feed LOCAL EQUIVALENT */
+#define CR   FROMASCII('\015')	/* Will be converted to ^M for transmission */
 
 /*
  * Debug message control.
@@ -578,7 +508,7 @@
 #if defined(LY_TRACELINE)
 #define LY_SHOWWHERE fprintf( tfp, "%s: %d: ", __FILE__, LY_TRACELINE ),
 #else
-#define LY_SHOWWHERE /* nothing */
+#define LY_SHOWWHERE		/* nothing */
 #endif
 
 #define CTRACE(p)         ((void)((TRACE) && ( LY_SHOWWHERE fprintf p )))
@@ -587,8 +517,6 @@
 #define CTRACE_SLEEP(secs) if (TRACE && LYTraceLogFP == 0) sleep(secs)
 #define CTRACE_FLUSH(fp)   if (TRACE) fflush(fp)
 
-extern FILE *TraceFP NOPARAMS;
-
 #include <www_tcp.h>
 
 /*
@@ -598,7 +526,7 @@
  * for the stdio functions as well as the network functions.
  */
 #if defined(USE_SOCKS5) && !defined(DONT_USE_SOCKS5)
-#define SOCKS4TO5	/* turn on the Rxxxx definitions used in Lynx */
+#define SOCKS4TO5		/* turn on the Rxxxx definitions used in Lynx */
 #include <socks.h>
 
 /*
@@ -637,7 +565,7 @@
 
 #endif /* USE_SOCKS5 */
 
-#define SHORTENED_RBIND	/* FIXME: do this in configure-script */
+#define SHORTENED_RBIND		/* FIXME: do this in configure-script */
 
 #ifdef USE_SSL
 #define free_func free__func
@@ -660,7 +588,7 @@
 #define SSL_VERIFY_PEER			0x01
 #endif
 
-#else	/* assume SSLeay */
+#else /* assume SSLeay */
 #include <ssl.h>
 #include <crypto.h>
 #include <rand.h>
@@ -670,26 +598,44 @@
 
 #undef free_func
 
-extern SSL * HTGetSSLHandle NOPARAMS;
-extern void HTSSLInitPRNG NOPARAMS;
-extern char HTGetSSLCharacter PARAMS((void * handle));
-
 #endif /* USE_SSL */
 
 #ifdef HAVE_LIBDMALLOC
-#include <dmalloc.h>    /* Gray Watson's library */
+#include <dmalloc.h>		/* Gray Watson's library */
 #define show_alloc() dmalloc_log_unfreed()
 #endif
 
 #ifdef HAVE_LIBDBMALLOC
-#include <dbmalloc.h>   /* Conor Cahill's library */
+#include <dbmalloc.h>		/* Conor Cahill's library */
 #define show_alloc() malloc_dump(fileno(stderr))
 #endif
 
 #ifndef show_alloc
-#define show_alloc()	/* nothing */
+#define show_alloc()		/* nothing */
 #endif
 
 #include <userdefs.h>
 
-#endif /* HTUTILS_H */
+#ifdef __cplusplus
+extern "C" {
+#endif
+#ifndef TOLOWER
+#ifdef EXP_ASCII_CTYPES
+    extern int ascii_toupper(int);
+    extern int ascii_tolower(int);
+    extern int ascii_isupper(int);
+#endif
+#endif
+
+    extern FILE *TraceFP(void);
+
+#ifdef USE_SSL
+    extern SSL *HTGetSSLHandle(void);
+    extern void HTSSLInitPRNG(void);
+    extern char HTGetSSLCharacter(void *handle);
+#endif				/* USE_SSL */
+
+#ifdef __cplusplus
+}
+#endif
+#endif				/* HTUTILS_H */
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/HTGopher.h
+++ lynx-cur-2.8.6/WWW/Library/Implementation/HTGopher.h
@@ -7,17 +7,23 @@
                          
  */
 
-
 #ifndef HTGOPHER_H
 #define HTGOPHER_H
 
 #include <HTAccess.h>
 #include <HTAnchor.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
 #ifdef GLOBALREF_IS_MACRO
-extern GLOBALREF (HTProtocol, HTGopher);
+    extern GLOBALREF (HTProtocol, HTGopher);
+
 #else
-GLOBALREF HTProtocol HTGopher;
-#endif /* GLOBALREF_IS_MACRO */
+    GLOBALREF HTProtocol HTGopher;
+#endif				/* GLOBALREF_IS_MACRO */
 
-#endif /* HTGOPHER_H */
+#ifdef __cplusplus
+}
+#endif
+#endif				/* HTGOPHER_H */
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/HTNews.h
+++ lynx-cur-2.8.6/WWW/Library/Implementation/HTNews.h
@@ -3,9 +3,9 @@
                                              
  */
 /* History:
-**      26 Sep 90       Written TBL in Objective-C
-**      29 Nov 91       Downgraded to C, for portable implementation.
-*/
+ *      26 Sep 90       Written TBL in Objective-C
+ *      29 Nov 91       Downgraded to C, for portable implementation.
+ */
 
 #ifndef HTNEWS_H
 #define HTNEWS_H
@@ -13,41 +13,48 @@
 #include <HTAccess.h>
 #include <HTAnchor.h>
 
-extern int HTNewsChunkSize;
-extern int HTNewsMaxChunk;
+#ifdef __cplusplus
+extern "C" {
+#endif
+    extern int HTNewsChunkSize;
+    extern int HTNewsMaxChunk;
 
 #ifdef GLOBALREF_IS_MACRO
-extern GLOBALREF(HTProtocol, HTNews);
-extern GLOBALREF(HTProtocol, HTNNTP);
-extern GLOBALREF(HTProtocol, HTNewsPost);
-extern GLOBALREF(HTProtocol, HTNewsReply);
-extern GLOBALREF(HTProtocol, HTSNews);
-extern GLOBALREF(HTProtocol, HTSNewsPost);
-extern GLOBALREF(HTProtocol, HTSNewsReply);
+    extern GLOBALREF (HTProtocol, HTNews);
+    extern GLOBALREF (HTProtocol, HTNNTP);
+    extern GLOBALREF (HTProtocol, HTNewsPost);
+    extern GLOBALREF (HTProtocol, HTNewsReply);
+    extern GLOBALREF (HTProtocol, HTSNews);
+    extern GLOBALREF (HTProtocol, HTSNewsPost);
+    extern GLOBALREF (HTProtocol, HTSNewsReply);
+
 #else
-GLOBALREF HTProtocol HTNews;
-GLOBALREF HTProtocol HTNNTP;
-GLOBALREF HTProtocol HTNewsPost;
-GLOBALREF HTProtocol HTNewsReply;
-GLOBALREF HTProtocol HTSNews;
-GLOBALREF HTProtocol HTSNewsPost;
-GLOBALREF HTProtocol HTSNewsReply;
-#endif /* GLOBALREF_IS_MACRO */
-
-extern void HTSetNewsHost PARAMS((
-	CONST char *	value));
-extern CONST char * HTGetNewsHost NOPARAMS;
-extern char * HTNewsHost;
+    GLOBALREF HTProtocol HTNews;
+    GLOBALREF HTProtocol HTNNTP;
+    GLOBALREF HTProtocol HTNewsPost;
+    GLOBALREF HTProtocol HTNewsReply;
+    GLOBALREF HTProtocol HTSNews;
+    GLOBALREF HTProtocol HTSNewsPost;
+    GLOBALREF HTProtocol HTSNewsReply;
+#endif				/* GLOBALREF_IS_MACRO */
+
+    extern void HTSetNewsHost(const char *value);
+    extern const char *HTGetNewsHost(void);
+    extern char *HTNewsHost;
 
-extern void HTClearNNTPAuthInfo NOPARAMS;
+    extern void HTClearNNTPAuthInfo(void);
 
 #ifdef USE_SSL
-extern int HTNewsProxyConnect PARAMS ((
-	int		sock,
-	CONST char *	url,
-	HTParentAnchor *anAnchor,
-	HTFormat	format_out,
-	HTStream *	sink));
+    extern SSL_CTX *ssl_ctx;
+
+    extern int HTNewsProxyConnect(int sock,
+				  const char *url,
+				  HTParentAnchor *anAnchor,
+				  HTFormat format_out,
+				  HTStream *sink);
 #endif
 
-#endif /* HTNEWS_H */
+#ifdef __cplusplus
+}
+#endif
+#endif				/* HTNEWS_H */
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/HTMIME.h
+++ lynx-cur-2.8.6/WWW/Library/Implementation/HTMIME.h
@@ -1,23 +1,23 @@
 /*                   /Net/dxcern/userd/timbl/hypertext/WWW/Library/Implementation/HTMIME.html
                                        MIME PARSER
 
-   The MIME parser stream presents a MIME document.  It recursively invokes the format
-   manager to handle embedded formats.
+   The MIME parser stream presents a MIME document.  It recursively invokes the
+   format manager to handle embedded formats.
 
-   As well as stripping off and parsing the headers, the MIME parser has to parse any
-   weirld MIME encodings it may meet within the body parts of messages, and must deal with
-   multipart messages.
+   As well as stripping off and parsing the headers, the MIME parser has to
+   parse any weirld MIME encodings it may meet within the body parts of
+   messages, and must deal with multipart messages.
 
-   This module is implemented to the level necessary for operation with WWW, but is not
-   currently complete for any arbitrary MIME message.
+   This module is implemented to the level necessary for operation with WWW,
+   but is not currently complete for any arbitrary MIME message.
 
    Check the source for latest additions to functionality.
 
-   The MIME parser is complicated by the fact that WWW allows real binary to be sent, not
-   ASCII encoded.  Therefore the netascii decoding is included in this module.  One cannot
-   layer it by converting first from Net to local text, then decoding it.  Of course, for
-   local files, the net ascii decoding is not needed.  There are therefore two creation
-   routines.
+   The MIME parser is complicated by the fact that WWW allows real binary to be
+   sent, not ASCII encoded.  Therefore the netascii decoding is included in
+   this module.  One cannot layer it by converting first from Net to local
+   text, then decoding it.  Of course, for local files, the net ascii decoding
+   is not needed.  There are therefore two creation routines.
 
  */
 #ifndef HTMIME_H
@@ -26,65 +26,65 @@
 #include <HTStream.h>
 #include <HTAnchor.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
 /*
-**  This function is for trimming off any paired
-**  open- and close-double quotes from header values.
-**  It does not parse the string for embedded quotes,
-**  and will not modify the string unless both the
-**  first and last characters are double-quotes. - FM
-*/
-extern void HTMIME_TrimDoubleQuotes PARAMS((
-	char *		value));
+ *  This function is for trimming off any paired
+ *  open- and close-double quotes from header values.
+ *  It does not parse the string for embedded quotes,
+ *  and will not modify the string unless both the
+ *  first and last characters are double-quotes. - FM
+ */ extern void HTMIME_TrimDoubleQuotes(char *value);
 
 /*
 
   INPUT: LOCAL TEXT
 
  */
-extern HTStream * HTMIMEConvert PARAMS((HTPresentation * pres,
-                                        HTParentAnchor * anchor,
-                                        HTStream * sink));
+    extern HTStream *HTMIMEConvert(HTPresentation *pres,
+				   HTParentAnchor *anchor,
+				   HTStream *sink);
+
 /*
 
   INPUT: NET ASCII
 
  */
-extern HTStream * HTNetMIME PARAMS((HTPresentation * pres,
-                                        HTParentAnchor * anchor,
-                                        HTStream * sink));
+    extern HTStream *HTNetMIME(HTPresentation *pres,
+			       HTParentAnchor *anchor,
+			       HTStream *sink);
+
 /*
 
   INPUT: Redirection message, parse headers only for Location if present
 
  */
-extern HTStream * HTMIMERedirect PARAMS((HTPresentation * pres,
-                                        HTParentAnchor * anchor,
-                                        HTStream * sink));
-
+    extern HTStream *HTMIMERedirect(HTPresentation *pres,
+				    HTParentAnchor *anchor,
+				    HTStream *sink);
 
 /*
 
   For handling Japanese headers.
 
 */
-extern void HTmmdec_base64 PARAMS((
-	char *	t,
-	char *	s));
-
-extern void HTmmdec_quote PARAMS((
-	char *	t,
-	char *	s));
-
-extern void HTmmdecode PARAMS((
-	char *	trg,
-	char *	str));
-
-extern int HTrjis PARAMS((
-	char *	t,
-	char *	s));
-
-extern int HTmaybekanji PARAMS((
-	int	c1,
-	int	c2));
+    extern void HTmmdec_base64(char *t,
+			       char *s);
+
+    extern void HTmmdec_quote(char *t,
+			      char *s);
+
+    extern void HTmmdecode(char *trg,
+			   char *str);
+
+    extern int HTrjis(char *t,
+		      char *s);
+
+    extern int HTmaybekanji(int c1,
+			    int c2);
 
-#endif /* !HTMIME_H */
+#ifdef __cplusplus
+}
+#endif
+#endif				/* !HTMIME_H */
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/HTInit.h
+++ lynx-cur-2.8.6/WWW/Library/Implementation/HTInit.h
@@ -1,11 +1,11 @@
 /*                   /Net/dxcern/userd/timbl/hypertext/WWW/Library/Implementation/HTInit.html
                                   INITIALISATION MODULE
                                              
-   This module resisters all the plug & play software modules which will be used in the
-   program.  This is for a browser.
+   This module registers all the plug & play software modules which will be
+   used in the program.  This is for a browser.
    
-   To override this, just copy it and link in your version befoe you link with the
-   library.
+   To override this, just copy it and link in your version before you link with
+   the library.
    
    Implemented by HTInit.c by default.
    
@@ -17,9 +17,18 @@
 #ifndef HTUTILS_H
 #include <HTUtils.h>
 #endif
- 
-extern void HTFormatInit NOPARAMS;
-extern void HTPreparsedFormatInit NOPARAMS;
-extern void HTFileInit NOPARAMS;
 
-#endif /* HTINIT_H */
+#ifdef __cplusplus
+extern "C" {
+#endif
+    extern void HTFormatInit(void);
+    extern void HTPreparsedFormatInit(void);
+    extern void HTFileInit(void);
+    extern int LYTestMailcapCommand(const char *testcommand, const char *params);
+    extern BOOL LYMailcapUsesPctS(const char *controlstring);
+    extern char *LYMakeMailcapCommand(const char *command, const char *params, const char *filename);
+
+#ifdef __cplusplus
+}
+#endif
+#endif				/* HTINIT_H */
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/HTFormat.h
+++ lynx-cur-2.8.6/WWW/Library/Implementation/HTFormat.h
@@ -17,53 +17,59 @@
 #include <HTStream.h>
 #include <HTAtom.h>
 #include <HTList.h>
+#include <HTAnchor.h>
 
-/*
-
-The HTFormat type
+#ifdef USE_SOURCE_CACHE
+#include <HTChunk.h>
+#endif
 
-   We use the HTAtom object for holding representations.  This allows faster manipulation
-   (comparison and copying) that if we stayed with strings.
+#ifdef USE_BZLIB
+#include <bzlib.h>
+#endif
 
- */
-typedef HTAtom * HTFormat;
+#ifdef USE_ZLIB
+#include <zlib.h>
+#endif
 
+#ifdef __cplusplus
+extern "C" {
+#endif
 /*
 
-   These macros (which used to be constants) define some basic internally referenced
-   representations.  The www/xxx ones are of course not MIME standard.
+   These macros (which used to be constants) define some basic internally
+   referenced representations.  The www/xxx ones are of course not MIME
+   standard.
 
-   www/source  is an output format which leaves the input untouched. It is useful for
-   diagnostics, and for users who want to see the original, whatever it is.
+   www/source is an output format which leaves the input untouched.  It is
+   useful for diagnostics, and for users who want to see the original, whatever
+   it is.
 
- */
-                        /* Internal ones */
-/* #define WWW_SOURCE HTAtom_for("www/source") */    /* Whatever it was originally*/
-extern HTAtom * WWW_SOURCE;     /* calculated once, heavy used */
+																	 *//* Internal ones *//* #define WWW_SOURCE HTAtom_for("www/source") *//* Whatever it was originally */ extern HTAtom *WWW_SOURCE;
+    /* calculated once, heavy used */
 
 /*
 
-   www/present represents the user's perception of the document.  If you convert to
-   www/present, you present the material to the user.
+   www/present represents the user's perception of the document.  If you
+   convert to www/present, you present the material to the user.
 
  */
-#define WWW_PRESENT HTAtom_for("www/present")   /* The user's perception */
+#define WWW_PRESENT HTAtom_for("www/present")	/* The user's perception */
 
 #define WWW_DEBUG       HTAtom_for("www/debug")
 /*
 
-   WWW_DEBUG represents the user's perception of debug information, for example sent as a
-   HTML document in a HTTP redirection message.
+   WWW_DEBUG represents the user's perception of debug information, for example
+   sent as a HTML document in a HTTP redirection message.
 
  */
 
 /*
 
-   The message/rfc822 format means a MIME message or a plain text message with no MIME
-   header.  This is what is returned by an HTTP server.
+   The message/rfc822 format means a MIME message or a plain text message with
+   no MIME header.  This is what is returned by an HTTP server.
 
  */
-#define WWW_MIME HTAtom_for("www/mime")         /* A MIME message */
+#define WWW_MIME HTAtom_for("www/mime")		/* A MIME message */
 
 /*
   For parsing only the header. - kw
@@ -75,7 +81,7 @@
    www/print is like www/present except it represents a printed copy.
 
  */
-#define WWW_PRINT HTAtom_for("www/print")       /* A printed copy */
+#define WWW_PRINT HTAtom_for("www/print")	/* A printed copy */
 
 /*
 
@@ -93,9 +99,9 @@
 
 /*
 
-   These are regular MIME types.  HTML is assumed to be added by the W3 code.
-   application/octet-stream was mistakenly application/binary in earlier libwww versions
-   (pre 2.11).
+   These are regular MIME types.  HTML is assumed to be added by the W3 code. 
+   application/octet-stream was mistakenly application/binary in earlier libwww
+   versions (pre 2.11).
 
  */
 #define WWW_PLAINTEXT   HTAtom_for("text/plain")
@@ -105,36 +111,24 @@
 #define WWW_HTML        HTAtom_for("text/html")
 #define WWW_BINARY      HTAtom_for("application/octet-stream")
 
-/*
-
-   We must include the following file after defining HTFormat, to which it makes
-   reference.
-
-The HTEncoding type
-
- */
-typedef HTAtom* HTEncoding;
+    typedef HTAtom *HTEncoding;
 
 /*
-
-   The following are values for the MIME types:
-
+ * The following are values for the MIME types:
  */
 #define WWW_ENC_7BIT            HTAtom_for("7bit")
 #define WWW_ENC_8BIT            HTAtom_for("8bit")
 #define WWW_ENC_BINARY          HTAtom_for("binary")
 
 /*
-
-   We also add
-
+ * We also add
  */
 #define WWW_ENC_COMPRESS        HTAtom_for("compress")
 
 /*
-   Does a string designate a real encoding, or is it just
-   a "dummy" as for example 7bit, 8bit, and binary?
-  */
+ * Does a string designate a real encoding, or is it just
+ * a "dummy" as for example 7bit, 8bit, and binary?
+ */
 #define IsUnityEncStr(senc) \
         ((senc)==NULL || *(senc)=='\0' || !strcmp(senc,"identity") ||\
         !strcmp(senc,"8bit") || !strcmp(senc,"binary") || !strcmp(senc,"7bit"))
@@ -143,53 +137,85 @@
         ((enc)==NULL || (enc)==HTAtom_for("identity") ||\
         (enc)==WWW_ENC_8BIT || (enc)==WWW_ENC_BINARY || (enc)==WWW_ENC_7BIT)
 
-
-#include <HTAnchor.h>
-
 /*
 
 The HTPresentation and HTConverter types
 
-   This HTPresentation structure represents a possible conversion algorithm from one
-   format to another.  It includes a pointer to a conversion routine.  The conversion
-   routine returns a stream to which data should be fed. See also HTStreamStack which
-   scans the list of registered converters and calls one.  See the initialisation module
-   for a list of conversion routines.
+   This HTPresentation structure represents a possible conversion algorithm
+   from one format to another.  It includes a pointer to a conversion routine. 
+   The conversion routine returns a stream to which data should be fed.  See
+   also HTStreamStack which scans the list of registered converters and calls
+   one.  See the initialisation module for a list of conversion routines.
 
  */
-typedef struct _HTPresentation HTPresentation;
+    typedef struct _HTPresentation HTPresentation;
 
-typedef HTStream * HTConverter PARAMS((
-        HTPresentation *        pres,
-        HTParentAnchor *        anchor,
-        HTStream *              sink));
+    typedef HTStream *HTConverter (HTPresentation *pres,
+				   HTParentAnchor *anchor,
+				   HTStream *sink);
 
-struct _HTPresentation {
-        HTAtom	*	rep;            /* representation name atomized */
-        HTAtom	*	rep_out;        /* resulting representation */
-        HTConverter *	converter;	/* routine to gen the stream stack */
-        char *		command;        /* MIME-format string */
-        float		quality;        /* Between 0 (bad) and 1 (good) */
-        float		secs;
-        float		secs_per_byte;
-	long int	maxbytes;
-	BOOL		get_accept;	/* list in "Accept:" for GET */
-};
+    struct _HTPresentation {
+	HTAtom *rep;		/* representation name atomized */
+	HTAtom *rep_out;	/* resulting representation */
+	HTConverter *converter;	/* routine to gen the stream stack */
+	char *command;		/* MIME-format command string */
+	char *testcommand;	/* MIME-format test string */
+	float quality;		/* Between 0 (bad) and 1 (good) */
+	float secs;
+	float secs_per_byte;
+	long int maxbytes;
+	BOOL get_accept;	/* list in "Accept:" for GET */
+	int accept_opt;		/* matches against LYAcceptMedia */
+    };
 
 /*
 
-   The list of presentations is kept by this module.  It is also scanned by modules which
-   want to know the set of formats supported. for example.
+   The list of presentations is kept by this module.  It is also scanned by
+   modules which want to know the set of formats supported.  for example.
 
  */
-extern HTList * HTPresentations;
+    extern HTList *HTPresentations;
 
 /*
 
    The default presentation is used when no other is appropriate
 
  */
-extern  HTPresentation* default_presentation;
+    extern HTPresentation *default_presentation;
+
+/*
+ * Options used for "Accept:" string
+ */
+    typedef enum {
+	/* make the components powers of two so we can add them */
+	mediaINT = 1		/* internal types predefined in HTInit.c */
+	,mediaEXT = 2		/* external types predefined in HTInit.c */
+	,mediaCFG = 4		/* types, e.g., viewers, from lynx.cfg */
+	,mediaUSR = 8		/* user's mime-types, etc. */
+	,mediaSYS = 16		/* system's mime-types, etc. */
+	/* these are useful flavors for the options menu */
+	,mediaOpt1 = mediaINT
+	,mediaOpt2 = mediaINT + mediaCFG
+	,mediaOpt3 = mediaINT + mediaCFG + mediaUSR
+	,mediaOpt4 = mediaINT + mediaCFG + mediaUSR + mediaSYS
+	/* this is the flavor from pre-2.8.6 */
+	,mediaALL = mediaINT + mediaEXT + mediaCFG + mediaUSR + mediaSYS
+    } AcceptMedia;
+
+/*
+ * Options used for "Accept-Encoding:" string
+ */
+    typedef enum {
+	encodingNONE = 0
+	,encodingGZIP = 1
+	,encodingDEFLATE = 2
+	,encodingCOMPRESS = 4
+	,encodingBZIP2 = 8
+	,encodingALL = (encodingGZIP
+			+ encodingDEFLATE
+			+ encodingCOMPRESS
+			+ encodingBZIP2)
+    } AcceptEncoding;
 
 /*
 
@@ -201,6 +227,8 @@
 
   command                 is the MAILCAP - style command template
 
+  testcommand             is the MAILCAP - style testcommand template
+
   quality                 A degradation faction 0..1.0
 
   secs                    A limit on the time user will wait (0.0 for infinity)
@@ -208,16 +236,18 @@
 
   maxbytes                A limit on the length acceptable as input (0 infinite)
 
- */
-extern void HTSetPresentation PARAMS((
-        CONST char *	representation,
-        CONST char *	command,
-        double		quality,
-        double		secs,
-        double		secs_per_byte,
-	long int	maxbytes
-));
+  media                   Used in filtering presentation types for "Accept:"
 
+ */
+    extern void HTSetPresentation(const char *representation,
+				  const char *command,
+				  const char *testcommand,
+				  double quality,
+				  double secs,
+				  double secs_per_byte,
+				  long int maxbytes,
+				  AcceptMedia media
+    );
 
 /*
 
@@ -233,51 +263,48 @@
 
  */
 
-extern void HTSetConversion PARAMS((
-        CONST char *    rep_in,
-        CONST char *    rep_out,
-        HTConverter *   converter,
-        float           quality,
-        float           secs,
-        float           secs_per_byte,
-	long int	maxbytes
-));
-
+    extern void HTSetConversion(const char *rep_in,
+				const char *rep_out,
+				HTConverter *converter,
+				float quality,
+				float secs,
+				float secs_per_byte,
+				long int maxbytes,
+				AcceptMedia media
+    );
 
 /*
 
 HTStreamStack:   Create a stack of streams
 
-   This is the routine which actually sets up the conversion.  It currently checks only for
-   direct conversions, but multi-stage conversions are forseen.  It takes a stream into
-   which the output should be sent in the final format, builds the conversion stack, and
-   returns a stream into which the data in the input format should be fed.  The anchor is
-   passed because hypertxet objects load information into the anchor object which
-   represents them.
+   This is the routine which actually sets up the conversion.  It currently
+   checks only for direct conversions, but multi-stage conversions are forseen. 
+   It takes a stream into which the output should be sent in the final format,
+   builds the conversion stack, and returns a stream into which the data in the
+   input format should be fed.  The anchor is passed because hypertxet objects
+   load information into the anchor object which represents them.
 
  */
-extern HTStream * HTStreamStack PARAMS((
-        HTFormat                format_in,
-        HTFormat                format_out,
-        HTStream*               stream_out,
-        HTParentAnchor*         anchor));
+    extern HTStream *HTStreamStack(HTFormat format_in,
+				   HTFormat format_out,
+				   HTStream *stream_out,
+				   HTParentAnchor *anchor);
 
 /*
 HTReorderPresentation: put presentation near head of list
 
-    Look up a presentation (exact match only) and, if found, reorder
-    it to the start of the HTPresentations list. - kw
+    Look up a presentation (exact match only) and, if found, reorder it to the
+    start of the HTPresentations list.  - kw
     */
 
-extern void HTReorderPresentation PARAMS((
-        HTFormat                format_in,
-        HTFormat                format_out));
+    extern void HTReorderPresentation(HTFormat format_in,
+				      HTFormat format_out);
 
 /*
  * Setup 'get_accept' flag to denote presentations that are not redundant,
  * and will be listed in "Accept:" header.
  */
-extern void HTFilterPresentations NOPARAMS;
+    extern void HTFilterPresentations(void);
 
 /*
 
@@ -297,69 +324,63 @@
   length                  The number of bytes expected in the input format
 
  */
-extern float HTStackValue PARAMS((
-        HTFormat                format_in,
-        HTFormat                rep_out,
-        float                   initial_value,
-        long int                length));
+    extern float HTStackValue(HTFormat format_in,
+			      HTFormat rep_out,
+			      float initial_value,
+			      long int length);
 
 #define NO_VALUE_FOUND  -1e20	/* returned if none found */
 
 /*	Display the page while transfer in progress
-**	-------------------------------------------
-**
-**   Repaint the page only when necessary.
-**   This is a traverse call for HText_pageDispaly() - it works!.
-**
-*/
-extern void HTDisplayPartial NOPARAMS;
+ *	-------------------------------------------
+ *
+ *   Repaint the page only when necessary.
+ *   This is a traverse call for HText_pageDispaly() - it works!.
+ *
+ */
+    extern void HTDisplayPartial(void);
 
-extern void HTFinishDisplayPartial NOPARAMS;
+    extern void HTFinishDisplayPartial(void);
 
 /*
 
 HTCopy:  Copy a socket to a stream
 
-   This is used by the protocol engines to send data down a stream, typically one which
-   has been generated by HTStreamStack.
+   This is used by the protocol engines to send data down a stream, typically
+   one which has been generated by HTStreamStack.
 
  */
-extern int HTCopy PARAMS((
-	HTParentAnchor *	anchor,
-        int                     file_number,
-	void*			handle,
-        HTStream*               sink));
-
+    extern int HTCopy(HTParentAnchor *anchor,
+		      int file_number,
+		      void *handle,
+		      HTStream *sink);
 
 /*
 
 HTFileCopy:  Copy a file to a stream
 
-   This is used by the protocol engines to send data down a stream, typically one which
-   has been generated by HTStreamStack.  It is currently called by HTParseFile
+   This is used by the protocol engines to send data down a stream, typically
+   one which has been generated by HTStreamStack.  It is currently called by
+   HTParseFile
 
  */
-extern int HTFileCopy PARAMS((
-        FILE*                   fp,
-        HTStream*               sink));
-
+    extern int HTFileCopy(FILE *fp,
+			  HTStream *sink);
 
 #ifdef USE_SOURCE_CACHE
-#include <HTChunk.h>
 /*
 
 HTMemCopy:  Copy a memory chunk to a stream
 
-   This is used by the protocol engines to send data down a stream, typically one which
-   has been generated by HTStreamStack.  It is currently called by HTParseMem
+   This is used by the protocol engines to send data down a stream, typically
+   one which has been generated by HTStreamStack.  It is currently called by
+   HTParseMem
 
  */
-extern int HTMemCopy PARAMS((
-	HTChunk *		chunk,
-	HTStream*		sink));
+    extern int HTMemCopy(HTChunk *chunk,
+			 HTStream *sink);
 #endif
 
-
 /*
 
 HTCopyNoCR: Copy a socket to a stream, stripping CR characters.
@@ -368,46 +389,44 @@
 
  */
 
-extern void HTCopyNoCR PARAMS((
-	HTParentAnchor *	anchor,
-        int                     file_number,
-        HTStream*               sink));
-
+    extern void HTCopyNoCR(HTParentAnchor *anchor,
+			   int file_number,
+			   HTStream *sink);
 
 /*
 
 Clear input buffer and set file number
 
-   This routine and the one below provide simple character input from sockets. (They are
-   left over from the older architecure and may not be used very much.)  The existence of
-   a common routine and buffer saves memory space in small implementations.
+   This routine and the one below provide simple character input from sockets. 
+   (They are left over from the older architecture and may not be used very
+   much.) The existence of a common routine and buffer saves memory space in
+   small implementations.
 
  */
-extern void HTInitInput PARAMS((int file_number));
+    extern void HTInitInput(int file_number);
 
 /*
 
 Get next character from buffer
 
  */
-extern int interrupted_in_htgetcharacter;
-extern int HTGetCharacter NOPARAMS;
-
+    extern int interrupted_in_htgetcharacter;
+    extern int HTGetCharacter(void);
 
 /*
 
 HTParseSocket: Parse a socket given its format
 
-   This routine is called by protocol modules to load an object.  uses HTStreamStack and
-   the copy routines above.  Returns HT_LOADED if succesful, <0 if not.
+   This routine is called by protocol modules to load an object.  uses
+   HTStreamStack and the copy routines above.  Returns HT_LOADED if successful,
+   <0 if not.
 
  */
-extern int HTParseSocket PARAMS((
-        HTFormat        format_in,
-        HTFormat        format_out,
-        HTParentAnchor  *anchor,
-        int             file_number,
-        HTStream*       sink));
+    extern int HTParseSocket(HTFormat format_in,
+			     HTFormat format_out,
+			     HTParentAnchor *anchor,
+			     int file_number,
+			     HTStream *sink);
 
 /*
 
@@ -418,12 +437,11 @@
    return HT_PARTIAL_CONTENT, HT_NO_DATA, or other <0 for failure.
 
  */
-extern int HTParseFile PARAMS((
-        HTFormat        format_in,
-        HTFormat        format_out,
-        HTParentAnchor  *anchor,
-        FILE            *fp,
-        HTStream*       sink));
+    extern int HTParseFile(HTFormat format_in,
+			   HTFormat format_out,
+			   HTParentAnchor *anchor,
+			   FILE *fp,
+			   HTStream *sink);
 
 #ifdef USE_SOURCE_CACHE
 /*
@@ -435,16 +453,14 @@
    return <0 for failure.
 
  */
-extern int HTParseMem PARAMS((
-	HTFormat	format_in,
-	HTFormat	format_out,
-	HTParentAnchor	*anchor,
-	HTChunk*	chunk,
-	HTStream*	sink));
+    extern int HTParseMem(HTFormat format_in,
+			  HTFormat format_out,
+			  HTParentAnchor *anchor,
+			  HTChunk *chunk,
+			  HTStream *sink);
 #endif
 
 #ifdef USE_ZLIB
-#include <zlib.h>
 /*
 HTParseGzFile: Parse a gzip'ed File through a file pointer
 
@@ -452,17 +468,28 @@
    HTStreamStack and HTGzFileCopy.  Returns HT_LOADED if successful, can also
    return HT_PARTIAL_CONTENT, HT_NO_DATA, or other <0 for failure.
  */
-extern int HTParseGzFile PARAMS((
-        HTFormat        format_in,
-        HTFormat        format_out,
-        HTParentAnchor  *anchor,
-        gzFile          gzfp,
-        HTStream*       sink));
+    extern int HTParseGzFile(HTFormat format_in,
+			     HTFormat format_out,
+			     HTParentAnchor *anchor,
+			     gzFile gzfp,
+			     HTStream *sink);
 
-#endif /* USE_ZLIB */
+/*
+HTParseZzFile: Parse a deflate'd File through a file pointer
+
+   This routine is called by protocols modules to load an object.  uses
+   HTStreamStack and HTZzFileCopy.  Returns HT_LOADED if successful, can also
+   return HT_PARTIAL_CONTENT, HT_NO_DATA, or other <0 for failure.
+ */
+    extern int HTParseZzFile(HTFormat format_in,
+			     HTFormat format_out,
+			     HTParentAnchor *anchor,
+			     FILE *zzfp,
+			     HTStream *sink);
+
+#endif				/* USE_ZLIB */
 
 #ifdef USE_BZLIB
-#include <bzlib.h>
 /*
 HTParseBzFile: Parse a bzip2'ed File through a file pointer
 
@@ -470,44 +497,48 @@
    HTStreamStack and HTGzFileCopy.  Returns HT_LOADED if successful, can also
    return HT_PARTIAL_CONTENT, HT_NO_DATA, or other <0 for failure.
  */
-extern int HTParseBzFile PARAMS((
-        HTFormat        format_in,
-        HTFormat        format_out,
-        HTParentAnchor  *anchor,
-        BZFILE          *bzfp,
-        HTStream*       sink));
+    extern int HTParseBzFile(HTFormat format_in,
+			     HTFormat format_out,
+			     HTParentAnchor *anchor,
+			     BZFILE * bzfp,
+			     HTStream *sink);
 
-#endif /* USE_BZLIB */
+#endif				/* USE_BZLIB */
 
 /*
 
 HTNetToText: Convert Net ASCII to local representation
 
-   This is a filter stream suitable for taking text from a socket and passing it into a
-   stream which expects text in the local C representation.  It does ASCII and newline
-   conversion.  As usual, pass its output stream to it when creating it.
+   This is a filter stream suitable for taking text from a socket and passing
+   it into a stream which expects text in the local C representation.  It does
+   ASCII and newline conversion.  As usual, pass its output stream to it when
+   creating it.
 
  */
-extern HTStream *  HTNetToText PARAMS ((HTStream * sink));
+    extern HTStream *HTNetToText(HTStream *sink);
 
 /*
 
 HTFormatInit: Set up default presentations and conversions
 
-   These are defined in HTInit.c or HTSInit.c if these have been replaced. If you don't
-   call this routine, and you don't define any presentations, then this routine will
-   automatically be called the first time a conversion is needed. However, if you
-   explicitly add some conversions (eg using HTLoadRules) then you may want also to
-   explicitly call this to get the defaults as well.
+   These are defined in HTInit.c or HTSInit.c if these have been replaced.  If
+   you don't call this routine, and you don't define any presentations, then
+   this routine will automatically be called the first time a conversion is
+   needed.  However, if you explicitly add some conversions (eg using
+   HTLoadRules) then you may want also to explicitly call this to get the
+   defaults as well.
 
  */
-extern void HTFormatInit NOPARAMS;
+    extern void HTFormatInit(void);
 
 /*
 
 Epilogue
 
  */
-extern BOOL HTOutputSource;     /* Flag: shortcut parser */
+    extern BOOL HTOutputSource;	/* Flag: shortcut parser */
 
-#endif /* HTFORMAT_H */
+#ifdef __cplusplus
+}
+#endif
+#endif				/* HTFORMAT_H */
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/HTRules.h
+++ lynx-cur-2.8.6/WWW/Library/Implementation/HTRules.h
@@ -21,24 +21,27 @@
 #ifndef HTUTILS_H
 #include <HTUtils.h>
 #endif
- 
-typedef enum {
-        HT_Invalid,
-        HT_Map,
-        HT_Pass,
-        HT_Fail,
-        HT_DefProt,
-        HT_Protect,
-        HT_Progress,
-        HT_InfoMsg,
-        HT_UserMsg,
-        HT_Alert,
-        HT_AlwaysAlert,
-        HT_Redirect,
-        HT_RedirectPerm,
-        HT_PermitRedir,
-        HT_UseProxy
-} HTRuleOp;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+    typedef enum {
+	HT_Invalid,
+	HT_Map,
+	HT_Pass,
+	HT_Fail,
+	HT_DefProt,
+	HT_Protect,
+	HT_Progress,
+	HT_InfoMsg,
+	HT_UserMsg,
+	HT_Alert,
+	HT_AlwaysAlert,
+	HT_Redirect,
+	HT_RedirectPerm,
+	HT_PermitRedir,
+	HT_UseProxy
+    } HTRuleOp;
 
 #ifndef NO_RULES
 
@@ -54,8 +57,8 @@
 
  */
 
-extern char * HTBinDir;         /* Physical /htbin location */
-extern char * HTSearchScript;   /* Search script name */
+    extern char *HTBinDir;	/* Physical /htbin location */
+    extern char *HTSearchScript;	/* Search script name */
 
 /*
 
@@ -84,13 +87,10 @@
    large.
 
  */
-extern int HTAddRule PARAMS((
-    HTRuleOp op,
-    CONST char * pattern,
-    CONST char * equiv,
-    CONST char * cond_op,
-    CONST char * cond));
-
+    extern int HTAddRule(HTRuleOp op, const char *pattern,
+			 const char *equiv,
+			 const char *cond_op,
+			 const char *cond);
 
 /*
 
@@ -102,7 +102,7 @@
 
  */
 
-extern void HTClearRules PARAMS((void));
+    extern void HTClearRules(void);
 
 /*
 
@@ -123,7 +123,7 @@
                          a copy of the original.
 
  */
-extern char * HTTranslate PARAMS((CONST char * required));
+    extern char *HTTranslate(const char *required);
 
 /*
 
@@ -137,8 +137,7 @@
    the  rule file, for example INI files for X resources.
 
  */
-extern int HTSetConfiguration PARAMS((char * config));
-
+    extern int HTSetConfiguration(char *config);
 
 /*
 
@@ -157,10 +156,14 @@
 
  */
 
-extern int HTLoadRules PARAMS((CONST char * filename));
+    extern int HTLoadRules(const char *filename);
+
 /*
 
  */
 
-#endif /* NO_RULES */
-#endif /* HTRULE_H */
+#endif				/* NO_RULES */
+#ifdef __cplusplus
+}
+#endif
+#endif				/* HTRULE_H */
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/HTString.h
+++ lynx-cur-2.8.6/WWW/Library/Implementation/HTString.h
@@ -11,23 +11,26 @@
 #include <HTUtils.h>
 #endif /* HTUTILS_H */
 
-extern CONST char * HTLibraryVersion;   /* String for help screen etc */
+#ifdef __cplusplus
+extern "C" {
+#endif
+    extern const char *HTLibraryVersion;	/* String for help screen etc */
 
 /*
     EBCDIC string comparison using ASCII collating sequence
 */
 #ifdef    NOT_ASCII
-extern int AS_casecomp  PARAMS((CONST char *a, CONST char *b));
-extern int AS_ncmp PARAMS((CONST char *a, CONST char *b, unsigned int n));
+    extern int AS_casecomp(const char *a, const char *b);
+    extern int AS_ncmp(const char *a, const char *b, unsigned int n);
+
 #define    AS_cmp( a, b )  ( AS_ncmp( ( a ), ( b ), -1 ) )
-extern int AS_cmp PARAMS((CONST char *a, CONST char *b));
 
 #else
 #define AS_casecomp( a, b ) ( strcasecomp( ( a ), ( b ) ) )
 #define AS_ncmp( a, b, c )  ( strncmp( ( a ), ( b ), ( c ) ) )
 #define AS_cmp strcmp
 
-#endif /* NOT_ASCII */
+#endif				/* NOT_ASCII */
 
 /*
 
@@ -36,17 +39,17 @@
    The usual routines (comp instead of cmp) had some problem.
    
  */
-extern int strcasecomp  PARAMS((CONST char *a, CONST char *b));
-extern int strncasecomp PARAMS((CONST char *a, CONST char *b, int n));
+    extern int strcasecomp(const char *a, const char *b);
+    extern int strncasecomp(const char *a, const char *b, int n);
 
-extern int strcasecomp8  PARAMS((CONST char *a, CONST char *b));
-extern int strncasecomp8 PARAMS((CONST char *a, CONST char *b, int n));
-       /*
-       **  strcasecomp8 and strncasecomp8 are variants of strcasecomp
-       **  and strncasecomp, but use 8bit upper/lower case information
-       **  from the current display charset
-       */
+    extern int strcasecomp8(const char *a, const char *b);
+    extern int strncasecomp8(const char *a, const char *b, int n);
 
+    /*
+     * strcasecomp8 and strncasecomp8 are variants of strcasecomp and
+     * strncasecomp, but use 8bit upper/lower case information from the
+     * current display charset
+     */
 
 /*
 
@@ -55,8 +58,8 @@
  */
 #define StrAllocCopy(dest, src) HTSACopy (&(dest), src)
 #define StrAllocCat(dest, src)  HTSACat  (&(dest), src)
-extern char * HTSACopy PARAMS ((char **dest, CONST char *src));
-extern char * HTSACat  PARAMS ((char **dest, CONST char *src));
+    extern char *HTSACopy(char **dest, const char *src);
+    extern char *HTSACat(char **dest, const char *src);
 
 /*
 optimized for heavily realloc'd strings in temp objects
@@ -64,36 +67,28 @@
 #define StrAllocCopy_extra(dest, src) HTSACopy_extra (&(dest), src)
 #define FREE_extra(x)   {if (x != NULL) {HTSAFree_extra(x); x = NULL;}}
 #define Clear_extra(x)  {if (x != NULL) {*x = '\0';}}
-extern char * HTSACopy_extra PARAMS ((char **dest, CONST char *src));
-extern void   HTSAFree_extra PARAMS ((char *s));
+    extern char *HTSACopy_extra(char **dest, const char *src);
+    extern void HTSAFree_extra(char *s);
 
 /*
 
 Next word or quoted string
 
  */
-extern char * HTNextField PARAMS ((char** pstr));
+    extern char *HTNextField(char **pstr);
 
 /* A more general parser - kw */
-extern char * HTNextTok PARAMS((char ** pstr,
-		      CONST char * delims, CONST char * bracks, char * found));
+    extern char *HTNextTok(char **pstr,
+			   const char *delims, const char *bracks, char *found);
 
-#ifdef ANSI_VARARGS
-extern char * HTSprintf (char ** pstr, CONST char * fmt, ...)
-			GCC_PRINTFLIKE(2,3);
-extern char * HTSprintf0 (char ** pstr, CONST char * fmt, ...)
-			 GCC_PRINTFLIKE(2,3);
-#else
-extern char * HTSprintf () GCC_PRINTFLIKE(2,3);
-extern char * HTSprintf0 () GCC_PRINTFLIKE(2,3);
-#endif
+    extern char *HTSprintf(char **pstr, const char *fmt,...) GCC_PRINTFLIKE(2,3);
+    extern char *HTSprintf0(char **pstr, const char *fmt,...) GCC_PRINTFLIKE(2,3);
 
 #if defined(LY_FIND_LEAKS)	/* private otherwise */
-extern char * StrAllocVsprintf PARAMS((
-        char **		pstr,
-        size_t		len,
-        CONST char *	fmt,
-        va_list *	ap));
+    extern char *StrAllocVsprintf(char **pstr,
+				  size_t len,
+				  const char *fmt,
+				  va_list * ap);
 #endif
 
 #if (defined(VMS) || defined(DOSPATH) || defined(__EMX__)) && !defined(__CYGWIN__)
@@ -103,33 +98,34 @@
 #endif
 
 #if USE_QUOTED_PARAMETER
-extern char *HTQuoteParameter PARAMS((CONST char *parameter));
-extern void HTAddXpand PARAMS((char ** result, CONST char * command, int number, CONST char * parameter));
+    extern char *HTQuoteParameter(const char *parameter);
+    extern void HTAddXpand(char **result, const char *command, int number, const char *parameter);
+
 #else
 #define HTQuoteParameter(parameter) parameter	/* simplify ifdef'ing */
 #define HTAddXpand(result,command,number,parameter)  HTAddParam(result,command,number,parameter)
 #endif
 
-extern int HTCountCommandArgs PARAMS((CONST char * command));
-extern void HTAddToCmd PARAMS((char ** result, CONST char * command, int number, CONST char * string));
-extern void HTAddParam PARAMS((char ** result, CONST char * command, int number, CONST char * parameter));
-extern void HTEndParam PARAMS((char ** result, CONST char * command, int number));
+    extern int HTCountCommandArgs(const char *command);
+    extern void HTAddToCmd(char **result, const char *command, int number, const char *string);
+    extern void HTAddParam(char **result, const char *command, int number, const char *parameter);
+    extern void HTEndParam(char **result, const char *command, int number);
 
 /* Force an option, with leading blanks, to be appended without quoting them */
 #define HTOptParam(result, command, number, parameter) HTSACat(result, parameter)
 
 /* Binary copy and concat */
-typedef struct {
+    typedef struct {
 	char *str;
 	int len;
-} bstring;
+    } bstring;
 
-extern void HTSABCopy  PARAMS((bstring ** dest, CONST char * src, int len));
-extern void HTSABCopy0 PARAMS((bstring ** dest, CONST char * src));
-extern void HTSABCat   PARAMS((bstring ** dest, CONST char * src, int len));
-extern void HTSABCat0  PARAMS((bstring ** dest, CONST char * src));
-extern BOOL HTSABEql   PARAMS((bstring * a, bstring * b));
-extern void HTSABFree  PARAMS((bstring ** ptr));
+    extern void HTSABCopy(bstring **dest, const char *src, int len);
+    extern void HTSABCopy0(bstring **dest, const char *src);
+    extern void HTSABCat(bstring **dest, const char *src, int len);
+    extern void HTSABCat0(bstring **dest, const char *src);
+    extern BOOL HTSABEql(bstring *a, bstring *b);
+    extern void HTSABFree(bstring **ptr);
 
 #define BStrLen(s)    (((s) != 0) ? (s)->len : 0)
 #define BStrData(s)   (((s) != 0) ? (s)->str : 0)
@@ -144,14 +140,12 @@
 #define BStrCat0(d,s)  HTSABCat0(  &(d), s)
 #define BStrFree(d)    HTSABFree(  &(d))
 
-#ifdef ANSI_VARARGS
-extern bstring * HTBprintf (bstring ** pstr, CONST char * fmt, ...)
-			    GCC_PRINTFLIKE(2,3);
-#else
-extern bstring * HTBprintf () GCC_PRINTFLIKE(2,3);
-#endif
+    extern bstring *HTBprintf(bstring **pstr, const char *fmt,...) GCC_PRINTFLIKE(2,3);
 
-extern void trace_bstring PARAMS((bstring *data));
-extern void trace_bstring2 PARAMS((CONST char *text, int size));
+    extern void trace_bstring(bstring *data);
+    extern void trace_bstring2(const char *text, int size);
 
-#endif /* HTSTRING_H */
+#ifdef __cplusplus
+}
+#endif
+#endif				/* HTSTRING_H */
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/HTList.h
+++ lynx-cur-2.8.6/WWW/Library/Implementation/HTList.h
@@ -1,9 +1,9 @@
 
 /*              List object
-**
-**      The list object is a generic container for storing collections
-**      of things in order.
-*/
+ *
+ *      The list object is a generic container for storing collections
+ *      of things in order.
+ */
 #ifndef HTLIST_H
 #define HTLIST_H
 
@@ -11,133 +11,108 @@
 #include <HTUtils.h>
 #endif
 
-typedef struct _HTList HTList;
-
-struct _HTList {
-	void *		object;
-	HTList *	next;
-};
+#ifdef __cplusplus
+extern "C" {
+#endif
+    typedef struct _HTList HTList;
 
+    struct _HTList {
+	void *object;
+	HTList *next;
+    };
 
 /*	Fast macro to traverse a list.  Call it first with copy of the list
-**	header.  It returns the first object and increments the passed list
-**	pointer.  Call it with the same variable until it returns NULL.
-*/
+ *	header.  It returns the first object and increments the passed list
+ *	pointer.  Call it with the same variable until it returns NULL.
+ */
 #define HTList_nextObject(me) \
 	((me) && ((me) = (me)->next) ? (me)->object : NULL)
 
-
 /*	Macro to find object pointed to by the head (returns NULL
-**	if list is empty, OR if it doesn't exist - Yuk!)
-*/
+ *	if list is empty, OR if it doesn't exist - Yuk!)
+ */
 #define HTList_lastObject(me) \
 	((me) && (me)->next ? (me)->next->object : NULL)
 
-
 /*	Macro to check if a list is empty (or doesn't exist - Yuk!)
 */
 #define HTList_isEmpty(me) ((me) ? ((me)->next == NULL) : YES)
 
-
 /*	Create list.
 */
-extern HTList * HTList_new NOPARAMS;
-
+    extern HTList *HTList_new(void);
 
 /*	Delete list.
 */
-extern void HTList_delete PARAMS((
-	HTList *	me));
+    extern void HTList_delete(HTList *me);
 
 /*	Reverse a list.
 */
-extern HTList * HTList_reverse PARAMS((
-	HTList *	start));
+    extern HTList *HTList_reverse(HTList *start);
 
 /*	Append two lists, making second list empty.
 */
-extern HTList * HTList_appendList PARAMS((
-	HTList *	start,
-	HTList *	tail));
-
+    extern HTList *HTList_appendList(HTList *start,
+				     HTList *tail);
 
 /*      Add object to START of list (so it is pointed to by the head).
 */
-extern void HTList_addObject PARAMS((
-	HTList *	me,
-	void *		newObject));
-
+    extern void HTList_addObject(HTList *me,
+				 void *newObject);
 
 /*      Append object to END of list (furthest from the head).
 */
-extern void HTList_appendObject PARAMS((
-	HTList *	me,
-	void *		newObject));
-
+    extern void HTList_appendObject(HTList *me,
+				    void *newObject);
 
 /*	Insert an object into the list at a specified position.
-**      If position is 0, this places the object at the head of the list
-**      and is equivalent to HTList_addObject().
-*/
-extern void HTList_insertObjectAt PARAMS((
-	HTList *	me,
-	void *		newObject,
-	int		pos));
-
+ *      If position is 0, this places the object at the head of the list
+ *      and is equivalent to HTList_addObject().
+ */
+    extern void HTList_insertObjectAt(HTList *me,
+				      void *newObject,
+				      int pos);
 
 /*	Remove specified object from list.
 */
-extern BOOL HTList_removeObject PARAMS((
-	HTList *	me,
-	void *		oldObject));
-
+    extern BOOL HTList_removeObject(HTList *me,
+				    void *oldObject);
 
 /*	Remove object at a given position in the list, where 0 is the
-**	object pointed to by the head (returns a pointer to the element
-**	(->object) for the object, and NULL if the list is empty, or
-**	if it doesn't exist - Yuk!).
-*/
-extern void * HTList_removeObjectAt PARAMS((
-	HTList *	me,
-	int		position));
-
+ *	object pointed to by the head (returns a pointer to the element
+ *	(->object) for the object, and NULL if the list is empty, or
+ *	if it doesn't exist - Yuk!).
+ */
+    extern void *HTList_removeObjectAt(HTList *me,
+				       int position);
 
 /*	Remove object from START of list (the Last one inserted
-**	via HTList_addObject(), and pointed to by the head).
-*/
-extern void * HTList_removeLastObject PARAMS((
-	HTList *	me));
-
+ *	via HTList_addObject(), and pointed to by the head).
+ */
+    extern void *HTList_removeLastObject(HTList *me);
 
 /*	Remove object from END of list (the First one inserted
-**	via HTList_addObject(), and furthest from the head).
-*/
-extern void * HTList_removeFirstObject PARAMS((
-	HTList *	me));
-
+ *	via HTList_addObject(), and furthest from the head).
+ */
+    extern void *HTList_removeFirstObject(HTList *me);
 
 /*	Determine total number of objects in the list,
-**	not counting the head.
-*/
-extern int HTList_count PARAMS((
-	HTList *	me));
-
+ *	not counting the head.
+ */
+    extern int HTList_count(HTList *me);
 
 /*	Determine position of an object in the list (a value of 0
-**	means it is pointed to by the head; returns -1 if not found).
-*/
-extern int HTList_indexOf PARAMS((
-	HTList *	me,
-	void *		object));
-
+ *	means it is pointed to by the head; returns -1 if not found).
+ */
+    extern int HTList_indexOf(HTList *me,
+			      void *object);
 
 /*	Return pointer to the object at a specified position in the list,
-**	where 0 is the object pointed to by the head (returns NULL if
-**	the list is empty, or if it doesn't exist - Yuk!).
-*/
-extern void * HTList_objectAt PARAMS((
-	HTList *	me,
-	int		position));
+ *	where 0 is the object pointed to by the head (returns NULL if
+ *	the list is empty, or if it doesn't exist - Yuk!).
+ */
+    extern void *HTList_objectAt(HTList *me,
+				 int position);
 
 /*      Link object to START of list (so it is pointed to by the head).
  *
@@ -145,23 +120,23 @@
  *	it use already allocated memory which should not be free'd by any
  *	list operations (optimization).
  */
-extern void HTList_linkObject PARAMS((
-	HTList *	me,
-	void *		newObject,
-	HTList *	newNode));
+    extern void HTList_linkObject(HTList *me,
+				  void *newObject,
+				  HTList *newNode);
 
 /*	Unlink object from START of list (the Last one inserted
  *	via HTList_linkObject(), and pointed to by the head).
  *	It does not free memory.
  */
-extern void * HTList_unlinkLastObject PARAMS((
-	HTList *	me));
+    extern void *HTList_unlinkLastObject(HTList *me);
 
 /*	Unlink specified object from list.
  *	It does not free memory.
  */
-extern BOOL HTList_unlinkObject PARAMS((
-	HTList *	me,
-	void *		oldObject));
+    extern BOOL HTList_unlinkObject(HTList *me,
+				    void *oldObject);
 
-#endif /* HTLIST_H */
+#ifdef __cplusplus
+}
+#endif
+#endif				/* HTLIST_H */
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/HTStyle.h
+++ lynx-cur-2.8.6/WWW/Library/Implementation/HTStyle.h
@@ -1,32 +1,35 @@
 /*                                                       HTStyle: Style management for libwww
                               STYLE DEFINITION FOR HYPERTEXT
 
-   Styles allow the translation between a logical property of a piece of text and its
-   physical representation.
+   Styles allow the translation between a logical property of a piece of text
+   and its physical representation.
 
-   A StyleSheet is a collection of styles, defining the translation necessary to represent
-   a document.  It is a linked list of styles.
+   A StyleSheet is a collection of styles, defining the translation necessary
+   to represent a document.  It is a linked list of styles.
 
 Overriding this module
 
-   Why is the style structure declared in the HTStyle.h module, instead of having the user
-   browser define the structure, and the HTStyle routines just use sizeof() for copying?
-
-   It's not obvious whether HTStyle.c should be common code.  It's useful to have common
-   code for loading style sheets, especially if the movement toward standard style sheets
-   gets going.
-
-   If it IS common code, then both the hypertext object and HTStyle.c must know the
-   structure of a style, so HTStyle.h is a suitable place to put that.  HTStyle.c has to
-   be compiled with a knowledge of the
-
-   It we take it out of the library, then of course HTStyle could be declared as an
-   undefined structure.  The only references to it are in the structure-flattening code
-   HTML.c and HTPlain.c, which only use HTStypeNamed().
-
-   You can in any case override this function in your own code, which will prevent the
-   HTStyle from being loaded.  You will be able to redefine your style structure in this
-   case without problems, as no other moule needs to know it.
+   Why is the style structure declared in the HTStyle.h module, instead of
+   having the user browser define the structure, and the HTStyle routines just
+   use sizeof() for copying?
+
+   It's not obvious whether HTStyle.c should be common code.  It's useful to
+   have common code for loading style sheets, especially if the movement toward
+   standard style sheets gets going.
+
+   If it IS common code, then both the hypertext object and HTStyle.c must know
+   the structure of a style, so HTStyle.h is a suitable place to put that. 
+   HTStyle.c has to be compiled with a knowledge of the
+
+   It we take it out of the library, then of course HTStyle could be declared
+   as an undefined structure.  The only references to it are in the
+   structure-flattening code HTML.c and HTPlain.c, which only use
+   HTStypeNamed().
+
+   You can in any case override this function in your own code, which will
+   prevent the HTStyle from being loaded.  You will be able to redefine your
+   style structure in this case without problems, as no other moule needs to
+   know it.
 
  */
 #ifndef HTStyle_H
@@ -34,135 +37,132 @@
 
 #include <HTAnchor.h>
 
-typedef long int HTFont;        /* Dummy definition instead */
+typedef long int HTFont;	/* Dummy definition instead */
 
 #ifdef NeXT_suppressed
 #include <appkit/appkit.h>
 typedef NXCoord HTCoord;
+
 #define HTParagraphStyle NXTextStyle
 #define HTCoord NXCoord
 typedef struct _color {
-        float   grey;
-        int     RGBColor;
+    float grey;
+    int RGBColor;
 } HTColor;
+
 #else
 
 typedef int HTCoord;		/* changed from float to int - kw */
 
 typedef struct _HTParagraphStyle {
-    HTCoord     left_indent;            /* @@@@ junk! etc etc*/
+    HTCoord left_indent;	/* @@@@ junk! etc etc */
 } HTParagraphStyle;
 
-typedef int HTColor;            /* Sorry about the US spelling! */
+typedef int HTColor;		/* Sorry about the US spelling! */
 
 #endif
 
-
-
-#define STYLE_NAME_LENGTH       80      /* @@@@@@@@@@@ */
-
-typedef struct {
-    short               kind;           /* only NX_LEFTTAB implemented*/
-    HTCoord             position;       /* x coordinate for stop */
-} HTTabStop;
-
+#ifdef __cplusplus
+extern "C" {
+#endif
+#define STYLE_NAME_LENGTH       80	/* @@@@@@@@@@@ */
+    typedef struct {
+	short kind;		/* only NX_LEFTTAB implemented */
+	HTCoord position;	/* x coordinate for stop */
+    } HTTabStop;
 
 /*      The Style Structure
-**      -------------------
-*/
+ *      -------------------
+ */
 
-typedef struct _HTStyle {
+    typedef struct _HTStyle {
 
 /*      Style management information
 */
-    struct _HTStyle     *next;          /* Link for putting into stylesheet */
-    char *              name;           /* Style name */
-    int                 id;             /* equivalent of name, for speed */
-    char *              SGMLTag;        /* Tag name to start */
-
+	struct _HTStyle *next;	/* Link for putting into stylesheet */
+	char *name;		/* Style name */
+	int id;			/* equivalent of name, for speed */
+	char *SGMLTag;		/* Tag name to start */
 
 /*      Character attributes    (a la NXRun)
 */
-    HTFont              font;           /* Font id */
-    HTCoord             fontSize;       /* The size of font, not independent */
-    HTColor             color;		/* text gray of current run */
-    int                 superscript;    /* superscript (-sub) in points */
+	HTFont font;		/* Font id */
+	HTCoord fontSize;	/* The size of font, not independent */
+	HTColor color;		/* text gray of current run */
+	int superscript;	/* superscript (-sub) in points */
 
-    HTAnchor            *anchor;        /* Anchor id if any, else zero */
+	HTAnchor *anchor;	/* Anchor id if any, else zero */
 
 /*      Paragraph Attribtes     (a la NXTextStyle)
 */
-    HTCoord             indent1st;      /* how far first line in paragraph is
-                                 * indented */
-    HTCoord             leftIndent;     /* how far second line is indented */
-    HTCoord             rightIndent;    /* (Missing from NeXT version */
-    short               alignment;      /* quad justification */
-    HTCoord             lineHt;         /* line height */
-    HTCoord             descentLine;    /* descender bottom from baseline */
-    CONST HTTabStop     *tabs;          /* array of tab stops, 0 terminated */
-
-    BOOL                wordWrap;       /* Yes means wrap at space not char */
-    BOOL                freeFormat;     /* Yes means \n is just white space */
-    HTCoord             spaceBefore;    /* Omissions from NXTextStyle */
-    HTCoord             spaceAfter;
-    int                 paraFlags;      /* Paragraph flags, bits as follows: */
+	HTCoord indent1st;	/* how far first line in paragraph is
+				   * indented */
+	HTCoord leftIndent;	/* how far second line is indented */
+	HTCoord rightIndent;	/* (Missing from NeXT version */
+	short alignment;	/* quad justification */
+	HTCoord lineHt;		/* line height */
+	HTCoord descentLine;	/* descender bottom from baseline */
+	const HTTabStop *tabs;	/* array of tab stops, 0 terminated */
+
+	BOOL wordWrap;		/* Yes means wrap at space not char */
+	BOOL freeFormat;	/* Yes means \n is just white space */
+	HTCoord spaceBefore;	/* Omissions from NXTextStyle */
+	HTCoord spaceAfter;
+	int paraFlags;		/* Paragraph flags, bits as follows: */
 
-#define PARA_KEEP       1       /* Do not break page within this paragraph */
-#define PARA_WITH_NEXT  2       /* Do not break page after this paragraph */
+#define PARA_KEEP       1	/* Do not break page within this paragraph */
+#define PARA_WITH_NEXT  2	/* Do not break page after this paragraph */
 
-#define HT_JUSTIFY 0            /* For alignment */
+#define HT_JUSTIFY 0		/* For alignment */
 #define HT_LEFT 1
 #define HT_RIGHT 2
 #define HT_CENTER 3
 
-} HTStyle;
+    } HTStyle;
 
 #define HT_ALIGN_NONE (-1)
 
 /*      Style functions:
 */
-extern HTStyle * HTStyleNew NOPARAMS;
-extern HTStyle * HTStyleNewNamed PARAMS ((CONST char * name));
-extern HTStyle * HTStyleFree PARAMS((HTStyle * self));
+    extern HTStyle *HTStyleNew(void);
+    extern HTStyle *HTStyleNewNamed(const char *name);
+    extern HTStyle *HTStyleFree(HTStyle *self);
+
 #ifdef SUPRESS
-extern HTStyle * HTStyleRead PARAMS((HTStyle * self, HTStream * stream));
-extern HTStyle * HTStyleWrite PARAMS((HTStyle * self, HTStream * stream));
+    extern HTStyle *HTStyleRead(HTStyle *self, HTStream *stream);
+    extern HTStyle *HTStyleWrite(HTStyle *self, HTStream *stream);
 #endif
 /*              Style Sheet
-**              -----------
-*/
-typedef struct _HTStyleSheet {
-        char *          name;
-        HTStyle *       styles;
-} HTStyleSheet;
-
+ *              -----------
+ */
+    typedef struct _HTStyleSheet {
+	char *name;
+	HTStyle *styles;
+    } HTStyleSheet;
 
 /*      Stylesheet functions:
 */
-extern HTStyleSheet * HTStyleSheetNew NOPARAMS;
-extern HTStyleSheet * HTStyleSheetFree PARAMS((HTStyleSheet * self));
-extern HTStyle * HTStyleNamed PARAMS((HTStyleSheet * self, CONST char * name));
-extern HTStyle * HTStyleForParagraph PARAMS((HTStyleSheet * self,
-        HTParagraphStyle * paraStyle));
-extern HTStyle * HTStyleMatching PARAMS((HTStyleSheet *self, HTStyle * style));
-/* extern HTStyle * HTStyleForRun PARAMS((HTStyleSheet *self, NXRun * run)); */
-extern HTStyleSheet * HTStyleSheetAddStyle PARAMS((HTStyleSheet * self,
-        HTStyle * style));
-extern HTStyleSheet * HTStyleSheetRemoveStyle PARAMS((HTStyleSheet * self,
-        HTStyle * style));
+    extern HTStyleSheet *HTStyleSheetNew(void);
+    extern HTStyleSheet *HTStyleSheetFree(HTStyleSheet *self);
+    extern HTStyle *HTStyleNamed(HTStyleSheet *self, const char *name);
+    extern HTStyle *HTStyleForParagraph(HTStyleSheet *self, HTParagraphStyle * paraStyle);
+    extern HTStyle *HTStyleMatching(HTStyleSheet *self, HTStyle *style);
+
+/* extern HTStyle * HTStyleForRun (HTStyleSheet *self, NXRun * run); */
+    extern HTStyleSheet *HTStyleSheetAddStyle(HTStyleSheet *self, HTStyle *style);
+    extern HTStyleSheet *HTStyleSheetRemoveStyle(HTStyleSheet *self, HTStyle *style);
+
 #ifdef SUPPRESS
-extern HTStyleSheet * HTStyleSheetRead PARAMS((HTStyleSheet * self,
-                                                HTStream * stream));
-extern HTStyleSheet * HTStyleSheetWrite PARAMS((HTStyleSheet * self,
-                                                HTStream * stream));
+    extern HTStyleSheet *HTStyleSheetRead(HTStyleSheet *self, HTStream *stream);
+    extern HTStyleSheet *HTStyleSheetWrite(HTStyleSheet *self, HTStream *stream);
 #endif
-#define CLEAR_POINTER ((void *)-1)      /* Pointer value means "clear me" */
+#define CLEAR_POINTER ((void *)-1)	/* Pointer value means "clear me" */
 
 /* DefaultStyle.c */
-extern HTStyleSheet * DefaultStyle PARAMS((HTStyle*** result_array));
+    extern HTStyleSheet *DefaultStyle(HTStyle ***result_array);
 
 /* enum, use this instead of HTStyle name comparisons */
-enum HTStyle_Enum {
+    enum HTStyle_Enum {
 	ST_Normal = 0,
 	ST_DivCenter,
 	ST_DivLeft,
@@ -213,6 +213,9 @@
 	ST_HeadingCenter,
 	ST_HeadingLeft,
 	ST_HeadingRight
-};
+    };
 
-#endif /* HTStyle_H */
+#ifdef __cplusplus
+}
+#endif
+#endif				/* HTStyle_H */
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/HTAnchor.h
+++ lynx-cur-2.8.6/WWW/Library/Implementation/HTAnchor.h
@@ -2,11 +2,11 @@
  */
 
 /*	Hypertext "Anchor" Object				     HTAnchor.h
-**	==========================
-**
-**	An anchor represents a region of a hypertext document which is linked
-**	to another anchor in the same or a different document.
-*/
+ *	==========================
+ *
+ *	An anchor represents a region of a hypertext document which is linked
+ *	to another anchor in the same or a different document.
+ */
 
 #ifndef HTANCHOR_H
 #define HTANCHOR_H
@@ -20,39 +20,39 @@
 #include <HTAtom.h>
 #include <UCDefs.h>
 
-/*			Main definition of anchor
-**			=========================
-*/
-
-typedef struct _HyperDoc HyperDoc;  /* Ready for forward references */
+typedef struct _HyperDoc HyperDoc;	/* Ready for forward references */
 typedef struct _HTAnchor HTAnchor;
 typedef struct _HTParentAnchor HTParentAnchor;
 typedef struct _HTParentAnchor0 HTParentAnchor0;
 
-/*	After definition of HTFormat: */
 #include <HTFormat.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+/*			Main definition of anchor
+ *			=========================
+				 */ struct _HTAnchor {
+	/* Generic anchor */
+	HTParentAnchor0 *parent;	/* Parent of this anchor (self for adults) */
+    };
 
-struct _HTAnchor {		/* Generic anchor */
-  HTParentAnchor0 * parent;	/* Parent of this anchor (self for adults) */
-};
-
-struct _HTParentAnchor0 {	/* One for adult_table,
+    struct _HTParentAnchor0 {	/* One for adult_table,
 				 * generally not used outside HTAnchor.c */
-  /* Common part from the generic anchor structure */
-  HTParentAnchor0 * parent;	/* (self) */
+	/* Common part from the generic anchor structure */
+	HTParentAnchor0 *parent;	/* (self) */
 
-  /* ParentAnchor0-specific information */
-  char		  * address;	/* Absolute address of this node */
-  HTParentAnchor  * info;	/* additional info, allocated on demand */
-
-  HTBTree *	children;	/* Subanchors <a name="tag">, sorted by tag */
-  HTList	sources;	/* List of anchors pointing to this, if any */
-
-  HTList	_add_adult;	/* - just a memory for list entry:) */
-  short		adult_hash;	/* adult list number */
-  BOOL		underway;	/* Document about to be attached to it */
-};
+	/* ParentAnchor0-specific information */
+	char *address;		/* Absolute address of this node */
+	HTParentAnchor *info;	/* additional info, allocated on demand */
+
+	HTBTree *children;	/* Subanchors <a name="tag">, sorted by tag */
+	HTList sources;		/* List of anchors pointing to this, if any */
+
+	HTList _add_adult;	/* - just a memory for list entry:) */
+	short adult_hash;	/* adult list number */
+	BOOL underway;		/* Document about to be attached to it */
+    };
 
 /*
  *  Separated from the above to save memory:  allocated on demand,
@@ -61,388 +61,348 @@
  *  [being precise, we currently allocate it before HTLoadDocument(),
  *  in HTAnchor_findAddress() and HTAnchor_parent()].
  */
-struct _HTParentAnchor {
-  /* Common part from the generic anchor structure */
-  HTParentAnchor0 * parent;	/* Parent of this anchor */
-
-  /* ParentAnchor-specific information */
-  HTList	children_notag;	/* Subanchors <a href=...>, tag is NULL */
-  HyperDoc *	document;	/* The document within which this is an anchor*/
-
-  char *	address;	/* parent->address, a pointer */
-  bstring *	post_data;	/* Posting data */
-  char *	post_content_type;  /* Type of post data */
-  char *	bookmark;	/* Bookmark filename */
-  HTFormat	format;		/* Pointer to node format descriptor */
-  char *	charset;	/* Pointer to character set (kludge, for now */
-  BOOL		isIndex;	/* Acceptance of a keyword search */
-  char *	isIndexAction;	/* URL of isIndex server */
-  char *	isIndexPrompt;	/* Prompt for isIndex query */
-  char *	title;		/* Title of document */
-  char *	owner;		/* Owner of document */
-  char *	RevTitle;	/* TITLE in REV="made" or REV="owner" LINK */
-  char *	citehost;	/* Citehost from REL="citehost" LINK */
+    struct _HTParentAnchor {
+	/* Common part from the generic anchor structure */
+	HTParentAnchor0 *parent;	/* Parent of this anchor */
+
+	/* ParentAnchor-specific information */
+	HTList children_notag;	/* Subanchors <a href=...>, tag is NULL */
+	HyperDoc *document;	/* The document within which this is an anchor */
+
+	char *address;		/* parent->address, a pointer */
+	bstring *post_data;	/* Posting data */
+	char *post_content_type;	/* Type of post data */
+	char *bookmark;		/* Bookmark filename */
+	HTFormat format;	/* Pointer to node format descriptor */
+	char *charset;		/* Pointer to character set (kludge, for now */
+	BOOL isIndex;		/* Acceptance of a keyword search */
+	char *isIndexAction;	/* URL of isIndex server */
+	char *isIndexPrompt;	/* Prompt for isIndex query */
+	char *title;		/* Title of document */
+	char *owner;		/* Owner of document */
+	char *RevTitle;		/* TITLE in REV="made" or REV="owner" LINK */
+	char *citehost;		/* Citehost from REL="citehost" LINK */
 #ifdef USE_COLOR_STYLE
-  char *	style;
+	char *style;
 #endif
 
-  HTList*	methods;	/* Methods available as HTAtoms */
-  void *	protocol;	/* Protocol object */
-  char *	physical;	/* Physical address */
-  BOOL		isISMAPScript;	/* Script for clickable image map */
-  BOOL		isHEAD;		/* Document is headers from a HEAD request */
-  BOOL		safe;			/* Safe */
+	HTList *methods;	/* Methods available as HTAtoms */
+	void *protocol;		/* Protocol object */
+	char *physical;		/* Physical address */
+	BOOL isISMAPScript;	/* Script for clickable image map */
+	BOOL isHEAD;		/* Document is headers from a HEAD request */
+	BOOL safe;		/* Safe */
 #ifdef USE_SOURCE_CACHE
-  char *	source_cache_file;
-  HTChunk *	source_cache_chunk;
+	char *source_cache_file;
+	HTChunk *source_cache_chunk;
+#endif
+	char *FileCache;	/* Path to a disk-cached copy (see src/HTFWriter.c) */
+	char *SugFname;		/* Suggested filename */
+	char *cache_control;	/* Cache-Control */
+	BOOL no_cache;		/* Cache-Control, Pragma or META "no-cache"? */
+	BOOL inBASE;		/* duplicated from HTStructured (HTML.c/h) */
+#ifdef EXP_HTTP_HEADERS
+	HTChunk http_headers;
 #endif
-  char *	FileCache;	/* Path to a disk-cached copy (see src/HTFWriter.c) */
-  char *	SugFname;	/* Suggested filename */
-  char *	cache_control;	/* Cache-Control */
-  BOOL		no_cache;	/* Cache-Control, Pragma or META "no-cache"? */
-  BOOL		inBASE;		/* duplicated from HTStructured (HTML.c/h) */
-  char *	content_type;		/* Content-Type */
-  char *	content_language;	/* Content-Language */
-  char *	content_encoding;	/* Compression algorithm */
-  char *	content_base;		/* Content-Base */
-  char *	content_disposition;	/* Content-Disposition */
-  char *	content_location;	/* Content-Location */
-  char *	content_md5;		/* Content-MD5 */
-  char *	message_id;		/* Message-ID */
-  char *	subject;		/* Subject */
-  int		content_length;		/* Content-Length */
-  char *	date;			/* Date */
-  char *	expires;		/* Expires */
-  char *	last_modified;		/* Last-Modified */
-  char *	ETag;			/* ETag (HTTP1.1 cache validator) */
-  char *	server;			/* Server */
-  UCAnchorInfo *UCStages;		/* chartrans stages */
-  HTList *	imaps;			/* client side image maps */
-};
-
-typedef HTAtom HTLinkType;
-
-typedef struct {
-  /* Common part from the generic anchor structure */
-  HTParentAnchor0 * parent;	/* Parent of this anchor */
-
-  /* ChildAnchor-specific information */
-  char *	tag;		/* #fragment,  relative to the parent */
-
-  HTAnchor *	dest;		/* The anchor to which this leads */
-  HTLinkType *	type;		/* Semantics of this link */
-
-  HTList	_add_children_notag;	/* - just a memory for list entry:) */
-  HTList	_add_sources;		/* - just a memory for list entry:) */
-} HTChildAnchor;
+	char *content_type_params;	/* Content-Type (with parameters if any) */
+	char *content_type;	/* Content-Type */
+	char *content_language;	/* Content-Language */
+	char *content_encoding;	/* Compression algorithm */
+	char *content_base;	/* Content-Base */
+	char *content_disposition;	/* Content-Disposition */
+	char *content_location;	/* Content-Location */
+	char *content_md5;	/* Content-MD5 */
+	char *message_id;	/* Message-ID */
+	char *subject;		/* Subject */
+	int content_length;	/* Content-Length */
+	char *date;		/* Date */
+	char *expires;		/* Expires */
+	char *last_modified;	/* Last-Modified */
+	char *ETag;		/* ETag (HTTP1.1 cache validator) */
+	char *server;		/* Server */
+	UCAnchorInfo *UCStages;	/* chartrans stages */
+	HTList *imaps;		/* client side image maps */
+    };
+
+    typedef HTAtom HTLinkType;
+
+    typedef struct {
+	/* Common part from the generic anchor structure */
+	HTParentAnchor0 *parent;	/* Parent of this anchor */
+
+	/* ChildAnchor-specific information */
+	char *tag;		/* #fragment,  relative to the parent */
+
+	HTAnchor *dest;		/* The anchor to which this leads */
+	HTLinkType *type;	/* Semantics of this link */
+
+	HTList _add_children_notag;	/* - just a memory for list entry:) */
+	HTList _add_sources;	/* - just a memory for list entry:) */
+    } HTChildAnchor;
 
 /*
-**  DocAddress structure is used for loading an absolute anchor with all
-**  needed information including posting data and post content type.
-*/
-typedef struct _DocAddress {
-    char *	address;
-    bstring *	post_data;
-    char *	post_content_type;
-    char *	bookmark;
-    BOOL	isHEAD;
-    BOOL	safe;
-} DocAddress;
+ *  DocAddress structure is used for loading an absolute anchor with all
+ *  needed information including posting data and post content type.
+ */
+    typedef struct _DocAddress {
+	char *address;
+	bstring *post_data;
+	char *post_content_type;
+	char *bookmark;
+	BOOL isHEAD;
+	BOOL safe;
+    } DocAddress;
 
 /* "internal" means "within the same document, with certainty". */
-extern HTLinkType * HTInternalLink;
+    extern HTLinkType *HTInternalLink;
 
 /*	Create or find a child anchor with a possible link
-**	--------------------------------------------------
-**
-**	Create new anchor with a given parent and possibly
-**	a name, and possibly a link to a _relatively_ named anchor.
-**	(Code originally in ParseHTML.h)
-*/
-extern HTChildAnchor * HTAnchor_findChildAndLink PARAMS((
-	HTParentAnchor * parent,	/* May not be 0 */
-	CONST char * tag,		/* May be "" or 0 */
-	CONST char * href,		/* May be "" or 0 */
-	HTLinkType * ltype));		/* May be 0 */
+ *	--------------------------------------------------
+ *
+ *	Create new anchor with a given parent and possibly
+ *	a name, and possibly a link to a _relatively_ named anchor.
+ *	(Code originally in ParseHTML.h)
+ */
+    extern HTChildAnchor *HTAnchor_findChildAndLink(HTParentAnchor *parent,	/* May not be 0 */
+						    const char *tag,	/* May be "" or 0 */
+						    const char *href,	/* May be "" or 0 */
+						    HTLinkType *ltype);		/* May be 0 */
 
 /*	Create new or find old parent anchor
-**	------------------------------------
-**
-**	This one is for a reference which is found in a document, and might
-**	not be already loaded.
-**	Note: You are not guaranteed a new anchor -- you might get an old one,
-**	like with fonts.
-*/
-extern HTParentAnchor * HTAnchor_findAddress PARAMS((
-	CONST DocAddress *	address));
+ *	------------------------------------
+ *
+ *	This one is for a reference which is found in a document, and might
+ *	not be already loaded.
+ *	Note: You are not guaranteed a new anchor -- you might get an old one,
+ *	like with fonts.
+ */
+    extern HTParentAnchor *HTAnchor_findAddress(const DocAddress *address);
 
 /*	Create new or find old named anchor - simple form
-**	-------------------------------------------------
-**
-**	Like the previous one, but simpler to use for simple cases.
-**	No post data etc. can be supplied. - kw
-*/
-extern HTParentAnchor * HTAnchor_findSimpleAddress PARAMS((
-	CONST char *	url));
+ *	-------------------------------------------------
+ *
+ *	Like the previous one, but simpler to use for simple cases.
+ *	No post data etc. can be supplied. - kw
+ */
+    extern HTParentAnchor *HTAnchor_findSimpleAddress(const char *url);
 
 /*	Delete an anchor and possibly related things (auto garbage collection)
-**	--------------------------------------------
-**
-**	The anchor is only deleted if the corresponding document is not loaded.
-**	All outgoing links from children are deleted, and children are
-**	removed from the sources lists of their targets.
-**	We also try to delete the targets whose documents are not loaded.
-**	If this anchor's sources list is empty, we delete it and its children.
-*/
-extern BOOL HTAnchor_delete PARAMS((
-	HTParentAnchor0 *	me));
+ *	--------------------------------------------
+ *
+ *	The anchor is only deleted if the corresponding document is not loaded.
+ *	All outgoing links from children are deleted, and children are
+ *	removed from the sources lists of their targets.
+ *	We also try to delete the targets whose documents are not loaded.
+ *	If this anchor's sources list is empty, we delete it and its children.
+ */
+    extern BOOL HTAnchor_delete(HTParentAnchor0 *me);
 
 /*
  *  Unnamed children (children_notag) have no sense without HText -
  *  delete them and their links if we are about to free HText.
  *  Document currently exists.  Called within HText_free().
  */
-extern void HTAnchor_delete_links PARAMS((
-	HTParentAnchor *	me));
+    extern void HTAnchor_delete_links(HTParentAnchor *me);
 
 #ifdef USE_SOURCE_CACHE
-extern void HTAnchor_clearSourceCache PARAMS((
-	HTParentAnchor *	me));
+    extern void HTAnchor_clearSourceCache(HTParentAnchor *me);
 #endif
 
 /*	Data access functions
-**	---------------------
-*/
-extern HTParentAnchor * HTAnchor_parent PARAMS((
-	HTAnchor *		me));
+ *	---------------------
+ */
+    extern HTParentAnchor *HTAnchor_parent(HTAnchor * me);
 
-extern void HTAnchor_setDocument PARAMS((
-	HTParentAnchor *	me,
-	HyperDoc *		doc));
+    extern void HTAnchor_setDocument(HTParentAnchor *me,
+				     HyperDoc *doc);
 
-extern HyperDoc * HTAnchor_document PARAMS((
-	HTParentAnchor *	me));
+    extern HyperDoc *HTAnchor_document(HTParentAnchor *me);
 
 /*	Returns the full URI of the anchor, child or parent
-**	as a malloc'd string to be freed by the caller.
-*/
-extern char * HTAnchor_address PARAMS((
-	HTAnchor *		me));
+ *	as a malloc'd string to be freed by the caller.
+ */
+    extern char *HTAnchor_address(HTAnchor * me);
 
-extern void HTAnchor_setFormat PARAMS((
-	HTParentAnchor *	me,
-	HTFormat		form));
+    extern void HTAnchor_setFormat(HTParentAnchor *me,
+				   HTFormat form);
 
-extern HTFormat HTAnchor_format PARAMS((
-	HTParentAnchor *	me));
+    extern HTFormat HTAnchor_format(HTParentAnchor *me);
 
-extern void HTAnchor_setIndex PARAMS((
-	HTParentAnchor *	me,
-	CONST char *		address));
+    extern void HTAnchor_setIndex(HTParentAnchor *me,
+				  const char *address);
 
-extern void HTAnchor_setPrompt PARAMS((
-	HTParentAnchor *	me,
-	CONST char *		prompt));
+    extern void HTAnchor_setPrompt(HTParentAnchor *me,
+				   const char *prompt);
 
-extern BOOL HTAnchor_isIndex PARAMS((
-	HTParentAnchor *	me));
+    extern BOOL HTAnchor_isIndex(HTParentAnchor *me);
 
-extern BOOL HTAnchor_isISMAPScript PARAMS((
-	HTAnchor *		me));
+    extern BOOL HTAnchor_isISMAPScript(HTAnchor * me);
 
 #if defined(USE_COLOR_STYLE)
-extern CONST char * HTAnchor_style PARAMS((
-	HTParentAnchor *	me));
+    extern const char *HTAnchor_style(HTParentAnchor *me);
 
-extern void HTAnchor_setStyle PARAMS((
-	HTParentAnchor *	me,
-	CONST char *		style));
+    extern void HTAnchor_setStyle(HTParentAnchor *me,
+				  const char *style);
 #endif
 
 /*	Title handling.
 */
-extern CONST char * HTAnchor_title PARAMS((
-	HTParentAnchor *	me));
+    extern const char *HTAnchor_title(HTParentAnchor *me);
 
-extern void HTAnchor_setTitle PARAMS((
-	HTParentAnchor *	me,
-	CONST char *		title));
-
-extern void HTAnchor_appendTitle PARAMS((
-	HTParentAnchor *	me,
-	CONST char *		title));
+    extern void HTAnchor_setTitle(HTParentAnchor *me,
+				  const char *title);
+
+    extern void HTAnchor_appendTitle(HTParentAnchor *me,
+				     const char *title);
 
 /*	Bookmark handling.
 */
-extern CONST char * HTAnchor_bookmark PARAMS((
-	HTParentAnchor *	me));
+    extern const char *HTAnchor_bookmark(HTParentAnchor *me);
 
-extern void HTAnchor_setBookmark PARAMS((
-	HTParentAnchor *	me,
-	CONST char *		bookmark));
+    extern void HTAnchor_setBookmark(HTParentAnchor *me,
+				     const char *bookmark);
 
 /*	Owner handling.
 */
-extern CONST char * HTAnchor_owner PARAMS((
-	HTParentAnchor *	me));
+    extern const char *HTAnchor_owner(HTParentAnchor *me);
 
-extern void HTAnchor_setOwner PARAMS((
-	HTParentAnchor *	me,
-	CONST char *		owner));
+    extern void HTAnchor_setOwner(HTParentAnchor *me,
+				  const char *owner);
 
 /*	TITLE handling in LINKs with REV="made" or REV="owner". - FM
 */
-extern CONST char * HTAnchor_RevTitle PARAMS((
-	HTParentAnchor *	me));
+    extern const char *HTAnchor_RevTitle(HTParentAnchor *me);
 
-extern void HTAnchor_setRevTitle PARAMS((
-	HTParentAnchor *	me,
-	CONST char *		title));
+    extern void HTAnchor_setRevTitle(HTParentAnchor *me,
+				     const char *title);
 
 /*	Citehost for bibp links from LINKs with REL="citehost". - RDC
 */
-extern CONST char * HTAnchor_citehost PARAMS((
-	HTParentAnchor *	me));
+    extern const char *HTAnchor_citehost(HTParentAnchor *me);
 
-extern void HTAnchor_setCitehost PARAMS((
-	HTParentAnchor *	me,
-	CONST char *		citehost));
+    extern void HTAnchor_setCitehost(HTParentAnchor *me,
+				     const char *citehost);
 
 /*	Suggested filename handling. - FM
-**	(will be loaded if we had a Content-Disposition
-**	 header or META element with filename=name.suffix)
+ *	(will be loaded if we had a Content-Disposition
+ *	 header or META element with filename=name.suffix)
+ */
+    extern const char *HTAnchor_SugFname(HTParentAnchor *me);
+
+/*	HTTP Headers.
 */
-extern CONST char * HTAnchor_SugFname PARAMS((
-	HTParentAnchor *	me));
+    extern const char *HTAnchor_http_headers(HTParentAnchor *me);
+
+/*	Content-Type handling (parameter list).
+*/
+    extern const char *HTAnchor_content_type_params(HTParentAnchor *me);
 
 /*	Content-Type handling. - FM
 */
-extern CONST char * HTAnchor_content_type PARAMS((
-	HTParentAnchor *	me));
+    extern const char *HTAnchor_content_type(HTParentAnchor *me);
 
 /*	Content-Encoding handling. - FM
-**	(will be loaded if we had a Content-Encoding
-**	 header.)
-*/
-extern CONST char * HTAnchor_content_encoding PARAMS((
-	HTParentAnchor *	me));
+ *	(will be loaded if we had a Content-Encoding
+ *	 header.)
+ */
+    extern const char *HTAnchor_content_encoding(HTParentAnchor *me);
 
 /*	Last-Modified header handling. - FM
 */
-extern CONST char * HTAnchor_last_modified PARAMS((
-	HTParentAnchor *	me));
+    extern const char *HTAnchor_last_modified(HTParentAnchor *me);
 
 /*	Date header handling. - FM
 */
-extern CONST char * HTAnchor_date PARAMS((
-	HTParentAnchor *	me));
+    extern const char *HTAnchor_date(HTParentAnchor *me);
 
 /*	Server header handling. - FM
 */
-extern CONST char * HTAnchor_server PARAMS((
-	HTParentAnchor *	me));
+    extern const char *HTAnchor_server(HTParentAnchor *me);
 
 /*	Safe header handling. - FM
 */
-extern BOOL HTAnchor_safe PARAMS((
-	HTParentAnchor *	me));
+    extern BOOL HTAnchor_safe(HTParentAnchor *me);
 
 /*	Content-Base header handling. - FM
 */
-extern CONST char * HTAnchor_content_base PARAMS((
-	HTParentAnchor *	me));
+    extern const char *HTAnchor_content_base(HTParentAnchor *me);
 
 /*	Content-Location header handling. - FM
 */
-extern CONST char * HTAnchor_content_location PARAMS((
-	HTParentAnchor *	me));
+    extern const char *HTAnchor_content_location(HTParentAnchor *me);
 
 /*	Message-ID, used for mail replies - kw
 */
-extern CONST char * HTAnchor_messageID PARAMS((
-	HTParentAnchor *	me));
+    extern const char *HTAnchor_messageID(HTParentAnchor *me);
 
-extern BOOL HTAnchor_setMessageID PARAMS((
-	HTParentAnchor *	me,
-	CONST char *		messageid));
+    extern BOOL HTAnchor_setMessageID(HTParentAnchor *me,
+				      const char *messageid);
 
 /*	Subject, used for mail replies - kw
 */
-extern CONST char * HTAnchor_subject PARAMS((
-	HTParentAnchor *	me));
+    extern const char *HTAnchor_subject(HTParentAnchor *me);
 
-extern BOOL HTAnchor_setSubject PARAMS((
-	HTParentAnchor *	me,
-	CONST char *		subject));
+    extern BOOL HTAnchor_setSubject(HTParentAnchor *me,
+				    const char *subject);
 
 /*	Manipulation of links
-**	---------------------
-*/
-extern HTAnchor * HTAnchor_followLink PARAMS((
-	HTChildAnchor *		me));
+ *	---------------------
+ */
+    extern HTAnchor *HTAnchor_followLink(HTChildAnchor *me);
 
-extern HTAnchor * HTAnchor_followTypedLink PARAMS((
-	HTChildAnchor *		me,
-	HTLinkType *		type));
+    extern HTAnchor *HTAnchor_followTypedLink(HTChildAnchor *me,
+					      HTLinkType *type);
 
 /*	Read and write methods
-**	----------------------
-*/
-extern HTList * HTAnchor_methods PARAMS((
-	HTParentAnchor *	me));
+ *	----------------------
+ */
+    extern HTList *HTAnchor_methods(HTParentAnchor *me);
 
 /*	Protocol
-**	--------
-*/
-extern void * HTAnchor_protocol PARAMS((
-	HTParentAnchor *	me));
+ *	--------
+ */
+    extern void *HTAnchor_protocol(HTParentAnchor *me);
 
-extern void HTAnchor_setProtocol PARAMS((
-	HTParentAnchor *	me,
-	void *			protocol));
+    extern void HTAnchor_setProtocol(HTParentAnchor *me,
+				     void *protocol);
 
 /*	Physical address
-**	----------------
-*/
-extern char * HTAnchor_physical PARAMS((
-	HTParentAnchor *	me));
+ *	----------------
+ */
+    extern char *HTAnchor_physical(HTParentAnchor *me);
+
+    extern void HTAnchor_setPhysical(HTParentAnchor *me,
+				     char *protocol);
+
+    extern LYUCcharset *HTAnchor_getUCInfoStage(HTParentAnchor *me,
+						int which_stage);
 
-extern void HTAnchor_setPhysical PARAMS((
-	HTParentAnchor *	me,
-	char *			protocol));
-
-extern LYUCcharset * HTAnchor_getUCInfoStage PARAMS((
-	HTParentAnchor *	me,
-	int			which_stage));
-
-extern int HTAnchor_getUCLYhndl PARAMS((
-	HTParentAnchor *	me,
-	int			which_stage));
-
-extern LYUCcharset * HTAnchor_setUCInfoStage PARAMS((
-	HTParentAnchor *	me,
-	int			LYhndl,
-	int			which_stage,
-	int			set_by));
-
-extern LYUCcharset * HTAnchor_setUCInfoStage PARAMS((
-	HTParentAnchor *	me,
-	int			LYhndl,
-	int			which_stage,
-	int			set_by));
-
-extern LYUCcharset * HTAnchor_resetUCInfoStage PARAMS((
-	HTParentAnchor *	me,
-	int			LYhndl,
-	int			which_stage,
-	int			set_by));
-
-extern LYUCcharset * HTAnchor_copyUCInfoStage PARAMS((
-	HTParentAnchor *	me,
-	int			to_stage,
-	int			from_stage,
-	int			set_by));
+    extern int HTAnchor_getUCLYhndl(HTParentAnchor *me,
+				    int which_stage);
 
-extern void ImageMapList_free PARAMS((HTList * list));
+    extern LYUCcharset *HTAnchor_setUCInfoStage(HTParentAnchor *me,
+						int LYhndl,
+						int which_stage,
+						int set_by);
 
-#endif /* HTANCHOR_H */
+    extern LYUCcharset *HTAnchor_setUCInfoStage(HTParentAnchor *me,
+						int LYhndl,
+						int which_stage,
+						int set_by);
+
+    extern LYUCcharset *HTAnchor_resetUCInfoStage(HTParentAnchor *me,
+						  int LYhndl,
+						  int which_stage,
+						  int set_by);
+
+    extern LYUCcharset *HTAnchor_copyUCInfoStage(HTParentAnchor *me,
+						 int to_stage,
+						 int from_stage,
+						 int set_by);
+
+    extern void ImageMapList_free(HTList *list);
+
+#ifdef __cplusplus
+}
+#endif
+#endif				/* HTANCHOR_H */
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/HTAtom.h
+++ lynx-cur-2.8.6/WWW/Library/Implementation/HTAtom.h
@@ -1,38 +1,54 @@
 /*  */
 
 /*                      Atoms: Names to numbers                 HTAtom.h
-**                      =======================
-**
-**      Atoms are names which are given representative pointer values
-**      so that they can be stored more efficiently, and compaisons
-**      for equality done more efficiently.
-**
-**      HTAtom_for(string) returns a representative value such that it
-**      will always (within one run of the program) return the same
-**      value for the same given string.
-**
-** Authors:
-**      TBL     Tim Berners-Lee, WorldWideWeb project, CERN
-**
-**      (c) Copyright CERN 1991 - See Copyright.html
-**
-*/
+ *                      =======================
+ *
+ *      Atoms are names which are given representative pointer values
+ *      so that they can be stored more efficiently, and compaisons
+ *      for equality done more efficiently.
+ *
+ *      HTAtom_for(string) returns a representative value such that it
+ *      will always (within one run of the program) return the same
+ *      value for the same given string.
+ *
+ * Authors:
+ *      TBL     Tim Berners-Lee, WorldWideWeb project, CERN
+ *
+ *      (c) Copyright CERN 1991 - See Copyright.html
+ *
+ */
 
 #ifndef HTATOM_H
 #define HTATOM_H
 
 #include <HTList.h>
 
-typedef struct _HTAtom HTAtom;
-struct _HTAtom {
-        HTAtom *        next;
-        char *          name;
-}; /* struct _HTAtom */
+#ifdef __cplusplus
+extern "C" {
+#endif
+    typedef struct _HTAtom HTAtom;
+
+    struct _HTAtom {
+	HTAtom *next;
+	char *name;
+    };				/* struct _HTAtom */
 
-
-PUBLIC HTAtom * HTAtom_for PARAMS((CONST char * string));
-PUBLIC HTList * HTAtom_templateMatches PARAMS((CONST char * templ));
+    extern HTAtom *HTAtom_for(const char *string);
+    extern HTList *HTAtom_templateMatches(const char *templ);
 
 #define HTAtom_name(a) ((a)->name)
 
-#endif  /* HTATOM_H */
+/*
+
+The HTFormat type
+
+   We use the HTAtom object for holding representations.  This allows faster manipulation
+   (comparison and copying) that if we stayed with strings.
+
+ */
+    typedef HTAtom *HTFormat;
+
+#ifdef __cplusplus
+}
+#endif
+#endif				/* HTATOM_H */
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/HTStream.h
+++ lynx-cur-2.8.6/WWW/Library/Implementation/HTStream.h
@@ -3,11 +3,11 @@
                                              
    A Stream object is something which accepts a stream of text.
    
-   The creation methods will vary on the type of Stream Object.   All creation methods
-   return a pointer to the stream type below.
+   The creation methods will vary on the type of Stream Object.  All creation
+   methods return a pointer to the stream type below.
    
-   As you can see, but the methods used to write to the stream and close it are pointed to
-   be the object itself.
+   As you can see, but the methods used to write to the stream and close it are
+   pointed to be the object itself.
    
  */
 #ifndef HTSTREAM_H
@@ -16,43 +16,42 @@
 #ifndef HTUTILS_H
 #include <HTUtils.h>
 #endif
- 
-typedef struct _HTStream HTStream;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+    typedef struct _HTStream HTStream;
 
 /*
 
-   These are the common methods of all streams.  They should be self-explanatory, except
-   for end_document which must be called before free.  It should be merged with free in
-   fact:  it should be dummy for new streams.
+   These are the common methods of all streams.  They should be
+   self-explanatory, except for end_document which must be called before free. 
+   It should be merged with free in fact:  it should be dummy for new streams.
    
-   The put_block method was write, but this upset systems which had macros for write().
+   The put_block method was write, but this upset systems which had macros for
+   write().
    
  */
-typedef struct _HTStreamClass {
+    typedef struct _HTStreamClass {
+
+	const char *name;	/* Just for diagnostics */
+
+	void (*_free) (HTStream *me);
 
-        char*  name;                            /* Just for diagnostics */
-                
-        void (*_free) PARAMS((
-                HTStream*       me));
-
-        void (*_abort) PARAMS((
-                HTStream*       me,
-                HTError         e));
-                
-        void (*put_character) PARAMS((
-                HTStream*       me,
-                char            ch));
-                                
-        void (*put_string) PARAMS((
-                HTStream*       me,
-                CONST char *    str));
-                
-        void (*put_block) PARAMS((
-                HTStream*       me,
-                CONST char *    str,
-                int             len));
+	void (*_abort) (HTStream *me,
+			HTError e);
 
-}HTStreamClass;
+	void (*put_character) (HTStream *me,
+			       char ch);
+
+	void (*put_string) (HTStream *me,
+			    const char *str);
+
+	void (*put_block) (HTStream *me,
+			   const char *str,
+			   int len);
+
+    } HTStreamClass;
 
 /*
 
@@ -63,6 +62,9 @@
    example from the network.
 
  */
-extern HTStream * HTErrorStream NOPARAMS;
+    extern HTStream *HTErrorStream(void);
 
-#endif /* HTSTREAM_H */
+#ifdef __cplusplus
+}
+#endif
+#endif				/* HTSTREAM_H */
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/HTMLGen.h
+++ lynx-cur-2.8.6/WWW/Library/Implementation/HTMLGen.h
@@ -11,17 +11,18 @@
 #include <HTML.h>
 #include <HTStream.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
 /* Subclass:
-*/
-/* extern CONST HTStructuredClass HTMLGeneration; */
+*//* extern const HTStructuredClass HTMLGeneration; *//* Special Creation:
+ */ extern HTStructured *HTMLGenerator(HTStream *output);
 
-/* Special Creation:
-*/
-extern HTStructured * HTMLGenerator PARAMS((HTStream * output));
+    extern HTStream *HTPlainToHTML(HTPresentation *pres,
+				   HTParentAnchor *anchor,
+				   HTStream *sink);
 
-extern HTStream * HTPlainToHTML PARAMS((
-        HTPresentation *        pres,
-        HTParentAnchor *        anchor,
-        HTStream *              sink));
-
-#endif /* HTMLGEN_H */
+#ifdef __cplusplus
+}
+#endif
+#endif				/* HTMLGEN_H */
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/HTFWriter.h
+++ lynx-cur-2.8.6/WWW/Library/Implementation/HTFWriter.h
@@ -11,16 +11,20 @@
 #include <HTStream.h>
 #include <HTFormat.h>
 
-extern HTStream * HTFWriter_new PARAMS((FILE * fp));
+#ifdef __cplusplus
+extern "C" {
+#endif
+    extern HTStream *HTFWriter_new(FILE *fp);
 
-extern HTStream * HTSaveAndExecute PARAMS((
-        HTPresentation *        pres,
-        HTParentAnchor *        anchor, /* Not used */
-        HTStream *              sink));
+    extern HTStream *HTSaveAndExecute(HTPresentation *pres,
+				      HTParentAnchor *anchor,	/* Not used */
+				      HTStream *sink);
 
-extern HTStream * HTSaveLocally PARAMS((
-        HTPresentation *        pres,
-        HTParentAnchor *        anchor, /* Not used */
-        HTStream *              sink));
+    extern HTStream *HTSaveLocally(HTPresentation *pres,
+				   HTParentAnchor *anchor,	/* Not used */
+				   HTStream *sink);
 
-#endif /* HTFWRITE_H */
+#ifdef __cplusplus
+}
+#endif
+#endif				/* HTFWRITE_H */
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/HTPlain.h
+++ lynx-cur-2.8.6/WWW/Library/Implementation/HTPlain.h
@@ -8,9 +8,14 @@
 #include <HTStream.h>
 #include <HTAnchor.h>
 
-extern HTStream* HTPlainPresent PARAMS((
-        HTPresentation *        pres,
-        HTParentAnchor *        anchor,
-        HTStream *              sink));
+#ifdef __cplusplus
+extern "C" {
+#endif
+    extern HTStream *HTPlainPresent(HTPresentation *pres,
+				    HTParentAnchor *anchor,
+				    HTStream *sink);
 
-#endif /* HTPLAIN_H */
+#ifdef __cplusplus
+}
+#endif
+#endif				/* HTPLAIN_H */
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/HTChunk.h
+++ lynx-cur-2.8.6/WWW/Library/Implementation/HTChunk.h
@@ -16,19 +16,21 @@
 
 #include <UCMap.h>
 
-typedef struct {
-	int	size;		/* In bytes			*/
-	int	growby;		/* Allocation unit in bytes	*/
-	int	allocated;	/* Current size of *data	*/
-	char *	data;		/* Pointer to malloced area or 0 */
-	int	failok;		/* allowed to fail without exiting program? */
-} HTChunk;
-
+#ifdef __cplusplus
+extern "C" {
+#endif
+    typedef struct {
+	int size;		/* In bytes                     */
+	int growby;		/* Allocation unit in bytes     */
+	int allocated;		/* Current size of *data        */
+	char *data;		/* Pointer to malloc'd area or 0 */
+	int failok;		/* allowed to fail without exiting program? */
+    } HTChunk;
 
 /*
  * Initialize a chunk's allocation data and allocation-increment.
  */
-extern void HTChunkInit PARAMS((HTChunk * ch, int grow));
+    extern void HTChunkInit(HTChunk *ch, int grow);
 
 /*
  *
@@ -46,7 +48,7 @@
  *
  */
 
-extern HTChunk * HTChunkCreate PARAMS((int growby));
+    extern HTChunk *HTChunkCreate(int growby);
 
 /*
  *  Create a chunk for which an allocation error is not a fatal application
@@ -55,14 +57,13 @@
  *  are ok each time after data have been appended.
  *  The create call may also fail and will reurn NULL in that case. - kw
  */
-extern HTChunk * HTChunkCreateMayFail PARAMS((int growby, int failok));
+    extern HTChunk *HTChunkCreateMayFail(int growby, int failok);
 
 /*
  *  Like HTChunkCreate but with initial allocation - kw
  *
  */
-extern HTChunk * HTChunkCreate2 PARAMS((int growby, size_t needed));
-
+    extern HTChunk *HTChunkCreate2(int growby, size_t needed);
 
 /*
  *
@@ -78,8 +79,7 @@
  *
  */
 
-extern void HTChunkFree PARAMS((HTChunk * ch));
-
+    extern void HTChunkFree(HTChunk *ch);
 
 /*
  *
@@ -95,8 +95,7 @@
  *
  */
 
-extern void HTChunkClear PARAMS((HTChunk * ch));
-
+    extern void HTChunkClear(HTChunk *ch);
 
 /*
  *
@@ -114,8 +113,7 @@
  *
  */
 
-extern BOOL HTChunkRealloc PARAMS((HTChunk * ch, int growby));
-
+    extern BOOL HTChunkRealloc(HTChunk *ch, int growby);
 
 /*
  *
@@ -133,8 +131,7 @@
  *
  */
 
-extern void HTChunkEnsure PARAMS((HTChunk * ch, int s));
-
+    extern void HTChunkEnsure(HTChunk *ch, int s);
 
 /*
  *
@@ -151,11 +148,11 @@
  *   *ch		Is one character bigger
  *
  */
-extern void HTChunkPutc PARAMS((HTChunk * ch, char c));
+    extern void HTChunkPutc(HTChunk *ch, char c);
 
-extern void HTChunkPutb PARAMS((HTChunk * ch, CONST char *b, int l));
+    extern void HTChunkPutb(HTChunk *ch, const char *b, int l);
 
-extern void HTChunkPutUtf8Char PARAMS((HTChunk * ch, UCode_t code));
+    extern void HTChunkPutUtf8Char(HTChunk *ch, UCode_t code);
 
 /*
  * Append a string to a  chunk
@@ -172,9 +169,7 @@
  *
  */
 
-
-extern void HTChunkPuts PARAMS((HTChunk * ch, CONST char *str));
-
+    extern void HTChunkPuts(HTChunk *ch, const char *str);
 
 /*
  *
@@ -194,7 +189,9 @@
  *
  */
 
+    extern void HTChunkTerminate(HTChunk *ch);
 
-extern void HTChunkTerminate PARAMS((HTChunk * ch));
-
-#endif /* HTCHUNK_H */
+#ifdef __cplusplus
+}
+#endif
+#endif				/* HTCHUNK_H */
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/HTMLDTD.h
+++ lynx-cur-2.8.6/WWW/Library/Implementation/HTMLDTD.h
@@ -15,32 +15,29 @@
 #include <SGML.h>
 #include <HTFont.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
 /*
-**  Valid name chars for tag parsing.
-*/
+ *  Valid name chars for tag parsing.
+ */
 #define IsNmStart(c) (isalpha(UCH(c)))
 #define IsNmChar(c) (isalnum(UCH(c)) || \
 		      c == '_' || c=='-' || c == '.' || c==':')
-
-
 #define ReallyEmptyTagNum(e) ((HTML_dtd.tags[e].contents == SGML_EMPTY) && \
 			      !(HTML_dtd.tags[e].flags & Tgf_nreie))
 #define ReallyEmptyTag(t) ((t->contents == SGML_EMPTY) && \
 			   !(t->flags & Tgf_nreie))
-
 /*
 
 Element Numbers
 
- */
-
-/*
+ *//*
 
    Must Match all tables by element!
    These include tables in HTMLDTD.c and code in HTML.c.
 
- */
-typedef enum {
+ */ typedef enum {
 	HTML_A,
 	HTML_ABBREV,
 	HTML_ACRONYM,
@@ -159,7 +156,8 @@
 	HTML_VAR,
 	HTML_WBR,
 	HTML_XMP,
-	HTML_ALT_OBJECT } HTMLElement;
+	HTML_ALT_OBJECT
+    } HTMLElement;
 
 /* Notes: HTML.c uses a different extension of the HTML_ELEMENTS space
           privately, see HTNestedList.h. */
@@ -174,7 +172,6 @@
                       additional variant(s) at end. */
 #define HTML_ALL_ELEMENTS 119
 
-
 /*
 
 Attribute numbers
@@ -188,7 +185,7 @@
 
  */
 #define HTML_A_ACCESSKEY        0
-#define HTML_A_CHARSET          1 /* i18n draft, added tentatively - KW */
+#define HTML_A_CHARSET          1	/* i18n draft, added tentatively - KW */
 #define HTML_A_CLASS            2
 #define HTML_A_CLEAR            3
 #define HTML_A_COORDS           4
@@ -465,7 +462,7 @@
 #define HTML_FONT_STYLE         8
 #define HTML_FONT_ATTRIBUTES    9
 
-#define HTML_FORM_ACCEPT_CHARSET  0 /* HTML 4.0 draft - kw */
+#define HTML_FORM_ACCEPT_CHARSET  0	/* HTML 4.0 draft - kw */
 #define HTML_FORM_ACTION        1
 #define HTML_FORM_CLASS         2
 #define HTML_FORM_CLEAR         3
@@ -571,7 +568,7 @@
 #define HTML_IMG_ATTRIBUTES     19
 
 #define HTML_INPUT_ACCEPT       0
-#define HTML_INPUT_ACCEPT_CHARSET  1 /* RFC 2070 HTML i18n - kw */
+#define HTML_INPUT_ACCEPT_CHARSET  1	/* RFC 2070 HTML i18n - kw */
 #define HTML_INPUT_ALIGN        2
 #define HTML_INPUT_ALT          3
 #define HTML_INPUT_CHECKED      4
@@ -604,12 +601,12 @@
 #define HTML_INPUT_WIDTH       31
 #define HTML_INPUT_ATTRIBUTES  32
 
-#define HTML_ISINDEX_ACTION     0  /* Treat as synonym for HREF. - FM */
+#define HTML_ISINDEX_ACTION     0	/* Treat as synonym for HREF. - FM */
 #define HTML_ISINDEX_DIR        1
-#define HTML_ISINDEX_HREF       2  /* HTML 3.0 "action". - FM */
+#define HTML_ISINDEX_HREF       2	/* HTML 3.0 "action". - FM */
 #define HTML_ISINDEX_ID         3
 #define HTML_ISINDEX_LANG       4
-#define HTML_ISINDEX_PROMPT     5  /* HTML 3.0 "prompt". - FM */
+#define HTML_ISINDEX_PROMPT     5	/* HTML 3.0 "prompt". - FM */
 #define HTML_ISINDEX_TITLE      6
 #define HTML_ISINDEX_ATTRIBUTES 7
 
@@ -661,7 +658,7 @@
 #define HTML_LI_VALUE          12
 #define HTML_LI_ATTRIBUTES     13
 
-#define HTML_LINK_CHARSET       0 /* RFC 2070 HTML i18n - kw */
+#define HTML_LINK_CHARSET       0	/* RFC 2070 HTML i18n - kw */
 #define HTML_LINK_CLASS         1
 #define HTML_LINK_HREF          2
 #define HTML_LINK_ID            3
@@ -695,7 +692,7 @@
 #define HTML_MATH_ATTRIBUTES    8
 
 #define HTML_META_CONTENT       0
-#define HTML_META_HTTP_EQUIV    1  /* For parsing in HTML.c - FM */
+#define HTML_META_HTTP_EQUIV    1	/* For parsing in HTML.c - FM */
 #define HTML_META_NAME          2
 #define HTML_META_ATTRIBUTES    3
 
@@ -707,7 +704,7 @@
 #define HTML_NOTE_ID            3
 #define HTML_NOTE_LANG          4
 #define HTML_NOTE_MD            5
-#define HTML_NOTE_ROLE          6 /* Old name for CLASS - FM */
+#define HTML_NOTE_ROLE          6	/* Old name for CLASS - FM */
 #define HTML_NOTE_SRC           7
 #define HTML_NOTE_STYLE         8
 #define HTML_NOTE_TITLE         9
@@ -809,7 +806,7 @@
 #define HTML_PARAM_TITLE       13
 #define HTML_PARAM_TYPE        14
 #define HTML_PARAM_VALUE       15
-#define HTML_PARAM_VALUEREF    16  /* Use VALUETYPE (DATA|REF|OBJECT). - FM */
+#define HTML_PARAM_VALUEREF    16	/* Use VALUETYPE (DATA|REF|OBJECT). - FM */
 #define HTML_PARAM_VALUETYPE   17
 #define HTML_PARAM_ATTRIBUTES  18
 
@@ -918,7 +915,7 @@
 #define HTML_TD_WIDTH          19
 #define HTML_TD_ATTRIBUTES     20
 
-#define HTML_TEXTAREA_ACCEPT_CHARSET  0 /* RFC 2070 HTML i18n - kw */
+#define HTML_TEXTAREA_ACCEPT_CHARSET  0		/* RFC 2070 HTML i18n - kw */
 #define HTML_TEXTAREA_ALIGN     1
 #define HTML_TEXTAREA_CLASS     2
 #define HTML_TEXTAREA_CLEAR     3
@@ -973,19 +970,19 @@
 
 #ifdef USE_PRETTYSRC
 /* values of HTML attributes' types */
-#define HTMLA_NORMAL 0 /* nothing specific */
-#define HTMLA_ANAME  1 /* anchor name - 'id' or a's 'name' */
-#define HTMLA_HREF   2 /* href */
-#define HTMLA_CLASS  4 /* class name.  */
-#define HTMLA_AUXCLASS 8 /* attribute, the value of which also designates
-			    a class name */
+#define HTMLA_NORMAL 0		/* nothing specific */
+#define HTMLA_ANAME  1		/* anchor name - 'id' or a's 'name' */
+#define HTMLA_HREF   2		/* href */
+#define HTMLA_CLASS  4		/* class name.  */
+#define HTMLA_AUXCLASS 8	/* attribute, the value of which also designates
+				   a class name */
 #endif
-extern CONST SGML_dtd HTML_dtd;
+    extern const SGML_dtd HTML_dtd;
 
-extern void HTSwitchDTD PARAMS((int new_flag));
+    extern void HTSwitchDTD(int new_flag);
 
-extern HTTag HTTag_unrecognized;
-extern HTTag HTTag_mixedObject;
+    extern HTTag HTTag_unrecognized;
+    extern HTTag HTTag_mixedObject;
 
 /*
 
@@ -1002,17 +999,13 @@
    to be omitted.
 
  */
-extern void HTStartAnchor PARAMS((
-		HTStructured * targetstream,
-		CONST char *	name,
-		CONST char *	href));
-
-extern void HTStartAnchor5 PARAMS((
-		HTStructured * targetstream,
-		CONST char *	name,
-		CONST char *	href,
-		CONST char *	linktype,
-		int		tag_charset));
+    extern void HTStartAnchor(HTStructured * targetstream, const char *name,
+			      const char *href);
+
+    extern void HTStartAnchor5(HTStructured * targetstream, const char *name,
+			       const char *href,
+			       const char *linktype,
+			       int tag_charset);
 
 /*
 
@@ -1029,9 +1022,10 @@
    to be omitted.
 
  */
-extern void HTStartIsIndex PARAMS((
-		HTStructured * targetstream,
-		CONST char *	prompt,
-		CONST char *	href));
+    extern void HTStartIsIndex(HTStructured * targetstream, const char *prompt,
+			       const char *href);
 
-#endif /* HTMLDTD_H */
+#ifdef __cplusplus
+}
+#endif
+#endif				/* HTMLDTD_H */
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/SGML.h
+++ lynx-cur-2.8.6/WWW/Library/Implementation/SGML.h
@@ -21,151 +21,151 @@
 #include <HTAnchor.h>
 #include <LYJustify.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
 /*
 
 SGML content types
 
- */
-typedef enum {
-    SGML_EMPTY,	   /* No content. */
-    SGML_LITTERAL, /* Literal character data.  Recognize exact close tag only.
-		      Old www server compatibility only!  Not SGML */
-    SGML_CDATA,	   /* Character data.  Recognize </ only.
-		      (But we treat it just as SGML_LITTERAL.) */
-    SGML_SCRIPT,   /* Like CDATA, but allow it to be a comment */
-    SGML_RCDATA,   /* Replaceable character data. Should recognize </ and &ref;
-		      (but we treat it like SGML_MIXED for old times' sake). */
-    SGML_MIXED,	   /* Elements and parsed character data.
-		      Recognize all markup. */
-    SGML_ELEMENT,  /* Any data found should be regarded as an error.
-		      (But we treat it just like SGML_MIXED.) */
-    SGML_PCDATA	   /* Should contain no elements but &ref; is parsed.
-		      (We treat it like SGML_CDATA wrt. contained tags
-		      i.e. pass them on literally, i.e. like we should
-		      treat SGML_RCDATA) (added by KW). */
-} SGMLContent;
-
+ */ typedef enum {
+	SGML_EMPTY,		/* No content. */
+	SGML_LITTERAL,		/* Literal character data.  Recognize exact close tag only.
+				   Old www server compatibility only!  Not SGML */
+	SGML_CDATA,		/* Character data.  Recognize </ only.
+				   (But we treat it just as SGML_LITTERAL.) */
+	SGML_SCRIPT,		/* Like CDATA, but allow it to be a comment */
+	SGML_RCDATA,		/* Replaceable character data. Should recognize </ and &ref;
+				   (but we treat it like SGML_MIXED for old times' sake). */
+	SGML_MIXED,		/* Elements and parsed character data.
+				   Recognize all markup. */
+	SGML_ELEMENT,		/* Any data found should be regarded as an error.
+				   (But we treat it just like SGML_MIXED.) */
+	SGML_PCDATA		/* Should contain no elements but &ref; is parsed.
+				   (We treat it like SGML_CDATA wrt. contained tags
+				   i.e. pass them on literally, i.e. like we should
+				   treat SGML_RCDATA) (added by KW). */
+    } SGMLContent;
 
-typedef struct {
-    char *	name;		/* The (constant) name of the attribute */
+    typedef struct {
+	const char *name;	/* The name of the attribute */
 #ifdef USE_PRETTYSRC
-    char	type;		/* code of the type of the attribute. Code
+	char type;		/* code of the type of the attribute. Code
 				   values are in HTMLDTD.h */
 #endif
-} attr;
+    } attr;
+
+    typedef int TagClass;
 
-typedef int TagClass;
     /* textflow */
-#define Tgc_FONTlike	0x00001 /* S,STRIKE,I,B,TT,U,BIG,SMALL,STYLE,BLINK;BR,TAB */
-#define Tgc_EMlike	0x00002 /* EM,STRONG,DFN,CODE,SAMP,KBD,VAR,CITE,Q,INS,DEL,SPAN,.. */
-#define Tgc_MATHlike	0x00004 /* SUB,SUP,MATH,COMMENT */
-#define Tgc_Alike	0x00008 /* A */
-#define Tgc_formula	0x00010 /* not used until math is supported better... */
+#define Tgc_FONTlike	0x00001	/* S,STRIKE,I,B,TT,U,BIG,SMALL,STYLE,BLINK;BR,TAB */
+#define Tgc_EMlike	0x00002	/* EM,STRONG,DFN,CODE,SAMP,KBD,VAR,CITE,Q,INS,DEL,SPAN,.. */
+#define Tgc_MATHlike	0x00004	/* SUB,SUP,MATH,COMMENT */
+#define Tgc_Alike	0x00008	/* A */
+#define Tgc_formula	0x00010	/* not used until math is supported better... */
     /* used for special structures: forms, tables,... */
-#define Tgc_TRlike	0x00020 /* TR and similar */
-#define Tgc_SELECTlike	0x00040 /* SELECT,INPUT,TEXTAREA(,...) */
+#define Tgc_TRlike	0x00020	/* TR and similar */
+#define Tgc_SELECTlike	0x00040	/* SELECT,INPUT,TEXTAREA(,...) */
     /* structure */
-#define Tgc_FORMlike	0x00080 /* FORM itself */
-#define Tgc_Plike	0x00100 /* P,H1..H6,... structures containing text or
-				    insertion but not other structures */
-#define Tgc_DIVlike	0x00200 /* ADDRESS,FIG,BDO,NOTE,FN,DIV,CENTER;FIG
-				    structures which can contain other structures */
-#define Tgc_LIlike	0x00400 /* LH,LI,DT,DD;TH,TD structure-like, only valid
-				    within certain other structures */
-#define Tgc_ULlike	0x00800 /* UL,OL,DL,DIR,MENU;TABLE;XMP,LISTING
-				    special in some way, cannot contain (parsed)
-				    text directly */
+#define Tgc_FORMlike	0x00080	/* FORM itself */
+#define Tgc_Plike	0x00100	/* P,H1..H6,... structures containing text or
+				   insertion but not other structures */
+#define Tgc_DIVlike	0x00200	/* ADDRESS,FIG,BDO,NOTE,FN,DIV,CENTER;FIG
+				   structures which can contain other structures */
+#define Tgc_LIlike	0x00400	/* LH,LI,DT,DD;TH,TD structure-like, only valid
+				   within certain other structures */
+#define Tgc_ULlike	0x00800	/* UL,OL,DL,DIR,MENU;TABLE;XMP,LISTING
+				   special in some way, cannot contain (parsed)
+				   text directly */
     /* insertions */
-#define Tgc_BRlike	0x01000 /* BR,IMG,TAB allowed in any text */
-#define Tgc_APPLETlike	0x02000 /* APPLET,OBJECT,EMBED,SCRIPT;BUTTON */
-#define Tgc_HRlike	0x04000 /* HR,MARQUEE can contain all kinds of things
-				    and/or are not allowed (?) in running text */
-#define Tgc_MAPlike	0x08000 /* MAP,AREA some specials that never contain
-				    (directly or indirectly) other things than
-				    special insertions */
-#define Tgc_outer	0x10000 /* HTML,FRAMESET,FRAME,PLAINTEXT; */
-#define Tgc_BODYlike	0x20000 /* BODY,BODYTEXT,NOFRAMES,TEXTFLOW; */
-#define Tgc_HEADstuff	0x40000 /* HEAD,BASE,STYLE,TITLE; */
+#define Tgc_BRlike	0x01000	/* BR,IMG,TAB allowed in any text */
+#define Tgc_APPLETlike	0x02000	/* APPLET,OBJECT,EMBED,SCRIPT;BUTTON */
+#define Tgc_HRlike	0x04000	/* HR,MARQUEE can contain all kinds of things
+				   and/or are not allowed (?) in running text */
+#define Tgc_MAPlike	0x08000	/* MAP,AREA some specials that never contain
+				   (directly or indirectly) other things than
+				   special insertions */
+#define Tgc_outer	0x10000	/* HTML,FRAMESET,FRAME,PLAINTEXT; */
+#define Tgc_BODYlike	0x20000	/* BODY,BODYTEXT,NOFRAMES,TEXTFLOW; */
+#define Tgc_HEADstuff	0x40000	/* HEAD,BASE,STYLE,TITLE; */
     /* special relations */
 #define Tgc_same	0x80000
 
 /* Some more properties of tags (or rather, elements) and rules how
    to deal with them. - kw */
-typedef int TagFlags;
-#define Tgf_endO	0x00001 /* end tag can be Omitted */
-#define Tgf_startO	0x00002 /* start tag can be Omitted */
-#define Tgf_mafse	0x00004 /* Make Attribute-Free Start-tag End instead
-				      (if found invalid) */
-#define Tgf_strict	0x00008 /* Ignore contained invalid elements,
+    typedef int TagFlags;
+
+#define Tgf_endO	0x00001	/* end tag can be Omitted */
+#define Tgf_startO	0x00002	/* start tag can be Omitted */
+#define Tgf_mafse	0x00004	/* Make Attribute-Free Start-tag End instead
+				   (if found invalid) */
+#define Tgf_strict	0x00008	/* Ignore contained invalid elements,
 				   don't pass them on; or other variant
 				   handling for some content types */
-#define Tgf_nreie	0x00010 /* Not Really Empty If Empty,
-				      used by color style code */
-#define Tgf_frecyc	0x00020 /* Pass element content on in a form that
+#define Tgf_nreie	0x00010	/* Not Really Empty If Empty,
+				   used by color style code */
+#define Tgf_frecyc	0x00020	/* Pass element content on in a form that
 				   allows recycling, i.e. don't translate to
 				   output (display) character set yet (treat
 				   content similar to attribute values) */
-#define Tgf_nolyspcl	0x00040 /* Don't generate lynx special characters
+#define Tgf_nolyspcl	0x00040	/* Don't generate lynx special characters
 				   for soft hyphen and various spaces (nbsp,
 				   ensp,..) */
 
 /*		A tag structure describes an SGML element.
-**		-----------------------------------------
-**
-**
-**	name		is the string which comes after the tag opener "<".
-**
-**	attributes	points to a zero-terminated array
-**			of attribute names.
-**
-**	litteral	determines how the SGML engine parses the characters
-**			within the element.  If set, tag openers are ignored
-**			except for that which opens a matching closing tag.
-**
-*/
-typedef struct _tag HTTag;
-struct _tag{
-    char *	name;			/* The name of the tag */
+ *		-----------------------------------------
+ *
+ *
+ *	name		is the string which comes after the tag opener "<".
+ *
+ *	attributes	points to a zero-terminated array
+ *			of attribute names.
+ *
+ *	litteral	determines how the SGML engine parses the characters
+ *			within the element.  If set, tag openers are ignored
+ *			except for that which opens a matching closing tag.
+ *
+ */
+    typedef struct _tag HTTag;
+    struct _tag {
+	const char *name;	/* The name of the tag */
 #ifdef USE_COLOR_STYLE
-    int		name_len;		/* The length of the name */
+	int name_len;		/* The length of the name */
 #endif
 #ifdef EXP_JUSTIFY_ELTS
-    BOOL	can_justify;		/* justification allowed?*/
+	BOOL can_justify;	/* justification allowed? */
 #endif
-    attr *	attributes;		/* The list of acceptable attributes */
-    int		number_of_attributes;	/* Number of possible attributes */
-    SGMLContent contents;		/* End only on end tag @@ */
-    TagClass	tagclass,
-	contains,	/* which classes of elements this one can contain directly */
-	icontains,	/* which classes of elements this one can contain indirectly */
-	contained,	/* in which classes can this tag be contained ? */
-	icontained,	/* in which classes can this tag be indirectly contained ? */
-	canclose;	/* which classes of elements can this one close
-			   if something looks wrong ? */
-    TagFlags	flags;
-};
-
+	attr *attributes;	/* The list of acceptable attributes */
+	int number_of_attributes;	/* Number of possible attributes */
+	SGMLContent contents;	/* End only on end tag @@ */
+	TagClass tagclass;
+	TagClass contains;	/* which classes of elements this one can contain directly */
+	TagClass icontains;	/* which classes of elements this one can contain indirectly */
+	TagClass contained;	/* in which classes can this tag be contained ? */
+	TagClass icontained;	/* in which classes can this tag be indirectly contained ? */
+	TagClass canclose;	/* which classes of elements can this one close
+				   if something looks wrong ? */
+	TagFlags flags;
+    };
 
 /*		DTD Information
-**		---------------
-**
-**  Not the whole DTD, but all this parser uses of it.
-*/
-typedef struct {
-    HTTag *		tags;		/* Must be in strcmp order by name */
-    int			number_of_tags;
-    CONST char **	entity_names;	/* Must be in strcmp order by name */
-    size_t		number_of_entities;
-				/*  "entity_names" table probably unused,
-				**  see comments in HTMLDTD.c near the top
-				*/
-} SGML_dtd;
-
+ *		---------------
+ *
+ *  Not the whole DTD, but all this parser uses of it.
+ */
+    typedef struct {
+	HTTag *tags;		/* Must be in strcmp order by name */
+	int number_of_tags;
+	const char **entity_names;	/* Must be in strcmp order by name */
+	size_t number_of_entities;
+	/*  "entity_names" table probably unused,
+	 *  see comments in HTMLDTD.c near the top
+	 */
+    } SGML_dtd;
 
 /*	SGML context passed to parsers
 */
-typedef struct _HTSGMLContext *HTSGMLContext;	/* Hidden */
-
+    typedef struct _HTSGMLContext *HTSGMLContext;	/* Hidden */
 
 /*__________________________________________________________________________
 */
@@ -189,59 +189,44 @@
    Maybe the callerData is enough info to pass along.
 
  */
-typedef struct _HTStructured HTStructured;
+    typedef struct _HTStructured HTStructured;
+
+    typedef struct _HTStructuredClass {
+
+	const char *name;	/* Just for diagnostics */
+
+	void (*_free) (HTStructured * me);
+
+	void (*_abort) (HTStructured * me, HTError e);
+
+	void (*put_character) (HTStructured * me, char ch);
 
-typedef struct _HTStructuredClass{
+	void (*put_string) (HTStructured * me, const char *str);
 
-	char*  name;				/* Just for diagnostics */
+	void (*_write) (HTStructured * me, const char *str,
+			int len);
 
-	void (*_free) PARAMS((
-		HTStructured*	me));
+	int (*start_element) (HTStructured * me, int element_number,
+			      const BOOL *attribute_present,
+			      const char **attribute_value,
+			      int charset,
+			      char **include);
 
-	void (*_abort) PARAMS((
-		HTStructured*	me,
-		HTError		e));
-
-	void (*put_character) PARAMS((
-		HTStructured*	me,
-		char		ch));
-
-	void (*put_string) PARAMS((
-		HTStructured*	me,
-		CONST char *	str));
-
-	void (*_write) PARAMS((
-		HTStructured*	me,
-		CONST char *	str,
-		int		len));
-
-	int (*start_element) PARAMS((
-		HTStructured*	me,
-		int		element_number,
-		CONST BOOL*	attribute_present,
-		CONST char**	attribute_value,
-		int		charset,
-		char **		include));
-
-	int (*end_element) PARAMS((
-		HTStructured*	me,
-		int		element_number,
-		char **		include));
-
-	int (*put_entity) PARAMS((
-		HTStructured*	me,
-		int		entity_number));
+	int (*end_element) (HTStructured * me, int element_number,
+			    char **include);
 
-} HTStructuredClass;
+	int (*put_entity) (HTStructured * me, int entity_number);
+
+    } HTStructuredClass;
 
 /*
   Equivalents to the following functions possibly could be generalised
   into additional HTStructuredClass members.  For now they don't do
   anything target-specific. - kw
   */
-extern BOOLEAN LYCheckForCSI PARAMS((HTParentAnchor *anchor, char **url));
-extern void LYDoCSI PARAMS((char *url, CONST char *comment, char **csi));
-extern BOOLEAN LYCommentHacks PARAMS((HTParentAnchor *anchor, CONST char *comment));
+    extern BOOLEAN LYCheckForCSI(HTParentAnchor *anchor, char **url);
+    extern void LYDoCSI(char *url, const char *comment, char **csi);
+    extern BOOLEAN LYCommentHacks(HTParentAnchor *anchor, const char *comment);
 
 /*
 
@@ -250,10 +235,8 @@
    Returns a pointer to the tag within the DTD.
 
  */
-extern HTTag * SGMLFindTag PARAMS((
-	CONST SGML_dtd *	dtd,
-	CONST char *		string));
-
+    extern HTTag *SGMLFindTag(const SGML_dtd * dtd,
+			      const char *string);
 
 /*
 
@@ -261,18 +244,20 @@
 
  */
 /*
-** On entry,
-**	dtd		must point to a DTD structure as defined above
-**	callbacks	must point to user routines.
-**	callData	is returned in callbacks transparently.
-** On exit,
-**		The default tag starter has been processed.
-*/
-extern HTStream * SGML_new PARAMS((
-	CONST SGML_dtd *	dtd,
-	HTParentAnchor *	anchor,
-	HTStructured *		target));
+ * On entry,
+ *	dtd		must point to a DTD structure as defined above
+ *	callbacks	must point to user routines.
+ *	callData	is returned in callbacks transparently.
+ * On exit,
+ *		The default tag starter has been processed.
+ */
+    extern HTStream *SGML_new(const SGML_dtd * dtd,
+			      HTParentAnchor *anchor,
+			      HTStructured * target);
 
-extern CONST HTStreamClass SGMLParser;
+    extern const HTStreamClass SGMLParser;
 
-#endif	/* SGML_H */
+#ifdef __cplusplus
+}
+#endif
+#endif				/* SGML_H */
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/HTTCP.h
+++ lynx-cur-2.8.6/WWW/Library/Implementation/HTTCP.h
@@ -11,100 +11,100 @@
 #include <HTUtils.h>
 #endif
 
+#ifdef __cplusplus
+extern "C" {
+#endif
 /*      Produce a string for an internet address
-**      ---------------------------------------
-**
-** On exit:
-**           returns a pointer to a static string which must be copied if
-**                it is to be kept.
-*/
+ *      ---------------------------------------
+ *
+ * On exit:
+ *           returns a pointer to a static string which must be copied if
+ *                it is to be kept.
+ */
 #ifdef INET6
-extern CONST char * HTInetString PARAMS((SockA* mysin));
+    extern const char *HTInetString(SockA * mysin);
+
 #else
-extern CONST char * HTInetString PARAMS((struct sockaddr_in* mysin));
-#endif /* INET6 */
+    extern const char *HTInetString(struct sockaddr_in *mysin);
+#endif				/* INET6 */
 
 /*      Encode INET status (as in sys/errno.h)                    inet_status()
-**      ------------------
-**
-** On entry:
-**              where gives a description of what caused the error
-**      global errno gives the error number in the unix way.
-**
-** On return:
-**      returns a negative status in the unix way.
-*/
-#if defined(__STDC__) || defined(__BORLANDC__) || defined(_MSC_VER)
-        extern int HTInetStatus(char *where);
-#else
-        extern int HTInetStatus();
-#endif
+ *      ------------------
+ *
+ * On entry:
+ *              where gives a description of what caused the error
+ *      global errno gives the error number in the unix way.
+ *
+ * On return:
+ *      returns a negative status in the unix way.
+ */
+    extern int HTInetStatus(const char *where);
 
 /*      Publicly accessible variables
 */
 /* extern struct sockaddr_in HTHostAddress; */
-                        /* The internet address of the host */
-                        /* Valid after call to HTHostName() */
-
+    /* The internet address of the host */
+    /* Valid after call to HTHostName() */
 
 /*      Parse a cardinal value                                 parse_cardinal()
-**      ----------------------
-**
-** On entry:
-**      *pp points to first character to be interpreted, terminated by
-**      non 0..9 character.
-**      *pstatus points to status already valid,
-**      maxvalue gives the largest allowable value.
-**
-** On exit:
-**      *pp points to first unread character,
-**      *pstatus points to status updated iff bad
-*/
-
-extern unsigned int HTCardinal PARAMS((int *pstatus,
-                char            **pp,
-                unsigned int    max_value));
+ *      ----------------------
+ *
+ * On entry:
+ *      *pp points to first character to be interpreted, terminated by
+ *      non 0..9 character.
+ *      *pstatus points to status already valid,
+ *      maxvalue gives the largest allowable value.
+ *
+ * On exit:
+ *      *pp points to first unread character,
+ *      *pstatus points to status updated iff bad
+ */
+
+    extern unsigned int HTCardinal(int *pstatus,
+				   char **pp,
+				   unsigned int max_value);
 
 /*	Check whether string is a valid Internet hostname
-**	-------------------------------------------------
-*/
+ *	-------------------------------------------------
+ */
 
-extern BOOL valid_hostname PARAMS((char * name));
+    extern BOOL valid_hostname(char *name);
 
 /*	Resolve an internet hostname, like gethostbyname
-**	------------------------------------------------
-**
-**  On entry,
-**	str	points to the given host name, not numeric address,
-**		without colon or port number.
-**
-**  On exit,
-**	returns a pointer to a struct hostent in static storage,
-**	or NULL in case of error or user interruption.
-**
-**  The interface is intended to be the same as for gethostbyname(),
-**  but additional status is returned in lynx_nsl_status.
-*/
-extern int lynx_nsl_status;
+ *	------------------------------------------------
+ *
+ *  On entry,
+ *	str	points to the given host name, not numeric address,
+ *		without colon or port number.
+ *
+ *  On exit,
+ *	returns a pointer to a struct hostent in static storage,
+ *	or NULL in case of error or user interruption.
+ *
+ *  The interface is intended to be the same as for gethostbyname(),
+ *  but additional status is returned in lynx_nsl_status.
+ */
+    extern int lynx_nsl_status;
 
-extern struct hostent * LYGetHostByName PARAMS((char * str));
+    extern struct hostent *LYGetHostByName(char *str);
 
 /*      Get Name of This Machine
-**      ------------------------
-**
-*/
+ *      ------------------------
+ *
+ */
+
+    extern const char *HTHostName(void);
+
+    extern int HTDoConnect(const char *url,
+			   const char *protocol,
+			   int default_port,
+			   int *s);
+
+    extern int HTDoRead(int fildes,
+			void *buf,
+			unsigned nbyte);
 
-extern CONST char * HTHostName NOPARAMS;
-
-extern int HTDoConnect PARAMS((
-	CONST char *	url,
-	char *		protocol,
-	int		default_port,
-	int *		s));
-
-extern int HTDoRead PARAMS((
-	int		fildes,
-	void *		buf,
-	unsigned	nbyte));
-
-#endif   /* HTTCP_H */
+#ifdef __cplusplus
+}
+#endif
+#endif				/* HTTCP_H */
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/HTFTP.h
+++ lynx-cur-2.8.6/WWW/Library/Implementation/HTFTP.h
@@ -14,28 +14,28 @@
 #include <HTStream.h>
 #include <HTParse.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
 #define FILE_BY_NAME 0
 #define FILE_BY_TYPE 1
 #define FILE_BY_SIZE 2
 #define FILE_BY_DATE 3
-extern int HTfileSortMethod;  /* specifies the method of sorting */
-
+    extern int HTfileSortMethod;	/* specifies the method of sorting */
 
 /* PUBLIC						 HTVMS_name()
-**		CONVERTS WWW name into a VMS name
-** ON ENTRY:
-**	nn		Node Name (optional)
-**	fn		WWW file name
-**
-** ON EXIT:
-**	returns		vms file specification
-**
-** Bug:	Returns pointer to static -- non-reentrant
-*/
-PUBLIC char * HTVMS_name PARAMS((
-	CONST char * nn,
-	CONST char * fn));
-
+ *		CONVERTS WWW name into a VMS name
+ * ON ENTRY:
+ *	nn		Node Name (optional)
+ *	fn		WWW file name
+ *
+ * ON EXIT:
+ *	returns		vms file specification
+ *
+ * Bug:	Returns pointer to static -- non-reentrant
+ */
+    extern char *HTVMS_name(const char *nn,
+			    const char *fn);
 
 /*
 
@@ -46,25 +46,25 @@
   returns                 Socket number for file if good.<0 if bad.
 
  */
-extern int HTFTPLoad PARAMS
-((
-  CONST char *          name,
-  HTParentAnchor *      anchor,
-  HTFormat              format_out,
-  HTStream*             sink
-));
+    extern int HTFTPLoad(const char *name,
+			 HTParentAnchor *anchor,
+			 HTFormat format_out,
+			 HTStream *sink);
 
 /*
-**  This function frees any user entered password, so that
-**  it must be entered again for a future request. - FM
-*/
-extern void HTClearFTPPassword NOPARAMS;
+ *  This function frees any user entered password, so that
+ *  it must be entered again for a future request. - FM
+ */
+    extern void HTClearFTPPassword(void);
 
 /*
 
 Return Host Name
 
  */
-extern CONST char * HTHostName NOPARAMS;
+    extern const char *HTHostName(void);
 
+#ifdef __cplusplus
+}
+#endif
 #endif
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/HTBTree.h
+++ lynx-cur-2.8.6/WWW/Library/Implementation/HTBTree.h
@@ -16,54 +16,49 @@
 #include <HTUtils.h>
 #endif
 
+#ifdef __cplusplus
+extern "C" {
+#endif
 /*
 
 Data structures
 
- */
-typedef struct _HTBTree_element {
-    void                        *object;        /* User object */
-    struct _HTBTree_element     *up;
-    struct _HTBTree_element     *left;
-    int                         left_depth;
-    struct _HTBTree_element     *right;
-    int                         right_depth;
-} HTBTElement;
-
-typedef int (*HTComparer) PARAMS((void * a, void * b));
-
-typedef struct _HTBTree_top {
-    HTComparer                  compare;
-    struct _HTBTree_element     *top;
-} HTBTree;
-
+ */ typedef struct _HTBTree_element {
+	void *object;		/* User object */
+	struct _HTBTree_element *up;
+	struct _HTBTree_element *left;
+	int left_depth;
+	struct _HTBTree_element *right;
+	int right_depth;
+    } HTBTElement;
+
+    typedef int (*HTComparer) (void *a, void *b);
+
+    typedef struct _HTBTree_top {
+	HTComparer compare;
+	struct _HTBTree_element *top;
+    } HTBTree;
 
 /*
 
 Create a binary tree given its discrimination routine
 
  */
-extern HTBTree * HTBTree_new PARAMS((HTComparer comp));
-
-
+    extern HTBTree *HTBTree_new(HTComparer comp);
 
 /*
 
 Free storage of the tree but not of the objects
 
  */
-extern void HTBTree_free PARAMS((HTBTree* tree));
-
-
+    extern void HTBTree_free(HTBTree *tree);
 
 /*
 
 Free storage of the tree and of the objects
 
  */
-extern void HTBTreeAndObject_free PARAMS((HTBTree* tree));
-
-
+    extern void HTBTreeAndObject_free(HTBTree *tree);
 
 /*
 
@@ -71,8 +66,7 @@
 
  */
 
-extern void HTBTree_add PARAMS((HTBTree* tree, void * object));
-
+    extern void HTBTree_add(HTBTree *tree, void *object);
 
 /*
 
@@ -81,8 +75,7 @@
   returns          Pointer to equivalent object in a tree or NULL if none.
  */
 
-extern void * HTBTree_search PARAMS((HTBTree* tree, void * object));
-
+    extern void *HTBTree_search(HTBTree *tree, void *object);
 
 /*
 
@@ -91,7 +84,6 @@
  */
 #define HTBTree_object(element)  ((element)->object)
 
-
 /*
 
 Find next element in depth-first order
@@ -104,6 +96,9 @@
   returns                Pointer to element or NULL if none left.
 
  */
-extern HTBTElement * HTBTree_next PARAMS((HTBTree* tree, HTBTElement * ele));
+    extern HTBTElement *HTBTree_next(HTBTree *tree, HTBTElement *ele);
 
-#endif /* HTBTREE_H */
+#ifdef __cplusplus
+}
+#endif
+#endif				/* HTBTREE_H */
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/HTFile.h
+++ lynx-cur-2.8.6/WWW/Library/Implementation/HTFile.h
@@ -1,231 +1,239 @@
 /*							File access in libwww
-**				FILE ACCESS
-**
-**  These are routines for local file access used by WWW browsers and servers.
-**  Implemented by HTFile.c.
-**
-**  If the file is not a local file, then we pass it on to HTFTP in case it
-**  can be reached by FTP.
-*/
+ *				FILE ACCESS
+ *
+ *  These are routines for local file access used by WWW browsers and servers.
+ *  Implemented by HTFile.c.
+ *
+ *  If the file is not a local file, then we pass it on to HTFTP in case it
+ *  can be reached by FTP.
+ */
 #ifndef HTFILE_H
 #define HTFILE_H
 
 #include <HTFormat.h>
 #include <HTAccess.h>
+
 #ifndef HTML_H
-#include <HTML.h>               /* SCW */
+#include <HTML.h>		/* SCW */
 #endif /* HTML_H */
 
+#ifdef __cplusplus
+extern "C" {
+#endif
 /*
-**  Controlling globals
-**
-**  These flags control how directories and files are represented as
-**  hypertext, and are typically set by the application from command
-**  line options, etc.
-*/
-extern int HTDirAccess;         /* Directory access level */
-
-#define HT_DIR_FORBID           0       /* Altogether forbidden */
-#define HT_DIR_SELECTIVE        1       /* If HT_DIR_ENABLE_FILE exists */
-#define HT_DIR_OK               2       /* Any accesible directory */
-
-#define HT_DIR_ENABLE_FILE      ".www_browsable" /* If exists, can browse */
-
-extern int HTDirReadme;         /* Include readme files in listing? */
-                                        /* Values: */
-#define HT_DIR_README_NONE      0       /* No */
-#define HT_DIR_README_TOP       1       /* Yes, first */
-#define HT_DIR_README_BOTTOM    2       /* Yes, at the end */
+ *  Controlling globals
+ *
+ *  These flags control how directories and files are represented as
+ *  hypertext, and are typically set by the application from command
+ *  line options, etc.
+				 */ extern int HTDirAccess;
+    /* Directory access level */
+
+#define HT_DIR_FORBID           0	/* Altogether forbidden */
+#define HT_DIR_SELECTIVE        1	/* If HT_DIR_ENABLE_FILE exists */
+#define HT_DIR_OK               2	/* Any accesible directory */
+
+#define HT_DIR_ENABLE_FILE      ".www_browsable"	/* If exists, can browse */
+
+    extern int HTDirReadme;	/* Include readme files in listing? */
+
+    /* Values: */
+#define HT_DIR_README_NONE      0	/* No */
+#define HT_DIR_README_TOP       1	/* Yes, first */
+#define HT_DIR_README_BOTTOM    2	/* Yes, at the end */
 
 #define HT_DIR_README_FILE              "README"
 
 /*
-**  Convert filenames between local and WWW formats
-*/
-extern char * HTURLPath_toFile PARAMS((CONST char * name, BOOL expand_all, BOOL is_remote));
-extern char * HTnameOfFile_WWW PARAMS((CONST char * name, BOOL WWW_prefix, BOOL expand_all));
+ *  Convert filenames between local and WWW formats
+ */
+    extern char *HTURLPath_toFile(const char *name, BOOL expand_all, BOOL is_remote);
+    extern char *HTnameOfFile_WWW(const char *name, BOOL WWW_prefix, BOOL expand_all);
+
 #define HTLocalName(name)      HTnameOfFile_WWW(name,TRUE,TRUE)
 #define HTfullURL_toFile(name) HTnameOfFile_WWW(name,FALSE,TRUE)
 #define HTpartURL_toFile(name) HTnameOfFile_WWW(name,FALSE,FALSE)
 
 /*
-**  Make a WWW name from a full local path name
-*/
-extern char * WWW_nameOfFile PARAMS((CONST char * name));
-
-/*
-**  Generate the name of a cache file
-*/
-extern char * HTCacheFileName PARAMS((CONST char * name));
-
-/*
-**  Output directory titles
-**
-** This is (like the next one) used by HTFTP. It is common code to generate
-** the title and heading 1 and the parent directory link for any anchor.
-**
-** changed to return TRUE if parent directory link was generated,
-** FALSE otherwise - KW
-*/
-extern BOOL HTDirTitles PARAMS((
-        HTStructured *  target,
-        HTParentAnchor* anchor,
-	BOOL		tildeIsTop));
-
-/*
-**	Check existence.
-*/
-extern int HTStat PARAMS((
-	CONST char *	filename,
-	struct stat *	data));
+ *  Make a WWW name from a full local path name
+ */
+    extern char *WWW_nameOfFile(const char *name);
+
+/*
+ *  Generate the name of a cache file
+ */
+    extern char *HTCacheFileName(const char *name);
+
+/*
+ *  Output directory titles
+ *
+ * This is (like the next one) used by HTFTP. It is common code to generate
+ * the title and heading 1 and the parent directory link for any anchor.
+ *
+ * changed to return TRUE if parent directory link was generated,
+ * FALSE otherwise - KW
+ */
+    extern BOOL HTDirTitles(HTStructured * target, HTParentAnchor *anchor,
+			    BOOL tildeIsTop);
+
+/*
+ *	Check existence.
+ */
+    extern int HTStat(const char *filename,
+		      struct stat *data);
 
 /*	Load a document.
-**	----------------
-*/
-extern int HTLoadFile PARAMS((
-	CONST char *		addr,
-	HTParentAnchor *	anchor,
-	HTFormat		format_out,
-	HTStream *		sink));
-
-/*
-**  Output a directory entry
-**
-** This is used by HTFTP.c for example -- it is a common routine for
-**  generating a linked directory entry.
-*/
-extern void HTDirEntry PARAMS((
-        HTStructured *  target,         /* in which to put the linked text */
-        CONST char *    tail,           /* last part of directory name */
-        CONST char *    entry));        /* name of this entry */
-
-/*
-**  HTSetSuffix: Define the representation for a file suffix
-**
-**  This defines a mapping between local file suffixes and file content
-**  types and encodings.
-**
-**  ON ENTRY,
-**
-**  suffix		includes the "." if that is important (normally, yes!)
-**
-**  representation	is MIME-style content-type
-**
-**  encoding		is MIME-style content-transfer-encoding
-**			(8bit, 7bit, etc) or HTTP-style content-encoding
-**			(gzip, compress etc.)
-**
-**  quality		an a priori judgement of the quality of such files
-**			(0.0..1.0)
-**
-**  HTSetSuffix5 has one more parameter for a short description of the type
-**  which is otherwise derived from the representation:
-**
-**  desc		is a short textual description, or NULL
-**
-**  Examples:   HTSetSuffix(".ps", "application/postscript", "8bit", 1.0);
-**  Examples:   HTSetSuffix(".psz", "application/postscript", "gzip", 1.0);
-**  A MIME type could also indicate a non-trivial encoding on its own
-**  ("application/x-compressed-tar"), but in that case don't use enconding
-**  to also indicate it but use "binary" etc.
-*/
-extern void HTSetSuffix5 PARAMS((
-        CONST char *    suffix,
-        CONST char *    representation,
-        CONST char *    encoding,
-        CONST char *    desc,
-        double          quality));
+ *	----------------
+ */
+    extern int HTLoadFile(const char *addr,
+			  HTParentAnchor *anchor,
+			  HTFormat format_out,
+			  HTStream *sink);
+
+/*
+ *  Output a directory entry
+ *
+ * This is used by HTFTP.c for example -- it is a common routine for
+ *  generating a linked directory entry.
+ */
+    extern void HTDirEntry(HTStructured * target, /* in which to put the linked text */ const char *tail,	/* last part of directory name */
+			   const char *entry);	/* name of this entry */
+
+/*
+ *  HTSetSuffix: Define the representation for a file suffix
+ *
+ *  This defines a mapping between local file suffixes and file content
+ *  types and encodings.
+ *
+ *  ON ENTRY,
+ *
+ *  suffix		includes the "." if that is important (normally, yes!)
+ *
+ *  representation	is MIME-style content-type
+ *
+ *  encoding		is MIME-style content-transfer-encoding
+ *			(8bit, 7bit, etc) or HTTP-style content-encoding
+ *			(gzip, compress etc.)
+ *
+ *  quality		an a priori judgement of the quality of such files
+ *			(0.0..1.0)
+ *
+ *  HTSetSuffix5 has one more parameter for a short description of the type
+ *  which is otherwise derived from the representation:
+ *
+ *  desc		is a short textual description, or NULL
+ *
+ *  Examples:   HTSetSuffix(".ps", "application/postscript", "8bit", 1.0);
+ *  Examples:   HTSetSuffix(".psz", "application/postscript", "gzip", 1.0);
+ *  A MIME type could also indicate a non-trivial encoding on its own
+ *  ("application/x-compressed-tar"), but in that case don't use enconding
+ *  to also indicate it but use "binary" etc.
+ */
+    extern void HTSetSuffix5(const char *suffix,
+			     const char *representation,
+			     const char *encoding,
+			     const char *desc,
+			     double quality);
 
 #define HTSetSuffix(suff,rep,enc,q) HTSetSuffix5(suff, rep, enc, NULL, q)
 
 /*
-**  HTFileFormat: Get Representation and Encoding from file name.
-**
-**  ON EXIT,
-**
-**  return		The represntation it imagines the file is in.
-**
-**  *pEncoding		The encoding (binary, 7bit, etc). See HTSetSuffix.
-*/
-extern HTFormat HTFileFormat PARAMS((
-	CONST char *		filename,
-	HTAtom **		pEncoding,
-	CONST char **		pDesc));
-
-/*
-**  HTCharsetFormat: Revise the file format in relation to the Lynx charset.
-**
-**  This checks the format associated with an anchor for
-**  for an extended MIME Content-Type, and if a charset is
-**  indicated, sets Lynx up for proper handling in relation
-**  to the currently selected character set. - FM
-*/
-extern HTFormat HTCharsetFormat PARAMS((
-	HTFormat		format,
-	HTParentAnchor *	anchor,
-	int			default_LYhndl));
+ *  HTFileFormat: Get Representation and Encoding from file name.
+ *
+ *  ON EXIT,
+ *
+ *  return		The represntation it imagines the file is in.
+ *
+ *  *pEncoding		The encoding (binary, 7bit, etc). See HTSetSuffix.
+ */
+    extern HTFormat HTFileFormat(const char *filename,
+				 HTAtom **pEncoding,
+				 const char **pDesc);
+
+/*
+ *  HTCharsetFormat: Revise the file format in relation to the Lynx charset.
+ *
+ *  This checks the format associated with an anchor for
+ *  for an extended MIME Content-Type, and if a charset is
+ *  indicated, sets Lynx up for proper handling in relation
+ *  to the currently selected character set. - FM
+ */
+    extern HTFormat HTCharsetFormat(HTFormat format,
+				    HTParentAnchor *anchor,
+				    int default_LYhndl);
 
 /*	Get various pieces of meta info from file name.
-**	-----------------------------------------------
-**
-**  LYGetFileInfo fills in information that can be determined without
-**  an actual (new) access to the filesystem, based on current suffix
-**  and character set configuration.  If the file has been loaded and
-**  parsed before  (with the same URL generated here!) and the anchor
-**  is still around, some results may be influenced by that (in
-**  particular, charset info from a META tag - this is not actually
-**  tested!).
-**  The caller should not keep pointers to the returned objects around
-**  for too long, the valid lifetimes vary. In particular, the returned
-**  charset string should be copied if necessary.  If return of the
-**  file_anchor is requested, that one can be used to retrieve
-**  additional bits of info that are stored in the anchor object and
-**  are not covered here; as usual, don't keep pointers to the
-**  file_anchor longer than necessary since the object may disappear
-**  through HTuncache_current_document or at the next document load.
-**  - kw
-*/
-extern void LYGetFileInfo PARAMS((
-	CONST char *		filename,
-	HTParentAnchor **	pfile_anchor,
-	HTFormat *		pformat,
-	HTAtom **		pencoding,
-	CONST char**		pdesc,
-	CONST char**		pcharset,
-	int *			pfile_cs));
-
-/*
-**  Determine file value from file name.
-*/
-extern float HTFileValue PARAMS((
-	CONST char *	filename));
-
-/*
-**  Determine compression type from file name, by looking at its suffix.
-*/
-typedef enum {
-    cftNone
-    , cftCompress
-    , cftGzip
-    , cftBzip2
-} CompressFileType;
-
-extern CompressFileType HTCompressFileType PARAMS((
-	char *			filename,
-	char *			dots,
-	char **			suffix));
-
-/*
-**  Determine write access to a file.
-**
-**  ON EXIT,
-**
-**  return value	YES if file can be accessed and can be written to.
-**
-**  BUGS
-**
-**   Isn't there a quicker way?
-*/
+ *	-----------------------------------------------
+ *
+ *  LYGetFileInfo fills in information that can be determined without
+ *  an actual (new) access to the filesystem, based on current suffix
+ *  and character set configuration.  If the file has been loaded and
+ *  parsed before  (with the same URL generated here!) and the anchor
+ *  is still around, some results may be influenced by that (in
+ *  particular, charset info from a META tag - this is not actually
+ *  tested!).
+ *  The caller should not keep pointers to the returned objects around
+ *  for too long, the valid lifetimes vary. In particular, the returned
+ *  charset string should be copied if necessary.  If return of the
+ *  file_anchor is requested, that one can be used to retrieve
+ *  additional bits of info that are stored in the anchor object and
+ *  are not covered here; as usual, don't keep pointers to the
+ *  file_anchor longer than necessary since the object may disappear
+ *  through HTuncache_current_document or at the next document load.
+ *  - kw
+ */
+    extern void LYGetFileInfo(const char *filename,
+			      HTParentAnchor **pfile_anchor,
+			      HTFormat *pformat,
+			      HTAtom **pencoding,
+			      const char **pdesc,
+			      const char **pcharset,
+			      int *pfile_cs);
+
+/*
+ *  Determine file value from file name.
+ */
+    extern float HTFileValue(const char *filename);
+
+/*
+ *  Known compression types.
+ */
+    typedef enum {
+	cftNone
+	,cftCompress
+	,cftGzip
+	,cftBzip2
+	,cftDeflate
+    } CompressFileType;
+
+/*
+ *  Determine compression type from file name, by looking at its suffix.
+ */
+    extern CompressFileType HTCompressFileType(const char *filename,
+					       const char *dots,
+					       int *rootlen);
+
+/*
+ *  Determine compression type from the content-type.
+ */
+    extern CompressFileType HTContentToCompressType(const char *encoding);
+
+/*
+ *  Determine compression type from the content-encoding.
+ */
+    extern CompressFileType HTEncodingToCompressType(const char *encoding);
+
+/*
+ *  Determine write access to a file.
+ *
+ *  ON EXIT,
+ *
+ *  return value	YES if file can be accessed and can be written to.
+ *
+ *  BUGS
+ *
+ *   Isn't there a quicker way?
+ */
 
 #if defined(HAVE_CONFIG_H)
 
@@ -237,101 +245,102 @@
 
 #ifdef VMS
 #define NO_GROUPS
-#endif /* VMS */
+#endif				/* VMS */
 #ifdef NO_UNIX_IO
 #define NO_GROUPS
-#endif /* NO_UNIX_IO */
+#endif				/* NO_UNIX_IO */
 #ifdef PCNFS
 #define NO_GROUPS
-#endif /* PCNFS */
+#endif				/* PCNFS */
 #ifdef NOUSERS
 #define NO_GROUPS
-#endif /* PCNFS */
+#endif				/* PCNFS */
 
-#endif /* HAVE_CONFIG_H */
+#endif				/* HAVE_CONFIG_H */
 
-extern BOOL HTEditable PARAMS((CONST char * filename));
+    extern BOOL HTEditable(const char *filename);
 
 /*	Make a save stream.
-**	-------------------
-*/
-extern HTStream * HTFileSaveStream PARAMS((
-	HTParentAnchor *	anchor));
-
-/*
-** Determine a suitable suffix, given the representation.
-**
-**  ON ENTRY,
-**
-**  rep			is the atomized MIME style representation
-**  enc			is an encoding (8bit, binary, gzip, compress,..)
-**
-**  ON EXIT,
-**
-**  returns		a pointer to a suitable suffix string if one has
-**			been found, else NULL.
-*/
-extern CONST char * HTFileSuffix PARAMS((
-                HTAtom* rep,
-                CONST char* enc));
+ *	-------------------
+ */
+    extern HTStream *HTFileSaveStream(HTParentAnchor *anchor);
+
+/*
+ * Determine a suitable suffix, given the representation.
+ *
+ *  ON ENTRY,
+ *
+ *  rep			is the atomized MIME style representation
+ *  enc			is an encoding (8bit, binary, gzip, compress,..)
+ *
+ *  ON EXIT,
+ *
+ *  returns		a pointer to a suitable suffix string if one has
+ *			been found, else NULL.
+ */
+    extern const char *HTFileSuffix(HTAtom *rep,
+				    const char *enc);
 
 /*
  * Enumerate external programs that lynx may assume exists.  Unlike those
  * given in download scripts, etc., lynx would really like to know their
  * absolute paths, for better security.
  */
-typedef enum {
-    ppUnknown = 0
-    ,ppBZIP2
-    ,ppCHMOD
-    ,ppCOMPRESS
-    ,ppCOPY
-    ,ppCSWING
-    ,ppGZIP
-    ,ppINSTALL
-    ,ppMKDIR
-    ,ppMV
-    ,ppRLOGIN
-    ,ppRM
-    ,ppRMDIR
-    ,ppTAR
-    ,ppTELNET
-    ,ppTN3270
-    ,ppTOUCH
-    ,ppUNCOMPRESS
-    ,ppUNZIP
-    ,ppUUDECODE
-    ,ppZCAT
-    ,ppZIP
-    ,pp_Last
-} ProgramPaths;
+    typedef enum {
+	ppUnknown = 0
+	,ppBZIP2
+	,ppCHMOD
+	,ppCOMPRESS
+	,ppCOPY
+	,ppCSWING
+	,ppGZIP
+	,ppINFLATE
+	,ppINSTALL
+	,ppMKDIR
+	,ppMV
+	,ppRLOGIN
+	,ppRM
+	,ppRMDIR
+	,ppTAR
+	,ppTELNET
+	,ppTN3270
+	,ppTOUCH
+	,ppUNCOMPRESS
+	,ppUNZIP
+	,ppUUDECODE
+	,ppZCAT
+	,ppZIP
+	,pp_Last
+    } ProgramPaths;
 
 /*
  * Given a program number, return its path
  */
-extern CONST char * HTGetProgramPath PARAMS((
-		ProgramPaths code));
+    extern const char *HTGetProgramPath(ProgramPaths code);
 
 /*
  * Store a program's path 
  */
-extern void HTSetProgramPath PARAMS((
-		ProgramPaths code,
-		CONST char *path));
+    extern void HTSetProgramPath(ProgramPaths code,
+				 const char *path);
 
 /*
  * Reset the list of known program paths to the ones that are compiled-in
  */
-extern void HTInitProgramPaths NOPARAMS;
+    extern void HTInitProgramPaths(void);
 
 /*
-**  The Protocols
-*/
+ *  The Protocols
+ */
 #ifdef GLOBALREF_IS_MACRO
-extern GLOBALREF (HTProtocol,HTFTP);
-extern GLOBALREF (HTProtocol,HTFile);
+    extern GLOBALREF (HTProtocol, HTFTP);
+    extern GLOBALREF (HTProtocol, HTFile);
+
 #else
-GLOBALREF HTProtocol HTFTP, HTFile;
-#endif /* GLOBALREF_IS_MACRO */
+    GLOBALREF HTProtocol HTFTP, HTFile;
+#endif				/* GLOBALREF_IS_MACRO */
 
-#endif /* HTFILE_H */
+#ifdef __cplusplus
+}
+#endif
+#endif				/* HTFILE_H */
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/HTTP.h
+++ lynx-cur-2.8.6/WWW/Library/Implementation/HTTP.h
@@ -7,26 +7,33 @@
 
 #include <HTAccess.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
 #ifdef GLOBALREF_IS_MACRO
-extern GLOBALREF (HTProtocol,HTTP);
-extern GLOBALREF (HTProtocol,HTTPS);
+    extern GLOBALREF (HTProtocol, HTTP);
+    extern GLOBALREF (HTProtocol, HTTPS);
+
 #else
-GLOBALREF HTProtocol HTTP;
-GLOBALREF HTProtocol HTTPS;
-#endif /* GLOBALREF_IS_MACRO */
+    GLOBALREF HTProtocol HTTP;
+    GLOBALREF HTProtocol HTTPS;
+#endif				/* GLOBALREF_IS_MACRO */
 
 #define URL_GET_METHOD  1
 #define URL_POST_METHOD 2
 #define URL_MAIL_METHOD 3
 
-extern int ws_read_per_sec;
-extern BOOL reloading;
-extern char * redirecting_url;
-extern BOOL permanent_redirection;
-extern BOOL redirect_post_content;
+    extern int ws_read_per_sec;
+    extern BOOL reloading;
+    extern char *redirecting_url;
+    extern BOOL permanent_redirection;
+    extern BOOL redirect_post_content;
 
 #ifdef USE_SSL
-extern SSL * SSL_handle;
+    extern SSL *SSL_handle;
 #endif
 
-#endif /* HTTP_H */
+#ifdef __cplusplus
+}
+#endif
+#endif				/* HTTP_H */
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/HTAccess.h
+++ lynx-cur-2.8.6/WWW/Library/Implementation/HTAccess.h
@@ -11,22 +11,24 @@
 #ifndef HTACCESS_H
 #define HTACCESS_H
 
-extern char * use_this_url_instead;
-
-extern int redirection_attempts;
-
 /*      Definition uses:
 */
 #include <HTAnchor.h>
 #include <HTFormat.h>
 
-/*      Return codes from load routines:
-**
-**      These codes may be returned by the protocol modules,
-**      and by the HTLoad routines.
-**      In general, positive codes are OK and negative ones are bad.
-*/
+#ifdef __cplusplus
+extern "C" {
+#endif
+    extern char *use_this_url_instead;
 
+    extern int redirection_attempts;
+
+/*      Return codes from load routines:
+ *
+ *      These codes may be returned by the protocol modules,
+ *      and by the HTLoad routines.
+ *      In general, positive codes are OK and negative ones are bad.
+ */
 
 /*
 
@@ -36,10 +38,10 @@
    for user confusion.
 
  */
-#define LOGICAL_DEFAULT "WWW_HOME"  /* Defined to be the home page */
+#define LOGICAL_DEFAULT "WWW_HOME"	/* Defined to be the home page */
 
 #ifndef PERSONAL_DEFAULT
-#define PERSONAL_DEFAULT "WWW/default.html"     /* in home directory */
+#define PERSONAL_DEFAULT "WWW/default.html"	/* in home directory */
 #endif
 #ifndef LOCAL_DEFAULT_FILE
 #define LOCAL_DEFAULT_FILE "/usr/local/lib/WWW/default.html"
@@ -47,11 +49,11 @@
 /*  If one telnets to a www access point,
     it will look in this file for home page */
 #ifndef REMOTE_POINTER
-#define REMOTE_POINTER  "/etc/www-remote.url"  /* can't be file */
+#define REMOTE_POINTER  "/etc/www-remote.url"	/* can't be file */
 #endif
 /* and if that fails it will use this. */
 #ifndef REMOTE_ADDRESS
-#define REMOTE_ADDRESS  "http://www.w3.org/remote.html"  /* can't be file */
+#define REMOTE_ADDRESS  "http://www.w3.org/remote.html"		/* can't be file */
 #endif
 
 /* If run from telnet daemon and no -l specified, use this file:
@@ -66,39 +68,37 @@
 #define LAST_RESORT     "http://www.w3.org/default.html"
 #endif
 
-
 /*
 
 Flags which may be set to control this module
 
  */
 #ifdef NOT
-extern int HTDiag;                      /* Flag: load source as plain text */
-#endif /* NOT */
-extern char * HTClientHost;             /* Name or number of telnetting host */
-extern FILE * HTlogfile;                /* File to output one-liners to */
-extern BOOL HTSecure;                   /* Disable security holes? */
-extern BOOL HTPermitRedir;              /* Special flag for getfile() */
-extern HTStream* HTOutputStream;        /* For non-interactive, set this */
-extern HTFormat HTOutputFormat;         /* To convert on load, set this */
+    extern int HTDiag;		/* Flag: load source as plain text */
+#endif				/* NOT */
+    extern char *HTClientHost;	/* Name or number of telnetting host */
+    extern FILE *HTlogfile;	/* File to output one-liners to */
+    extern BOOL HTSecure;	/* Disable security holes? */
+    extern BOOL HTPermitRedir;	/* Special flag for getfile() */
+    extern HTStream *HTOutputStream;	/* For non-interactive, set this */
+    extern HTFormat HTOutputFormat;	/* To convert on load, set this */
 
 /*	Check for proxy override.			override_proxy()
-**
-**	Check the no_proxy environment variable to get the list
-**	of hosts for which proxy server is not consulted.
-**
-**	no_proxy is a comma- or space-separated list of machine
-**	or domain names, with optional :port part.  If no :port
-**	part is present, it applies to all ports on that domain.
-**
-**  Example:
-**          no_proxy="cern.ch,some.domain:8001"
-**
-**  Use "*" to override all proxy service:
-**	     no_proxy="*"
-*/
-extern BOOL override_proxy PARAMS((
-	CONST char *	addr));
+ *
+ *	Check the no_proxy environment variable to get the list
+ *	of hosts for which proxy server is not consulted.
+ *
+ *	no_proxy is a comma- or space-separated list of machine
+ *	or domain names, with optional :port part.  If no :port
+ *	part is present, it applies to all ports on that domain.
+ *
+ *  Example:
+ *          no_proxy="cern.ch,some.domain:8001"
+ *
+ *  Use "*" to override all proxy service:
+ *	     no_proxy="*"
+ */
+    extern BOOL override_proxy(const char *addr);
 
 /*
 
@@ -113,10 +113,8 @@
   NO                      Failure
 
  */
-extern  BOOL HTLoadRelative PARAMS((
-		CONST char *		relative_name,
-		HTParentAnchor *	here));
-
+    extern BOOL HTLoadRelative(const char *relative_name,
+			       HTParentAnchor *here);
 
 /*
 
@@ -131,8 +129,7 @@
   NO                      Failure
 
  */
-extern BOOL HTLoadAbsolute PARAMS((CONST DocAddress * addr));
-
+    extern BOOL HTLoadAbsolute(const DocAddress *addr);
 
 /*
 
@@ -149,9 +146,8 @@
    Note: This is equivalent to HTLoadDocument
 
  */
-extern BOOL HTLoadToStream PARAMS((CONST char * addr, BOOL filter_it,
-				HTStream * sink));
-
+    extern BOOL HTLoadToStream(const char *addr, BOOL filter_it,
+			       HTStream *sink);
 
 /*
 
@@ -165,8 +161,7 @@
   returns NO              Failure
 
  */
-extern BOOL HTLoadAnchor PARAMS((HTAnchor * destination));
-
+    extern BOOL HTLoadAnchor(HTAnchor * destination);
 
 /*
 
@@ -179,8 +174,7 @@
   returns                 0 if error else a stream to save the object to.
 
  */
-extern HTStream * HTSaveStream PARAMS((HTParentAnchor * anchor));
-
+    extern HTStream *HTSaveStream(HTParentAnchor *anchor);
 
 /*
 
@@ -194,8 +188,7 @@
   here                    The anchor of the object being searched
 
  */
-extern BOOL HTSearch PARAMS((CONST char * keywords, HTParentAnchor* here));
-
+    extern BOOL HTSearch(const char *keywords, HTParentAnchor *here);
 
 /*
 
@@ -209,10 +202,8 @@
   *indexname              is name of object search is to be done on.
 
  */
-extern BOOL HTSearchAbsolute PARAMS((
-	CONST char *	keywords,
-	char *		indexname));
-
+    extern BOOL HTSearchAbsolute(const char *keywords,
+				 char *indexname);
 
 /*
 
@@ -220,21 +211,19 @@
 
  */
 
-typedef struct _HTProtocol {
-	char * name;
+    typedef struct _HTProtocol {
+	const char *name;
 
-	int (*load)PARAMS((
-		CONST char *	full_address,
-		HTParentAnchor * anchor,
-		HTFormat	format_out,
-		HTStream*	sink));
+	int (*load) (const char *full_address,
+		     HTParentAnchor *anchor,
+		     HTFormat format_out,
+		     HTStream *sink);
 
-	HTStream* (*saveStream)PARAMS((HTParentAnchor * anchor));
+	HTStream *(*saveStream) (HTParentAnchor *anchor);
 
-} HTProtocol;
-
-extern BOOL HTRegisterProtocol PARAMS((HTProtocol * protocol));
+    } HTProtocol;
 
+    extern BOOL HTRegisterProtocol(HTProtocol * protocol);
 
 /*
 
@@ -248,26 +237,28 @@
    This is a default algorithm -- browser don't HAVE to use this.
 
  */
-extern HTParentAnchor * HTHomeAnchor NOPARAMS;
+    extern HTParentAnchor *HTHomeAnchor(void);
 
 /*
 
 Return Host Name
 
  */
-extern CONST char * HTHostName NOPARAMS;
+    extern const char *HTHostName(void);
 
 /*
 
 For registering protocols supported by Lynx
 
 */
-extern void LYRegisterLynxProtocols NOARGS;
+    extern void LYRegisterLynxProtocols(void);
 
-extern void LYUCPushAssumed PARAMS((
-    HTParentAnchor *	anchor));
-extern int LYUCPopAssumed NOPARAMS;
+    extern void LYUCPushAssumed(HTParentAnchor *anchor);
+    extern int LYUCPopAssumed(void);
 
-extern BOOL using_proxy;	/* Are we using an NNTP proxy? */
+    extern BOOL using_proxy;	/* Are we using an NNTP proxy? */
 
-#endif /* HTACCESS_H */
+#ifdef __cplusplus
+}
+#endif
+#endif				/* HTACCESS_H */
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/HTParse.h
+++ lynx-cur-2.8.6/WWW/Library/Implementation/HTParse.h
@@ -1,10 +1,10 @@
 /*                                   HTParse:  URL parsing in the WWW Library
-**				HTPARSE
-**
-**  This module of the WWW library contains code to parse URLs and various
-**  related things.
-**  Implemented by HTParse.c .
-*/
+ *				HTPARSE
+ *
+ *  This module of the WWW library contains code to parse URLs and various
+ *  related things.
+ *  Implemented by HTParse.c .
+ */
 #ifndef HTPARSE_H
 #define HTPARSE_H
 
@@ -12,187 +12,176 @@
 #include <HTUtils.h>
 #endif
 
+#ifdef __cplusplus
+extern "C" {
+#endif
 /*
-**  The following are flag bits which may be ORed together to form
-**  a number to give the 'wanted' argument to HTParse.
-*/
+ *  The following are flag bits which may be ORed together to form
+ *  a number to give the 'wanted' argument to HTParse.
+ */
 #define PARSE_ACCESS            16
 #define PARSE_HOST               8
 #define PARSE_PATH               4
 #define PARSE_ANCHOR             2
 #define PARSE_PUNCTUATION        1
-
 #define PARSE_ALL               31
 #define PARSE_ALL_WITHOUT_ANCHOR  (PARSE_ALL ^ PARSE_ANCHOR)
-
 /*
-**  Additional flag bits for more details on components already
-**  covered by the above.  The PARSE_PATH above doesn't really
-**  strictly refer to the path component in the sense of the URI
-**  specs only, but rather to that combined with a possible query
-**  component. - kw
-*/
+ *  Additional flag bits for more details on components already
+ *  covered by the above.  The PARSE_PATH above doesn't really
+ *  strictly refer to the path component in the sense of the URI
+ *  specs only, but rather to that combined with a possible query
+ *  component. - kw
+ */
 #define PARSE_STRICTPATH        32
 #define PARSE_QUERY             64
-
 /*
-**  The following are valid mask values.  The terms are the BNF names
-**  in the URL document.
-*/
+ *  The following are valid mask values.  The terms are the BNF names
+ *  in the URL document.
+ */
 #define URL_XALPHAS     UCH(1)
 #define URL_XPALPHAS    UCH(2)
 #define URL_PATH        UCH(4)
-
-
 /*	Strip white space off a string.				HTStrip()
-**	-------------------------------
-**
-** On exit,
-**	Return value points to first non-white character, or to 0 if none.
-**	All trailing white space is OVERWRITTEN with zero.
-*/
-extern char * HTStrip PARAMS((
-	char *		s));
+ *	-------------------------------
+ *
+ * On exit,
+ *	Return value points to first non-white character, or to 0 if none.
+ *	All trailing white space is OVERWRITTEN with zero.
+ */ extern char *HTStrip(char *s);
 
 /*	Parse a Name relative to another name.			HTParse()
-**	--------------------------------------
-**
-**	This returns those parts of a name which are given (and requested)
-**	substituting bits from the related name where necessary.
-**
-** On entry,
-**	aName		A filename given
-**      relatedName     A name relative to which aName is to be parsed
-**      wanted          A mask for the bits which are wanted.
-**
-** On exit,
-**	returns		A pointer to a malloc'd string which MUST BE FREED
-*/
-extern char * HTParse PARAMS((
-	CONST char *	aName,
-	CONST char *	relatedName,
-	int		wanted));
+ *	--------------------------------------
+ *
+ *	This returns those parts of a name which are given (and requested)
+ *	substituting bits from the related name where necessary.
+ *
+ * On entry,
+ *	aName		A filename given
+ *      relatedName     A name relative to which aName is to be parsed
+ *      wanted          A mask for the bits which are wanted.
+ *
+ * On exit,
+ *	returns		A pointer to a malloc'd string which MUST BE FREED
+ */
+    extern char *HTParse(const char *aName,
+			 const char *relatedName,
+			 int wanted);
 
 /*	HTParseAnchor(), fast HTParse() specialization
-**	----------------------------------------------
-**
-** On exit,
-**	returns		A pointer within input string (probably to its end '\0')
-*/
-extern CONST char * HTParseAnchor PARAMS((
-	CONST char *	aName));
+ *	----------------------------------------------
+ *
+ * On exit,
+ *	returns		A pointer within input string (probably to its end '\0')
+ */
+    extern const char *HTParseAnchor(const char *aName);
 
 /*	Simplify a filename.				HTSimplify()
-**	--------------------
-**
-**  A unix-style file is allowed to contain the seqeunce xxx/../ which may
-**  be replaced by "" , and the seqeunce "/./" which may be replaced by "/".
-**  Simplification helps us recognize duplicate filenames.
-**
-**	Thus,	/etc/junk/../fred	becomes /etc/fred
-**		/etc/junk/./fred	becomes	/etc/junk/fred
-**
-**      but we should NOT change
-**		http://fred.xxx.edu/../..
-**
-**	or	../../albert.html
-*/
-extern void HTSimplify PARAMS((
-	char *		filename));
+ *	--------------------
+ *
+ *  A unix-style file is allowed to contain the seqeunce xxx/../ which may
+ *  be replaced by "" , and the seqeunce "/./" which may be replaced by "/".
+ *  Simplification helps us recognize duplicate filenames.
+ *
+ *	Thus,	/etc/junk/../fred	becomes /etc/fred
+ *		/etc/junk/./fred	becomes	/etc/junk/fred
+ *
+ *      but we should NOT change
+ *		http://fred.xxx.edu/../..
+ *
+ *	or	../../albert.html
+ */
+    extern void HTSimplify(char *filename);
 
 /*	Make Relative Name.					HTRelative()
-**	-------------------
-**
-** This function creates and returns a string which gives an expression of
-** one address as related to another.  Where there is no relation, an absolute
-** address is retured.
-**
-**  On entry,
-**	Both names must be absolute, fully qualified names of nodes
-**	(no anchor bits)
-**
-**  On exit,
-**	The return result points to a newly allocated name which, if
-**	parsed by HTParse relative to relatedName, will yield aName.
-**	The caller is responsible for freeing the resulting name later.
-**
-*/
-extern char * HTRelative PARAMS((
-	CONST char *	aName,
-	CONST char *	relatedName));
+ *	-------------------
+ *
+ * This function creates and returns a string which gives an expression of
+ * one address as related to another.  Where there is no relation, an absolute
+ * address is retured.
+ *
+ *  On entry,
+ *	Both names must be absolute, fully qualified names of nodes
+ *	(no anchor bits)
+ *
+ *  On exit,
+ *	The return result points to a newly allocated name which, if
+ *	parsed by HTParse relative to relatedName, will yield aName.
+ *	The caller is responsible for freeing the resulting name later.
+ *
+ */
+    extern char *HTRelative(const char *aName,
+			    const char *relatedName);
 
 /*		Escape undesirable characters using %		HTEscape()
-**		-------------------------------------
-**
-**	This function takes a pointer to a string in which
-**	some characters may be unacceptable are unescaped.
-**	It returns a string which has these characters
-**	represented by a '%' character followed by two hex digits.
-**
-**	Unlike HTUnEscape(), this routine returns a malloc'd string.
-*/
-extern char * HTEscape PARAMS((
-	CONST char *	str,
-	unsigned char	mask));
+ *		-------------------------------------
+ *
+ *	This function takes a pointer to a string in which
+ *	some characters may be unacceptable are unescaped.
+ *	It returns a string which has these characters
+ *	represented by a '%' character followed by two hex digits.
+ *
+ *	Unlike HTUnEscape(), this routine returns a malloc'd string.
+ */
+    extern char *HTEscape(const char *str,
+			  unsigned char mask);
 
 /*		Escape unsafe characters using %		HTEscapeUnsafe()
-**		--------------------------------
-**
-**	This function takes a pointer to a string in which
-**	some characters may be that may be unsafe are unescaped.
-**	It returns a string which has these characters
-**	represented by a '%' character followed by two hex digits.
-**
-**	Unlike HTUnEscape(), this routine returns a malloc'd string.
-*/
-extern char * HTEscapeUnsafe PARAMS((
-	CONST char *	str));
+ *		--------------------------------
+ *
+ *	This function takes a pointer to a string in which
+ *	some characters may be that may be unsafe are unescaped.
+ *	It returns a string which has these characters
+ *	represented by a '%' character followed by two hex digits.
+ *
+ *	Unlike HTUnEscape(), this routine returns a malloc'd string.
+ */
+    extern char *HTEscapeUnsafe(const char *str);
 
 /*	Escape undesirable characters using % but space to +.	HTEscapeSP()
-**	-----------------------------------------------------
-**
-**	This function takes a pointer to a string in which
-**	some characters may be unacceptable are unescaped.
-**	It returns a string which has these characters
-**	represented by a '%' character followed by two hex digits,
-**	except that spaces are converted to '+' instead of %2B.
-**
-**	Unlike HTUnEscape(), this routine returns a malloc'd string.
-*/
-extern char * HTEscapeSP PARAMS((
-	CONST char *	str,
-	unsigned char	mask));
+ *	-----------------------------------------------------
+ *
+ *	This function takes a pointer to a string in which
+ *	some characters may be unacceptable are unescaped.
+ *	It returns a string which has these characters
+ *	represented by a '%' character followed by two hex digits,
+ *	except that spaces are converted to '+' instead of %2B.
+ *
+ *	Unlike HTUnEscape(), this routine returns a malloc'd string.
+ */
+    extern char *HTEscapeSP(const char *str,
+			    unsigned char mask);
 
 /*	Decode %xx escaped characters.				HTUnEscape()
-**	------------------------------
-**
-**	This function takes a pointer to a string in which some
-**	characters may have been encoded in %xy form, where xy is
-**	the acsii hex code for character 16x+y.
-**	The string is converted in place, as it will never grow.
-*/
-extern char * HTUnEscape PARAMS((
-	char *		str));
+ *	------------------------------
+ *
+ *	This function takes a pointer to a string in which some
+ *	characters may have been encoded in %xy form, where xy is
+ *	the acsii hex code for character 16x+y.
+ *	The string is converted in place, as it will never grow.
+ */
+    extern char *HTUnEscape(char *str);
 
 /*	Decode some %xx escaped characters.		      HTUnEscapeSome()
-**	-----------------------------------			Klaus Weide
-**							    (kweide@tezcat.com)
-**	This function takes a pointer to a string in which some
-**	characters may have been encoded in %xy form, where xy is
-**	the acsii hex code for character 16x+y, and a pointer to
-**	a second string containing one or more characters which
-**	should be unescaped if escaped in the first string.
-**	The first string is converted in place, as it will never grow.
-*/
-extern char * HTUnEscapeSome PARAMS((
-	char *		str,
-	CONST char *	do_trans));
+ *	-----------------------------------			Klaus Weide
+ *							    (kweide@tezcat.com)
+ *	This function takes a pointer to a string in which some
+ *	characters may have been encoded in %xy form, where xy is
+ *	the acsii hex code for character 16x+y, and a pointer to
+ *	a second string containing one or more characters which
+ *	should be unescaped if escaped in the first string.
+ *	The first string is converted in place, as it will never grow.
+ */
+    extern char *HTUnEscapeSome(char *str,
+				const char *do_trans);
 
 /*
-**  Turn a string which is not a RFC 822 token into a quoted-string. - KW
-*/
-extern void HTMake822Word PARAMS((
-	char **		str,
-	int		quoted));
+ *  Turn a string which is not a RFC 822 token into a quoted-string. - KW
+ */
+    extern void HTMake822Word(char **str,
+			      int quoted);
 
-#endif  /* HTPARSE_H */
+#ifdef __cplusplus
+}
+#endif
+#endif				/* HTPARSE_H */
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/HTUU.c
+++ lynx-cur-2.8.6/WWW/Library/Implementation/HTUU.c
@@ -1,59 +1,59 @@
 
 /* MODULE							HTUU.c
-**			UUENCODE AND UUDECODE
-**
-** ACKNOWLEDGEMENT:
-**	This code is taken from rpem distribution, and was originally
-**	written by Mark Riordan.
-**
-** AUTHORS:
-**	MR	Mark Riordan	riordanmr@clvax1.cl.msu.edu
-**	AL	Ari Luotonen	luotonen@dxcern.cern.ch
-**
-** HISTORY:
-**	Added as part of the WWW library and edited to conform
-**	with the WWW project coding standards by:	AL  5 Aug 1993
-**	Originally written by:				MR 12 Aug 1990
-**	Original header text:
-** -------------------------------------------------------------
-**  File containing routines to convert a buffer
-**  of bytes to/from RFC 1113 printable encoding format.
-**
-**  This technique is similar to the familiar Unix uuencode
-**  format in that it maps 6 binary bits to one ASCII
-**  character (or more aptly, 3 binary bytes to 4 ASCII
-**  characters).  However, RFC 1113 does not use the same
-**  mapping to printable characters as uuencode.
-**
-**  Mark Riordan   12 August 1990 and 17 Feb 1991.
-**  This code is hereby placed in the public domain.
-** -------------------------------------------------------------
-**
-** BUGS:
-**
-**
-*/
+ *			UUENCODE AND UUDECODE
+ *
+ * ACKNOWLEDGEMENT:
+ *	This code is taken from rpem distribution, and was originally
+ *	written by Mark Riordan.
+ *
+ * AUTHORS:
+ *	MR	Mark Riordan	riordanmr@clvax1.cl.msu.edu
+ *	AL	Ari Luotonen	luotonen@dxcern.cern.ch
+ *
+ * HISTORY:
+ *	Added as part of the WWW library and edited to conform
+ *	with the WWW project coding standards by:	AL  5 Aug 1993
+ *	Originally written by:				MR 12 Aug 1990
+ *	Original header text:
+ * -------------------------------------------------------------
+ *  File containing routines to convert a buffer
+ *  of bytes to/from RFC 1113 printable encoding format.
+ *
+ *  This technique is similar to the familiar Unix uuencode
+ *  format in that it maps 6 binary bits to one ASCII
+ *  character (or more aptly, 3 binary bytes to 4 ASCII
+ *  characters).  However, RFC 1113 does not use the same
+ *  mapping to printable characters as uuencode.
+ *
+ *  Mark Riordan   12 August 1990 and 17 Feb 1991.
+ *  This code is hereby placed in the public domain.
+ * -------------------------------------------------------------
+ *
+ * BUGS:
+ *
+ *
+ */
 
 #include <HTUtils.h>
 #include <HTUU.h>
 
 #include <LYLeaks.h>
 
-PRIVATE char six2pr[64] = {
-    'A','B','C','D','E','F','G','H','I','J','K','L','M',
-    'N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
-    'a','b','c','d','e','f','g','h','i','j','k','l','m',
-    'n','o','p','q','r','s','t','u','v','w','x','y','z',
-    '0','1','2','3','4','5','6','7','8','9','+','/'
+static char six2pr[64] =
+{
+    'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
+    'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
+    'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
+    'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
+    '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/'
 };
 
-PRIVATE unsigned char pr2six[256];
-
+static unsigned char pr2six[256];
 
 /*--- function HTUU_encode -----------------------------------------------
  *
- *   Encode a single line of binary data to a standard format that
- *   uses only printing ASCII characters (but takes up 33% more bytes).
+ * Encode a single line of binary data to a standard format that
+ * uses only printing ASCII characters (but takes up 33% more bytes).
  *
  *    Entry    bufin    points to a buffer of bytes.  If nbytes is not
  *                      a multiple of three, then the byte just beyond
@@ -70,45 +70,45 @@
  *                      The last byte is a zero byte.
  *             Returns the number of ASCII characters in "bufcoded".
  */
-PUBLIC int HTUU_encode ARGS3(unsigned char *,	bufin,
-			     unsigned int,	nbytes,
-			     char *,		bufcoded)
+int HTUU_encode(unsigned char *bufin,
+		unsigned int nbytes,
+		char *bufcoded)
 {
 /* ENC is the basic 1 character encoding function to make a char printing */
 #define ENC(c) six2pr[c]
 
-   register char *outptr = bufcoded;
-   unsigned int i;
-   /* This doesn't seem to be needed (AL):   register unsigned char *inptr  = bufin; */
-
-   for (i=0; i<nbytes; i += 3) {
-      *(outptr++) = ENC(*bufin >> 2);            /* c1 */
-      *(outptr++) = ENC(((*bufin << 4) & 060) | ((bufin[1] >> 4) & 017)); /*c2*/
-      *(outptr++) = ENC(((bufin[1] << 2) & 074) | ((bufin[2] >> 6) & 03));/*c3*/
-      *(outptr++) = ENC(bufin[2] & 077);         /* c4 */
-
-      bufin += 3;
-   }
-
-   /* If nbytes was not a multiple of 3, then we have encoded too
-    * many characters.  Adjust appropriately.
-    */
-   if(i == nbytes+1) {
-      /* There were only 2 bytes in that last group */
-      outptr[-1] = '=';
-   } else if(i == nbytes+2) {
-      /* There was only 1 byte in that last group */
-      outptr[-1] = '=';
-      outptr[-2] = '=';
-   }
-   *outptr = '\0';
-   return(outptr - bufcoded);
-}
+    register char *outptr = bufcoded;
+    unsigned int i;
+
+    /* This doesn't seem to be needed (AL):   register unsigned char *inptr  = bufin; */
 
+    for (i = 0; i < nbytes; i += 3) {
+	*(outptr++) = ENC(*bufin >> 2);		/* c1 */
+	*(outptr++) = ENC(((*bufin << 4) & 060) | ((bufin[1] >> 4) & 017));	/*c2 */
+	*(outptr++) = ENC(((bufin[1] << 2) & 074) | ((bufin[2] >> 6) & 03));	/*c3 */
+	*(outptr++) = ENC(bufin[2] & 077);	/* c4 */
+
+	bufin += 3;
+    }
+
+    /* If nbytes was not a multiple of 3, then we have encoded too
+     * many characters.  Adjust appropriately.
+     */
+    if (i == nbytes + 1) {
+	/* There were only 2 bytes in that last group */
+	outptr[-1] = '=';
+    } else if (i == nbytes + 2) {
+	/* There was only 1 byte in that last group */
+	outptr[-1] = '=';
+	outptr[-2] = '=';
+    }
+    *outptr = '\0';
+    return (outptr - bufcoded);
+}
 
 /*--- function HTUU_decode ------------------------------------------------
  *
- *  Decode an ASCII-encoded buffer back to its original binary form.
+ * Decode an ASCII-encoded buffer back to its original binary form.
  *
  *    Entry    bufcoded    points to a uuencoded string.  It is
  *                         terminated by any character not in
@@ -125,30 +125,33 @@
  *    Exit     Returns the number of binary bytes decoded.
  *             bufplain    contains these bytes.
  */
-PUBLIC int HTUU_decode ARGS3(char *,		bufcoded,
-			     unsigned char *,	bufplain,
-			     int,		outbufsize)
+int HTUU_decode(char *bufcoded,
+		unsigned char *bufplain,
+		int outbufsize)
 {
 /* single character decode */
 #define DEC(c) pr2six[(int)c]
 #define MAXVAL 63
 
-   static int first = 1;
+    static int first = 1;
 
-   int nbytesdecoded, j;
-   register char *bufin = bufcoded;
-   register unsigned char *bufout = bufplain;
-   register int nprbytes;
-
-   /* If this is the first call, initialize the mapping table.
-    * This code should work even on non-ASCII machines.
-    */
-   if(first) {
-      first = 0;
-      for(j=0; j<256; j++) pr2six[j] = MAXVAL+1;
+    int nbytesdecoded, j;
+    register char *bufin = bufcoded;
+    register unsigned char *bufout = bufplain;
+    register int nprbytes;
+
+    /* If this is the first call, initialize the mapping table.
+     * This code should work even on non-ASCII machines.
+     */
+    if (first) {
+	first = 0;
+	for (j = 0; j < 256; j++)
+	    pr2six[j] = MAXVAL + 1;
 
-      for(j=0; j<64; j++) pr2six[UCH(six2pr[j])] = UCH(j);
+	for (j = 0; j < 64; j++)
+	    pr2six[UCH(six2pr[j])] = UCH(j);
 #if 0
+      /* *INDENT-OFF* */
       pr2six['A']= 0; pr2six['B']= 1; pr2six['C']= 2; pr2six['D']= 3;
       pr2six['E']= 4; pr2six['F']= 5; pr2six['G']= 6; pr2six['H']= 7;
       pr2six['I']= 8; pr2six['J']= 9; pr2six['K']=10; pr2six['L']=11;
@@ -165,43 +168,45 @@
       pr2six['0']=52; pr2six['1']=53; pr2six['2']=54; pr2six['3']=55;
       pr2six['4']=56; pr2six['5']=57; pr2six['6']=58; pr2six['7']=59;
       pr2six['8']=60; pr2six['9']=61; pr2six['+']=62; pr2six['/']=63;
+      /* *INDENT-ON* */
+
 #endif
-   }
+    }
 
-   /* Strip leading whitespace. */
+    /* Strip leading whitespace. */
 
-   while(*bufcoded==' ' || *bufcoded == '\t') bufcoded++;
+    while (*bufcoded == ' ' || *bufcoded == '\t')
+	bufcoded++;
 
-   /* Figure out how many characters are in the input buffer.
-    * If this would decode into more bytes than would fit into
-    * the output buffer, adjust the number of input bytes downwards.
-    */
-   bufin = bufcoded;
-   while(pr2six[UCH(*(bufin++))] <= MAXVAL);
-   nprbytes = bufin - bufcoded - 1;
-   nbytesdecoded = ((nprbytes+3)/4) * 3;
-   if(nbytesdecoded > outbufsize) {
-      nprbytes = (outbufsize*4)/3;
-   }
-
-   bufin = bufcoded;
-
-   while (nprbytes > 0) {
-      *(bufout++) = UCH((DEC(bufin[0]) << 2) | (DEC(bufin[1]) >> 4));
-      *(bufout++) = UCH((DEC(bufin[1]) << 4) | (DEC(bufin[2]) >> 2));
-      *(bufout++) = UCH((DEC(bufin[2]) << 6) | (DEC(bufin[3])));
-      bufin += 4;
-      nprbytes -= 4;
-   }
-
-   if(nprbytes & 03) {
-      if(pr2six[(int)bufin[-2]] > MAXVAL) {
-	 nbytesdecoded -= 2;
-      } else {
-	 nbytesdecoded -= 1;
-      }
-   }
+    /* Figure out how many characters are in the input buffer.
+     * If this would decode into more bytes than would fit into
+     * the output buffer, adjust the number of input bytes downwards.
+     */
+    bufin = bufcoded;
+    while (pr2six[UCH(*(bufin++))] <= MAXVAL) ;
+    nprbytes = bufin - bufcoded - 1;
+    nbytesdecoded = ((nprbytes + 3) / 4) * 3;
+    if (nbytesdecoded > outbufsize) {
+	nprbytes = (outbufsize * 4) / 3;
+    }
+
+    bufin = bufcoded;
+
+    while (nprbytes > 0) {
+	*(bufout++) = UCH((DEC(bufin[0]) << 2) | (DEC(bufin[1]) >> 4));
+	*(bufout++) = UCH((DEC(bufin[1]) << 4) | (DEC(bufin[2]) >> 2));
+	*(bufout++) = UCH((DEC(bufin[2]) << 6) | (DEC(bufin[3])));
+	bufin += 4;
+	nprbytes -= 4;
+    }
+
+    if (nprbytes & 03) {
+	if (pr2six[(int) bufin[-2]] > MAXVAL) {
+	    nbytesdecoded -= 2;
+	} else {
+	    nbytesdecoded -= 1;
+	}
+    }
 
-   return(nbytesdecoded);
+    return (nbytesdecoded);
 }
-
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/HTLex.c
+++ lynx-cur-2.8.6/WWW/Library/Implementation/HTLex.c
@@ -1,57 +1,55 @@
 
 /* MODULE							HTLex.c
-**		LEXICAL ANALYSOR
-**
-** AUTHORS:
-**	AL	Ari Luotonen	luotonen@dxcern.cern.ch
-**
-** HISTORY:
-**
-**
-** BUGS:
-**
-**
-*/
+ *		LEXICAL ANALYSOR
+ *
+ * AUTHORS:
+ *	AL	Ari Luotonen	luotonen@dxcern.cern.ch
+ *
+ * HISTORY:
+ *
+ *
+ * BUGS:
+ *
+ *
+ */
 
 #include <HTUtils.h>
 
-#include <HTLex.h>	/* Implemented here */
+#include <HTLex.h>		/* Implemented here */
 
 #include <LYLeaks.h>
 
 /*
-** Global variables
-*/
-PUBLIC char HTlex_buffer[40];	/* Read lexical string		*/
-PUBLIC int HTlex_line = 1;	/* Line number in source file	*/
-
+ * Global variables
+ */
+char HTlex_buffer[40];		/* Read lexical string          */
+int HTlex_line = 1;		/* Line number in source file   */
 
 /*
-** Module-wide variables
-*/
-PRIVATE int lex_cnt;
-PRIVATE BOOL lex_template;
-PRIVATE LexItem lex_pushed_back = LEX_NONE;
-PRIVATE FILE *cache = NULL;
-
+ * Module-wide variables
+ */
+static int lex_cnt;
+static BOOL lex_template;
+static LexItem lex_pushed_back = LEX_NONE;
+static FILE *cache = NULL;
 
-PUBLIC void unlex ARGS1(LexItem, lex_item)
+void unlex(LexItem lex_item)
 {
     lex_pushed_back = lex_item;
 }
 
-
-PUBLIC LexItem lex ARGS1(FILE *, fp)
+LexItem lex(FILE *fp)
 {
     int ch = 0;
 
-    if (fp != cache) {	/* This cache doesn't work ok because the system  */
-	cache = fp;	/* often assign same FILE structure the next open */
-	HTlex_line = 1;	/* file.  So, if there are syntax errors in setup */
-    }			/* files it may confuse things later on.	  */
-
+    if (fp != cache) {		/* This cache doesn't work ok because the system  */
+	cache = fp;		/* often assign same FILE structure the next open */
+	HTlex_line = 1;		/* file.  So, if there are syntax errors in setup */
+    }
+    /* files it may confuse things later on.      */
     if (lex_pushed_back != LEX_NONE) {
 	LexItem ret = lex_pushed_back;
+
 	lex_pushed_back = LEX_NONE;
 	return ret;
     }
@@ -59,73 +57,82 @@
     lex_cnt = 0;
     lex_template = NO;
 
-    for(;;) {
+    for (;;) {
 	switch (ch = getc(fp)) {
-	  case EOF:
-	  case ' ':
-	  case '\t':
-	  case '\r':
-	  case '\n':
-	  case ':':
-	  case ',':
-	  case '(':
-	  case ')':
-	  case '@':
+	case EOF:
+	case ' ':
+	case '\t':
+	case '\r':
+	case '\n':
+	case ':':
+	case ',':
+	case '(':
+	case ')':
+	case '@':
 	    if (lex_cnt > 0) {
-		if (ch != EOF) ungetc(ch,fp);
-		if (lex_template) return LEX_TMPL_STR;
-		else		  return LEX_ALPH_STR;
-	    }
-	    else switch(ch) {
-	      case EOF:		return LEX_EOF;
-	      case '\n':
-		HTlex_line++;	return LEX_REC_SEP;
-	      case ':':		return LEX_FIELD_SEP;
-	      case ',':		return LEX_ITEM_SEP;
-	      case '(':		return LEX_OPEN_PAREN;
-	      case ')':		return LEX_CLOSE_PAREN;
-	      case '@':		return LEX_AT_SIGN;
-	      default:	;	/* Leading white space ignored (SP,TAB,CR) */
-	    }
+		if (ch != EOF)
+		    ungetc(ch, fp);
+		if (lex_template)
+		    return LEX_TMPL_STR;
+		else
+		    return LEX_ALPH_STR;
+	    } else
+		switch (ch) {
+		case EOF:
+		    return LEX_EOF;
+		case '\n':
+		    HTlex_line++;
+		    return LEX_REC_SEP;
+		case ':':
+		    return LEX_FIELD_SEP;
+		case ',':
+		    return LEX_ITEM_SEP;
+		case '(':
+		    return LEX_OPEN_PAREN;
+		case ')':
+		    return LEX_CLOSE_PAREN;
+		case '@':
+		    return LEX_AT_SIGN;
+		default:;	/* Leading white space ignored (SP,TAB,CR) */
+		}
 	    break;
-	  default:
+	default:
 	    HTlex_buffer[lex_cnt++] = (char) ch;
 	    HTlex_buffer[lex_cnt] = '\0';
-	    if ('*' == ch) lex_template = YES;
-	} /* switch ch */
-    } /* forever */
+	    if ('*' == ch)
+		lex_template = YES;
+	}			/* switch ch */
+    }				/* forever */
 }
 
-
-PUBLIC char *lex_verbose ARGS1(LexItem, lex_item)
+const char *lex_verbose(LexItem lex_item)
 {
     static char msg[100];	/* @@@@@@@@ */
 
     switch (lex_item) {
-      case LEX_NONE:		/* Internally used	*/
+    case LEX_NONE:		/* Internally used      */
 	return "NO-LEX-ITEM";
-      case LEX_EOF:		/* End of file		*/
+    case LEX_EOF:		/* End of file          */
 	return "end-of-file";
-      case LEX_REC_SEP:		/* Record separator	*/
+    case LEX_REC_SEP:		/* Record separator     */
 	return "record separator (newline)";
-      case LEX_FIELD_SEP:	/* Field separator	*/
+    case LEX_FIELD_SEP:	/* Field separator      */
 	return "field separator ':'";
-      case LEX_ITEM_SEP:	/* List item separator	*/
+    case LEX_ITEM_SEP:		/* List item separator  */
 	return "item separator ','";
-      case LEX_OPEN_PAREN:	/* Group start tag	*/
+    case LEX_OPEN_PAREN:	/* Group start tag      */
 	return "'('";
-      case LEX_CLOSE_PAREN:	/* Group end tag	*/
+    case LEX_CLOSE_PAREN:	/* Group end tag        */
 	return "')'";
-      case LEX_AT_SIGN:		/* Address qualifier	*/
+    case LEX_AT_SIGN:		/* Address qualifier    */
 	return "address qualifier '@'";
-      case LEX_ALPH_STR:	/* Alphanumeric string	*/
+    case LEX_ALPH_STR:		/* Alphanumeric string  */
 	sprintf(msg, "alphanumeric string '%.70s'", HTlex_buffer);
 	return msg;
-      case LEX_TMPL_STR:	/* Template string	*/
+    case LEX_TMPL_STR:		/* Template string      */
 	sprintf(msg, "template string '%.70s'", HTlex_buffer);
 	return msg;
-      default:
+    default:
 	return "UNKNOWN-LEX-ITEM";
     }
 }
-
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/HTAssoc.c
+++ lynx-cur-2.8.6/WWW/Library/Implementation/HTAssoc.c
@@ -1,20 +1,20 @@
 
 /* MODULE							HTAssoc.c
-**	    ASSOCIATION LIST FOR STORING NAME-VALUE PAIRS.
-**	    NAMES NOT CASE SENSITIVE, AND ONLY COMMON LENGTH
-**	    IS CHECKED (allows abbreviations; well, length is
-**	    taken from lookup-up name, so if table contains
-**	    a shorter abbrev it is not found).
-** AUTHORS:
-**	AL	Ari Luotonen	luotonen@dxcern.cern.ch
-**
-** HISTORY:
-**
-**
-** BUGS:
-**
-**
-*/
+ *	    ASSOCIATION LIST FOR STORING NAME-VALUE PAIRS.
+ *	    NAMES NOT CASE SENSITIVE, AND ONLY COMMON LENGTH
+ *	    IS CHECKED (allows abbreviations; well, length is
+ *	    taken from lookup-up name, so if table contains
+ *	    a shorter abbrev it is not found).
+ * AUTHORS:
+ *	AL	Ari Luotonen	luotonen@dxcern.cern.ch
+ *
+ * HISTORY:
+ *
+ *
+ * BUGS:
+ *
+ *
+ */
 
 #include <HTUtils.h>
 
@@ -22,18 +22,18 @@
 
 #include <LYLeaks.h>
 
-PUBLIC HTAssocList *HTAssocList_new NOARGS
+HTAssocList *HTAssocList_new(void)
 {
     return HTList_new();
 }
 
-
-PUBLIC void HTAssocList_delete ARGS1(HTAssocList *, alist)
+void HTAssocList_delete(HTAssocList *alist)
 {
     if (alist) {
 	HTAssocList *cur = alist;
 	HTAssoc *assoc;
-	while (NULL != (assoc = (HTAssoc*)HTList_nextObject(cur))) {
+
+	while (NULL != (assoc = (HTAssoc *) HTList_nextObject(cur))) {
 	    FREE(assoc->name);
 	    FREE(assoc->value);
 	    FREE(assoc);
@@ -43,16 +43,16 @@
     }
 }
 
-
-PUBLIC void HTAssocList_add ARGS3(HTAssocList *,	alist,
-				  CONST char *,		name,
-				  CONST char *,		value)
+void HTAssocList_add(HTAssocList *alist,
+		     const char *name,
+		     const char *value)
 {
     HTAssoc *assoc;
 
     if (alist) {
-	if (!(assoc = (HTAssoc*)malloc(sizeof(HTAssoc))))
-	    outofmem(__FILE__, "HTAssoc_add");
+	if (!(assoc = (HTAssoc *) malloc(sizeof(HTAssoc))))
+	      outofmem(__FILE__, "HTAssoc_add");
+
 	assoc->name = NULL;
 	assoc->value = NULL;
 
@@ -60,23 +60,21 @@
 	    StrAllocCopy(assoc->name, name);
 	if (value)
 	    StrAllocCopy(assoc->value, value);
-	HTList_addObject(alist, (void*)assoc);
+	HTList_addObject(alist, (void *) assoc);
     } else {
-        CTRACE((tfp, "HTAssoc_add: ERROR: assoc list NULL!!\n"));
+	CTRACE((tfp, "HTAssoc_add: ERROR: assoc list NULL!!\n"));
     }
 }
 
-
-PUBLIC char *HTAssocList_lookup ARGS2(HTAssocList *,	alist,
-				      CONST char *,	name)
+char *HTAssocList_lookup(HTAssocList *alist,
+			 const char *name)
 {
     HTAssocList *cur = alist;
     HTAssoc *assoc;
 
-    while (NULL != (assoc = (HTAssoc*)HTList_nextObject(cur))) {
+    while (NULL != (assoc = (HTAssoc *) HTList_nextObject(cur))) {
 	if (!strncasecomp(assoc->name, name, strlen(name)))
 	    return assoc->value;
     }
     return NULL;
 }
-
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/HTAAProt.c
+++ lynx-cur-2.8.6/WWW/Library/Implementation/HTAAProt.c
@@ -1,68 +1,70 @@
 
 /* MODULE							HTAAProt.c
-**		PROTECTION FILE PARSING MODULE
-**
-** AUTHORS:
-**	AL	Ari Luotonen	luotonen@dxcern.cern.ch
-**	MD	Mark Donszelmann    duns@vxdeop.cern.ch
-**
-** HISTORY:
-**	20 Oct 93  AL	Now finds uid/gid for nobody/nogroup by name
-**			(doesn't use default 65534 right away).
-**			Also understands negative uids/gids.
-**	14 Nov 93  MD	Added VMS compatibility
-**
-** BUGS:
-**
-**
-*/
+ *		PROTECTION FILE PARSING MODULE
+ *
+ * AUTHORS:
+ *	AL	Ari Luotonen	luotonen@dxcern.cern.ch
+ *	MD	Mark Donszelmann    duns@vxdeop.cern.ch
+ *
+ * HISTORY:
+ *	20 Oct 93  AL	Now finds uid/gid for nobody/nogroup by name
+ *			(doesn't use default 65534 right away).
+ *			Also understands negative uids/gids.
+ *	14 Nov 93  MD	Added VMS compatibility
+ *
+ * BUGS:
+ *
+ *
+ */
 
 #include <HTUtils.h>
 
 #ifndef VMS
 #ifndef NOUSERS
-#include <pwd.h>	/* Unix password file routine: getpwnam()	*/
-#include <grp.h>	/* Unix group file routine: getgrnam()		*/
+#include <pwd.h>		/* Unix password file routine: getpwnam()       */
+#include <grp.h>		/* Unix group file routine: getgrnam()          */
 #endif /* NOUSERS */
 #endif /* not VMS */
 
 #include <HTAAUtil.h>
-#include <HTLex.h>	/* Lexical analysor	*/
-#include <HTAAProt.h>	/* Implemented here	*/
+#include <HTLex.h>		/* Lexical analysor     */
+#include <HTAAProt.h>		/* Implemented here     */
 
 #include <LYUtils.h>
 #include <LYLeaks.h>
 
-#define NOBODY    65534	/* -2 in 16-bit environment */
-#define NONESUCH  65533	/* -3 in 16-bit environment */
+#define NOBODY    65534		/* -2 in 16-bit environment */
+#define NONESUCH  65533		/* -3 in 16-bit environment */
 
 /*
-** Protection setup caching
-*/
+ * Protection setup caching
+ */
 typedef struct {
-    char *	prot_filename;
-    HTAAProt *	prot;
+    char *prot_filename;
+    HTAAProt *prot;
 } HTAAProtCache;
 
-PRIVATE HTList *  prot_cache	= NULL;	/* Protection setup cache.	*/
-PRIVATE HTAAProt *default_prot	= NULL;	/* Default protection.		*/
-PRIVATE HTAAProt *current_prot	= NULL;	/* Current protection mode	*/
+static HTList *prot_cache = NULL;	/* Protection setup cache.      */
+static HTAAProt *default_prot = NULL;	/* Default protection.          */
+static HTAAProt *current_prot = NULL;	/* Current protection mode      */
+
 					/* which is set up by callbacks */
-					/* from the rule system when	*/
+					/* from the rule system when    */
 					/* a "protect" rule is matched. */
 
 #ifndef NOUSERS
-/* PRIVATE							isNumber()
-**		DOES A CHARACTER STRING REPRESENT A NUMBER
-*/
-PRIVATE BOOL isNumber ARGS1(CONST char *, s)
+/* static							isNumber()
+ *		DOES A CHARACTER STRING REPRESENT A NUMBER
+ */
+static BOOL isNumber(const char *s)
 {
-    CONST char *cur = s;
+    const char *cur = s;
 
-    if (isEmpty(s)) return NO;
+    if (isEmpty(s))
+	return NO;
 
     if (*cur == '-')
-	cur++;		/* Allow initial minus sign in a number */
+	cur++;			/* Allow initial minus sign in a number */
 
     while (*cur) {
 	if (*cur < '0' || *cur > '9')
@@ -73,136 +75,130 @@
 }
 #endif /* !NOUSERS */
 
-
 #if defined (NOUSERS)
 /* PUBLIC							HTAA_getUidName()
-**		GET THE USER ID NAME (VMS ONLY)
-** ON ENTRY:
-**	No arguments.
-**
-** ON EXIT:
-**	returns	the user name
-**		Default is "" (nobody).
-*/
-PUBLIC char * HTAA_getUidName NOARGS
+ *		GET THE USER ID NAME (VMS ONLY)
+ * ON ENTRY:
+ *	No arguments.
+ *
+ * ON EXIT:
+ *	returns	the user name
+ *		Default is "" (nobody).
+ */
+const char *HTAA_getUidName(void)
 {
     if (current_prot && current_prot->uid_name
-		  && (0 != strcmp(current_prot->uid_name,"nobody")) )
-       return(current_prot->uid_name);
+	&& (0 != strcmp(current_prot->uid_name, "nobody")))
+	return (current_prot->uid_name);
     else
-       return("");
+	return ("");
 }
 
 /* PUBLIC							HTAA_getFileName
-**		GET THE FILENAME (VMS ONLY)
-** ON ENTRY:
-**	No arguments.
-**
-** ON EXIT:
-**	returns	the filename
-*/
-PUBLIC char * HTAA_getFileName NOARGS
+ *		GET THE FILENAME (VMS ONLY)
+ * ON ENTRY:
+ *	No arguments.
+ *
+ * ON EXIT:
+ *	returns	the filename
+ */
+const char *HTAA_getFileName(void)
 {
     if (current_prot && current_prot->filename)
-       return(current_prot->filename);
+	return (current_prot->filename);
     else
-       return("");
+	return ("");
 }
 
 #else /* not VMS */
 
 /* PUBLIC							HTAA_getUid()
-**		GET THE USER ID TO CHANGE THE PROCESS UID TO
-** ON ENTRY:
-**	No arguments.
-**
-** ON EXIT:
-**	returns	the uid number to give to setuid() system call.
-**		Default is 65534 (nobody).
-*/
-PUBLIC int HTAA_getUid NOARGS
+ *		GET THE USER ID TO CHANGE THE PROCESS UID TO
+ * ON ENTRY:
+ *	No arguments.
+ *
+ * ON EXIT:
+ *	returns	the uid number to give to setuid() system call.
+ *		Default is 65534 (nobody).
+ */
+int HTAA_getUid(void)
 {
     int uid;
 
-    if (current_prot  &&  current_prot->uid_name) {
+    if (current_prot && current_prot->uid_name) {
 	if (isNumber(current_prot->uid_name)) {
 	    uid = atoi(current_prot->uid_name);
-	    if ((*HTAA_UidToName (uid)) != '\0') {
+	    if ((*HTAA_UidToName(uid)) != '\0') {
 		return uid;
 	    }
-	}
-	else {	/* User name (not a number) */
-	    if ((uid = HTAA_NameToUid (current_prot->uid_name)) != NONESUCH) {
+	} else {		/* User name (not a number) */
+	    if ((uid = HTAA_NameToUid(current_prot->uid_name)) != NONESUCH) {
 		return uid;
 	    }
 	}
     }
     /*
-    ** Ok, then let's get uid for nobody.
-    */
-    if ((uid = HTAA_NameToUid ("nobody")) != NONESUCH) {
+     * Ok, then let's get uid for nobody.
+     */
+    if ((uid = HTAA_NameToUid("nobody")) != NONESUCH) {
 	return uid;
     }
     /*
-    ** Ok, then use default.
-    */
-    return NOBODY;	/* nobody */
+     * Ok, then use default.
+     */
+    return NOBODY;		/* nobody */
 }
 
-
 /* PUBLIC							HTAA_getGid()
-**		GET THE GROUP ID TO CHANGE THE PROCESS GID TO
-** ON ENTRY:
-**	No arguments.
-**
-** ON EXIT:
-**	returns	the uid number to give to setgid() system call.
-**		Default is 65534 (nogroup).
-*/
-PUBLIC int HTAA_getGid NOARGS
+ *		GET THE GROUP ID TO CHANGE THE PROCESS GID TO
+ * ON ENTRY:
+ *	No arguments.
+ *
+ * ON EXIT:
+ *	returns	the uid number to give to setgid() system call.
+ *		Default is 65534 (nogroup).
+ */
+int HTAA_getGid(void)
 {
     int gid;
 
-    if (current_prot  &&  current_prot->gid_name) {
+    if (current_prot && current_prot->gid_name) {
 	if (isNumber(current_prot->gid_name)) {
 	    gid = atoi(current_prot->gid_name);
 	    if (*HTAA_GidToName(gid) != '\0') {
 		return gid;
 	    }
-	}
-	else {	/* Group name (not number) */
-	    if ((gid = HTAA_NameToGid (current_prot->gid_name)) != NONESUCH) {
+	} else {		/* Group name (not number) */
+	    if ((gid = HTAA_NameToGid(current_prot->gid_name)) != NONESUCH) {
 		return gid;
 	    }
 	}
     }
     /*
-    ** Ok, then let's get gid for nogroup.
-    */
-    if ((gid = HTAA_NameToGid ("nogroup")) != NONESUCH) {
+     * Ok, then let's get gid for nogroup.
+     */
+    if ((gid = HTAA_NameToGid("nogroup")) != NONESUCH) {
 	return gid;
     }
     /*
-    ** Ok, then use default.
-    */
-    return NOBODY;	/* nogroup */
+     * Ok, then use default.
+     */
+    return NOBODY;		/* nogroup */
 }
 #endif /* not VMS */
 
-
-/* PRIVATE							HTAA_setIds()
-**		SET UID AND GID (AS NAMES OR NUMBERS)
-**		TO HTAAProt STRUCTURE
-** ON ENTRY:
-**	prot		destination.
-**	ids		is a string like "james.www" or "1422.69" etc.
-**			giving uid and gid.
-**
-** ON EXIT:
-**	returns		nothing.
-*/
-PRIVATE void HTAA_setIds ARGS2(HTAAProt *,	prot,
-			       CONST char *,	ids)
+/* static							HTAA_setIds()
+ *		SET UID AND GID (AS NAMES OR NUMBERS)
+ *		TO HTAAProt STRUCTURE
+ * ON ENTRY:
+ *	prot		destination.
+ *	ids		is a string like "james.www" or "1422.69" etc.
+ *			giving uid and gid.
+ *
+ * ON EXIT:
+ *	returns		nothing.
+ */
+static void HTAA_setIds(HTAAProt *prot, const char *ids)
 {
     if (ids) {
 	char *local_copy = NULL;
@@ -211,34 +207,30 @@
 	StrAllocCopy(local_copy, ids);
 	point = strchr(local_copy, '.');
 	if (point) {
-	    *(point++) = (char)0;
+	    *(point++) = (char) 0;
 	    StrAllocCopy(prot->gid_name, point);
-	}
-	else {
+	} else {
 	    StrAllocCopy(prot->gid_name, "nogroup");
 	}
 	StrAllocCopy(prot->uid_name, local_copy);
 	FREE(local_copy);
-    }
-    else {
+    } else {
 	StrAllocCopy(prot->uid_name, "nobody");
 	StrAllocCopy(prot->gid_name, "nogroup");
     }
 }
 
-
-/* PRIVATE						HTAA_parseProtFile()
-**		PARSE A PROTECTION SETUP FILE AND
-**		PUT THE RESULT IN A HTAAProt STRUCTURE
-** ON ENTRY:
-**	prot		destination structure.
-**	fp		open protection file.
-**
-** ON EXIT:
-**	returns		nothing.
-*/
-PRIVATE void HTAA_parseProtFile ARGS2(HTAAProt *, prot,
-				      FILE *,	  fp)
+/* static						HTAA_parseProtFile()
+ *		PARSE A PROTECTION SETUP FILE AND
+ *		PUT THE RESULT IN A HTAAProt STRUCTURE
+ * ON ENTRY:
+ *	prot		destination structure.
+ *	fp		open protection file.
+ *
+ * ON EXIT:
+ *	returns		nothing.
+ */
+static void HTAA_parseProtFile(HTAAProt *prot, FILE *fp)
 {
     if (prot && fp) {
 	LexItem lex_item;
@@ -249,7 +241,7 @@
 	    while (lex_item == LEX_REC_SEP)	/* Ignore empty lines */
 		lex_item = lex(fp);
 
-	    if (lex_item == LEX_EOF)		/* End of file */
+	    if (lex_item == LEX_EOF)	/* End of file */
 		break;
 
 	    if (lex_item == LEX_ALPH_STR) {	/* Valid setup record */
@@ -258,112 +250,114 @@
 
 		if (LEX_FIELD_SEP != (lex_item = lex(fp)))
 		    unlex(lex_item);	/* If someone wants to use colon */
-					/* after field name it's ok, but */
-					/* not required. Here we read it.*/
+		/* after field name it's ok, but */
+		/* not required. Here we read it. */
 
-		if (0==strncasecomp(fieldname, "Auth", 4)) {
+		if (0 == strncasecomp(fieldname, "Auth", 4)) {
 		    lex_item = lex(fp);
 		    while (lex_item == LEX_ALPH_STR) {
 			HTAAScheme scheme = HTAAScheme_enum(HTlex_buffer);
+
 			if (scheme != HTAA_UNKNOWN) {
 			    if (!prot->valid_schemes)
 				prot->valid_schemes = HTList_new();
-			    HTList_addObject(prot->valid_schemes,(void*)scheme);
+			    HTList_addObject(prot->valid_schemes, (void *) scheme);
 			    CTRACE((tfp, "%s %s `%s'\n",
-					"HTAA_parseProtFile: valid",
-					"authentication scheme:",
-					HTAAScheme_name(scheme)));
+				    "HTAA_parseProtFile: valid",
+				    "authentication scheme:",
+				    HTAAScheme_name(scheme)));
 			} else {
 			    CTRACE((tfp, "%s %s `%s'\n",
-					"HTAA_parseProtFile: unknown",
-					"authentication scheme:",
-					HTlex_buffer));
+				    "HTAA_parseProtFile: unknown",
+				    "authentication scheme:",
+				    HTlex_buffer));
 			}
 
 			if (LEX_ITEM_SEP != (lex_item = lex(fp)))
 			    break;
 			/*
-			** Here lex_item == LEX_ITEM_SEP; after item separator
-			** it is ok to have one or more newlines (LEX_REC_SEP)
-			** and they are ignored (continuation line).
-			*/
+			 * Here lex_item == LEX_ITEM_SEP; after item separator
+			 * it is ok to have one or more newlines (LEX_REC_SEP)
+			 * and they are ignored (continuation line).
+			 */
 			do {
 			    lex_item = lex(fp);
 			} while (lex_item == LEX_REC_SEP);
-		    } /* while items in list */
-		} /* if "Authenticate" */
-
-		else if (0==strncasecomp(fieldname, "mask", 4)) {
+		    }		/* while items in list */
+		}
+		/* if "Authenticate" */
+		else if (0 == strncasecomp(fieldname, "mask", 4)) {
 		    prot->mask_group = HTAA_parseGroupDef(fp);
-		    lex_item=LEX_REC_SEP; /*groupdef parser read this already*/
+		    lex_item = LEX_REC_SEP;	/*groupdef parser read this already */
 		    if (TRACE) {
 			if (prot->mask_group) {
 			    fprintf(tfp,
 				    "HTAA_parseProtFile: Mask group:\n");
 			    HTAA_printGroupDef(prot->mask_group);
-			} else fprintf(tfp, "HTAA_parseProtFile: Mask group syntax error\n");
+			} else
+			    fprintf(tfp,
+				    "HTAA_parseProtFile: Mask group syntax error\n");
 		    }
-		} /* if "Mask" */
-
-		else {	/* Just a name-value pair, put it to assoclist */
+		}
+		/* if "Mask" */
+		else {		/* Just a name-value pair, put it to assoclist */
 
 		    if (LEX_ALPH_STR == (lex_item = lex(fp))) {
 			if (!prot->values)
 			    prot->values = HTAssocList_new();
 			HTAssocList_add(prot->values, fieldname, HTlex_buffer);
-			lex_item = lex(fp);  /* Read record separator */
+			lex_item = lex(fp);	/* Read record separator */
 			CTRACE((tfp, "%s `%s' bound to value `%s'\n",
-				    "HTAA_parseProtFile: Name",
-				    fieldname, HTlex_buffer));
+				"HTAA_parseProtFile: Name",
+				fieldname, HTlex_buffer));
 		    }
-		} /* else name-value pair */
+		}		/* else name-value pair */
 
-	    } /* if valid field */
-
-	    if (lex_item != LEX_EOF  &&  lex_item != LEX_REC_SEP) {
+	    }
+	    /* if valid field */
+	    if (lex_item != LEX_EOF && lex_item != LEX_REC_SEP) {
 		CTRACE((tfp, "%s %s %d (that line ignored)\n",
-			    "HTAA_parseProtFile: Syntax error",
-			    "in protection setup file at line",
-			    HTlex_line));
+			"HTAA_parseProtFile: Syntax error",
+			"in protection setup file at line",
+			HTlex_line));
 		do {
 		    lex_item = lex(fp);
 		} while (lex_item != LEX_EOF && lex_item != LEX_REC_SEP);
-	    } /* if syntax error */
-	} /* while not end-of-file */
+	    }			/* if syntax error */
+	}			/* while not end-of-file */
 	FREE(fieldname);
-    } /* if valid parameters */
+    }				/* if valid parameters */
 }
 
-
-/* PRIVATE						HTAAProt_new()
-**		ALLOCATE A NEW HTAAProt STRUCTURE AND
-**		INITIALIZE IT FROM PROTECTION SETUP FILE
-** ON ENTRY:
-**	cur_docname	current filename after rule translations.
-**	prot_filename	protection setup file name.
-**			If NULL, not an error.
-**	ids		Uid and gid names or numbers,
-**			examples:
-**				james	( <=> james.nogroup)
-**				.www	( <=> nobody.www)
-**				james.www
-**				james.69
-**				1422.69
-**				1422.www
-**
-**			May be NULL, defaults to nobody.nogroup.
-**			Should be NULL, if prot_file is NULL.
-**
-** ON EXIT:
-**	returns		returns a new and initialized protection
-**			setup structure.
-**			If setup file is already read in (found
-**			in cache), only sets uid_name and gid
-**			fields, and returns that.
-*/
-PRIVATE HTAAProt *HTAAProt_new ARGS3(CONST char *,	cur_docname,
-				     CONST char *,	prot_filename,
-				     CONST char *,	ids)
+/* static						HTAAProt_new()
+ *		ALLOCATE A NEW HTAAProt STRUCTURE AND
+ *		INITIALIZE IT FROM PROTECTION SETUP FILE
+ * ON ENTRY:
+ *	cur_docname	current filename after rule translations.
+ *	prot_filename	protection setup file name.
+ *			If NULL, not an error.
+ *	ids		Uid and gid names or numbers,
+ *			examples:
+ *				james	( <=> james.nogroup)
+ *				.www	( <=> nobody.www)
+ *				james.www
+ *				james.69
+ *				1422.69
+ *				1422.www
+ *
+ *			May be NULL, defaults to nobody.nogroup.
+ *			Should be NULL, if prot_file is NULL.
+ *
+ * ON EXIT:
+ *	returns		returns a new and initialized protection
+ *			setup structure.
+ *			If setup file is already read in (found
+ *			in cache), only sets uid_name and gid
+ *			fields, and returns that.
+ */
+static HTAAProt *HTAAProt_new(const char *cur_docname,
+			      const char *prot_filename,
+			      const char *ids)
 {
     HTList *cur = prot_cache;
     HTAAProtCache *cache_item = NULL;
@@ -373,28 +367,28 @@
     if (!prot_cache)
 	prot_cache = HTList_new();
 
-    while (NULL != (cache_item = (HTAAProtCache*)HTList_nextObject(cur))) {
+    while (NULL != (cache_item = (HTAAProtCache *) HTList_nextObject(cur))) {
 	if (!strcmp(cache_item->prot_filename, prot_filename))
 	    break;
     }
     if (cache_item) {
 	prot = cache_item->prot;
 	CTRACE((tfp, "%s `%s' already in cache\n",
-		    "HTAAProt_new: Protection file", prot_filename));
+		"HTAAProt_new: Protection file", prot_filename));
     } else {
 	CTRACE((tfp, "HTAAProt_new: Loading protection file `%s'\n",
-		    prot_filename));
+		prot_filename));
 
 	if ((prot = typecalloc(HTAAProt)) == 0)
-	    outofmem(__FILE__, "HTAAProt_new");
+	      outofmem(__FILE__, "HTAAProt_new");
 
-	prot->template	= NULL;
-	prot->filename	= NULL;
-	prot->uid_name	= NULL;
-	prot->gid_name	= NULL;
+	prot->ctemplate = NULL;
+	prot->filename = NULL;
+	prot->uid_name = NULL;
+	prot->gid_name = NULL;
 	prot->valid_schemes = HTList_new();
-	prot->mask_group= NULL;		/* Masking disabled by defaults */
-	prot->values	= HTAssocList_new();
+	prot->mask_group = NULL;	/* Masking disabled by defaults */
+	prot->values = HTAssocList_new();
 
 	if (prot_filename && NULL != (fp = fopen(prot_filename, TXT_R))) {
 	    HTAA_parseProtFile(prot, fp);
@@ -404,11 +398,11 @@
 	    cache_item->prot = prot;
 	    cache_item->prot_filename = NULL;
 	    StrAllocCopy(cache_item->prot_filename, prot_filename);
-	    HTList_addObject(prot_cache, (void*)cache_item);
+	    HTList_addObject(prot_cache, (void *) cache_item);
 	} else {
 	    CTRACE((tfp, "HTAAProt_new: %s `%s'\n",
-			"Unable to open protection setup file",
-			NONNULL(prot_filename)));
+		    "Unable to open protection setup file",
+		    NONNULL(prot_filename)));
 	}
     }
 
@@ -419,29 +413,28 @@
     return prot;
 }
 
-
 /* PUBLIC					HTAA_setDefaultProtection()
-**		SET THE DEFAULT PROTECTION MODE
-**		(called by rule system when a
-**		"defprot" rule is matched)
-** ON ENTRY:
-**	cur_docname	is the current result of rule translations.
-**	prot_filename	is the protection setup file (second argument
-**			for "defprot" rule, optional)
-**	ids		contains user and group names separated by
-**			a dot, corresponding to the uid
-**			gid under which the server should run,
-**			default is "nobody.nogroup" (third argument
-**			for "defprot" rule, optional; can be given
-**			only if protection setup file is also given).
-**
-** ON EXIT:
-**	returns		nothing.
-**			Sets the module-wide variable default_prot.
-*/
-PUBLIC void HTAA_setDefaultProtection ARGS3(CONST char *,	cur_docname,
-					    CONST char *,	prot_filename,
-					    CONST char *,	ids)
+ *		SET THE DEFAULT PROTECTION MODE
+ *		(called by rule system when a
+ *		"defprot" rule is matched)
+ * ON ENTRY:
+ *	cur_docname	is the current result of rule translations.
+ *	prot_filename	is the protection setup file (second argument
+ *			for "defprot" rule, optional)
+ *	ids		contains user and group names separated by
+ *			a dot, corresponding to the uid
+ *			gid under which the server should run,
+ *			default is "nobody.nogroup" (third argument
+ *			for "defprot" rule, optional; can be given
+ *			only if protection setup file is also given).
+ *
+ * ON EXIT:
+ *	returns		nothing.
+ *			Sets the module-wide variable default_prot.
+ */
+void HTAA_setDefaultProtection(const char *cur_docname,
+			       const char *prot_filename,
+			       const char *ids)
 {
     default_prot = NULL;	/* Not free()'d because this is in cache */
 
@@ -449,34 +442,33 @@
 	default_prot = HTAAProt_new(cur_docname, prot_filename, ids);
     } else {
 	CTRACE((tfp, "%s %s\n",
-		    "HTAA_setDefaultProtection: ERROR: Protection file",
-		    "not specified (obligatory for DefProt rule)!!\n"));
+		"HTAA_setDefaultProtection: ERROR: Protection file",
+		"not specified (obligatory for DefProt rule)!!\n"));
     }
 }
 
-
 /* PUBLIC					HTAA_setCurrentProtection()
-**		SET THE CURRENT PROTECTION MODE
-**		(called by rule system when a
-**		"protect" rule is matched)
-** ON ENTRY:
-**	cur_docname	is the current result of rule translations.
-**	prot_filename	is the protection setup file (second argument
-**			for "protect" rule, optional)
-**	ids		contains user and group names separated by
-**			a dot, corresponding to the uid
-**			gid under which the server should run,
-**			default is "nobody.nogroup" (third argument
-**			for "protect" rule, optional; can be given
-**			only if protection setup file is also given).
-**
-** ON EXIT:
-**	returns		nothing.
-**			Sets the module-wide variable current_prot.
-*/
-PUBLIC void HTAA_setCurrentProtection ARGS3(CONST char *,	cur_docname,
-					    CONST char *,	prot_filename,
-					    CONST char *,	ids)
+ *		SET THE CURRENT PROTECTION MODE
+ *		(called by rule system when a
+ *		"protect" rule is matched)
+ * ON ENTRY:
+ *	cur_docname	is the current result of rule translations.
+ *	prot_filename	is the protection setup file (second argument
+ *			for "protect" rule, optional)
+ *	ids		contains user and group names separated by
+ *			a dot, corresponding to the uid
+ *			gid under which the server should run,
+ *			default is "nobody.nogroup" (third argument
+ *			for "protect" rule, optional; can be given
+ *			only if protection setup file is also given).
+ *
+ * ON EXIT:
+ *	returns		nothing.
+ *			Sets the module-wide variable current_prot.
+ */
+void HTAA_setCurrentProtection(const char *cur_docname,
+			       const char *prot_filename,
+			       const char *ids)
 {
     current_prot = NULL;	/* Not free()'d because this is in cache */
 
@@ -487,63 +479,61 @@
 	    current_prot = default_prot;
 	    HTAA_setIds(current_prot, ids);
 	    CTRACE((tfp, "%s %s %s\n",
-			"HTAA_setCurrentProtection: Protection file",
-			"not specified for Protect rule",
-			"-- using default protection"));
+		    "HTAA_setCurrentProtection: Protection file",
+		    "not specified for Protect rule",
+		    "-- using default protection"));
 	} else {
 	    CTRACE((tfp, "%s %s %s\n",
-			"HTAA_setCurrentProtection: ERROR: Protection",
-			"file not specified for Protect rule, and",
-			"default protection is not set!!"));
+		    "HTAA_setCurrentProtection: ERROR: Protection",
+		    "file not specified for Protect rule, and",
+		    "default protection is not set!!"));
 	}
     }
 }
 
-
 /* PUBLIC					HTAA_getCurrentProtection()
-**		GET CURRENT PROTECTION SETUP STRUCTURE
-**		(this is set up by callbacks made from
-**		 the rule system when matching "protect"
-**		 (and "defprot") rules)
-** ON ENTRY:
-**	HTTranslate() must have been called before calling
-**	this function.
-**
-** ON EXIT:
-**	returns	a HTAAProt structure representing the
-**		protection setup of the HTTranslate()'d file.
-**		This must not be free()'d.
-*/
-PUBLIC HTAAProt *HTAA_getCurrentProtection NOARGS
+ *		GET CURRENT PROTECTION SETUP STRUCTURE
+ *		(this is set up by callbacks made from
+ *		 the rule system when matching "protect"
+ *		 (and "defprot") rules)
+ * ON ENTRY:
+ *	HTTranslate() must have been called before calling
+ *	this function.
+ *
+ * ON EXIT:
+ *	returns	a HTAAProt structure representing the
+ *		protection setup of the HTTranslate()'d file.
+ *		This must not be free()'d.
+ */
+HTAAProt *HTAA_getCurrentProtection(void)
 {
     return current_prot;
 }
 
-
 /* PUBLIC					HTAA_getDefaultProtection()
-**		GET DEFAULT PROTECTION SETUP STRUCTURE
-**		AND SET IT TO CURRENT PROTECTION
-**		(this is set up by callbacks made from
-**		 the rule system when matching "defprot"
-**		 rules)
-** ON ENTRY:
-**	HTTranslate() must have been called before calling
-**	this function.
-**
-** ON EXIT:
-**	returns	a HTAAProt structure representing the
-**		default protection setup of the HTTranslate()'d
-**		file (if HTAA_getCurrentProtection() returned
-**		NULL, i.e., if there is no "protect" rule
-**		but ACL exists, and we need to know default
-**		protection settings).
-**		This must not be free()'d.
-** IMPORTANT:
-**	As a side-effect this tells the protection system that
-**	the file is in fact protected and sets the current
-**	protection mode to default.
-*/
-PUBLIC HTAAProt *HTAA_getDefaultProtection NOARGS
+ *		GET DEFAULT PROTECTION SETUP STRUCTURE
+ *		AND SET IT TO CURRENT PROTECTION
+ *		(this is set up by callbacks made from
+ *		 the rule system when matching "defprot"
+ *		 rules)
+ * ON ENTRY:
+ *	HTTranslate() must have been called before calling
+ *	this function.
+ *
+ * ON EXIT:
+ *	returns	a HTAAProt structure representing the
+ *		default protection setup of the HTTranslate()'d
+ *		file (if HTAA_getCurrentProtection() returned
+ *		NULL, i.e., if there is no "protect" rule
+ *		but ACL exists, and we need to know default
+ *		protection settings).
+ *		This must not be free()'d.
+ * IMPORTANT:
+ *	As a side-effect this tells the protection system that
+ *	the file is in fact protected and sets the current
+ *	protection mode to default.
+ */
+HTAAProt *HTAA_getDefaultProtection(void)
 {
     if (!current_prot) {
 	current_prot = default_prot;
@@ -552,40 +542,40 @@
     return current_prot;
 }
 
-
 /* SERVER INTERNAL					HTAA_clearProtections()
-**		CLEAR DOCUMENT PROTECTION MODE
-**		(ALSO DEFAULT PROTECTION)
-**		(called by the rule system)
-** ON ENTRY:
-**	No arguments.
-**
-** ON EXIT:
-**	returns	nothing.
-**		Frees the memory used by protection information.
-*/
-PUBLIC void HTAA_clearProtections NOARGS
+ *		CLEAR DOCUMENT PROTECTION MODE
+ *		(ALSO DEFAULT PROTECTION)
+ *		(called by the rule system)
+ * ON ENTRY:
+ *	No arguments.
+ *
+ * ON EXIT:
+ *	returns	nothing.
+ *		Frees the memory used by protection information.
+ */
+void HTAA_clearProtections(void)
 {
-    current_prot = NULL;	/* These are not freed because	*/
-    default_prot = NULL;	/* they are actually in cache.	*/
+    current_prot = NULL;	/* These are not freed because  */
+    default_prot = NULL;	/* they are actually in cache.  */
 }
 
 typedef struct {
-	char *name;
-	int user;
-	} USER_DATA;
+    char *name;
+    int user;
+} USER_DATA;
 
 #ifndef NOUSERS
-PRIVATE HTList *known_grp = NULL;
-PRIVATE HTList *known_pwd = NULL;
-PRIVATE BOOL uidgid_cache_inited = NO;
+static HTList *known_grp = NULL;
+static HTList *known_pwd = NULL;
+static BOOL uidgid_cache_inited = NO;
 #endif
 
 #ifdef LY_FIND_LEAKS
-PRIVATE void clear_uidgid_cache NOARGS
+static void clear_uidgid_cache(void)
 {
 #ifndef NOUSERS
     USER_DATA *data;
+
     if (known_grp) {
 	while ((data = HTList_removeLastObject(known_grp)) != NULL) {
 	    FREE(data->name);
@@ -605,9 +595,10 @@
 #endif /* LY_FIND_LEAKS */
 
 #ifndef NOUSERS
-PRIVATE void save_gid_info ARGS2(char *, name, int, user)
+static void save_gid_info(const char *name, int user)
 {
     USER_DATA *data = typecalloc(USER_DATA);
+
     if (!data)
 	return;
     if (!known_grp) {
@@ -621,14 +612,15 @@
     }
     StrAllocCopy(data->name, name);
     data->user = user;
-    HTList_addObject (known_grp, data);
+    HTList_addObject(known_grp, data);
 }
 #endif /* NOUSERS */
 
 #ifndef NOUSERS
-PRIVATE void save_uid_info ARGS2(char *, name, int, user)
+static void save_uid_info(const char *name, int user)
 {
     USER_DATA *data = typecalloc(USER_DATA);
+
     if (!data)
 	return;
     if (!known_pwd) {
@@ -642,36 +634,37 @@
     }
     StrAllocCopy(data->name, name);
     data->user = user;
-    HTList_addObject (known_pwd, data);
+    HTList_addObject(known_pwd, data);
 }
 #endif /* !NOUSERS */
 
 /* PUBLIC							HTAA_UidToName
-**		GET THE USER NAME
-** ON ENTRY:
-**      The user-id
-**
-** ON EXIT:
-**      returns the user name, or an empty string if not found.
-*/
-PUBLIC char * HTAA_UidToName ARGS1(int, uid)
+ *		GET THE USER NAME
+ * ON ENTRY:
+ *      The user-id
+ *
+ * ON EXIT:
+ *      returns the user name, or an empty string if not found.
+ */
+const char *HTAA_UidToName(int uid)
 {
 #ifndef NOUSERS
     struct passwd *pw;
     HTList *me = known_pwd;
 
     while (HTList_nextObject(me)) {
-	USER_DATA *data = (USER_DATA *)(me->object);
+	USER_DATA *data = (USER_DATA *) (me->object);
+
 	if (uid == data->user)
 	    return data->name;
     }
 
     if ((pw = getpwuid(uid)) != 0
-     && pw->pw_name != 0) {
+	&& pw->pw_name != 0) {
 	CTRACE((tfp, "%s(%d) returned (%s:%d:...)\n",
-		    "HTAA_UidToName: getpwuid",
-		    uid,
-		    pw->pw_name, (int) pw->pw_uid));
+		"HTAA_UidToName: getpwuid",
+		uid,
+		pw->pw_name, (int) pw->pw_uid));
 	save_uid_info(pw->pw_name, (int) pw->pw_uid);
 	return pw->pw_name;
     }
@@ -680,30 +673,31 @@
 }
 
 /* PUBLIC							HTAA_NameToUid
-**		GET THE USER ID
-** ON ENTRY:
-**      The user-name
-**
-** ON EXIT:
-**      returns the user id, or NONESUCH if not found.
-*/
-PUBLIC int HTAA_NameToUid ARGS1(char *, name)
+ *		GET THE USER ID
+ * ON ENTRY:
+ *      The user-name
+ *
+ * ON EXIT:
+ *      returns the user id, or NONESUCH if not found.
+ */
+int HTAA_NameToUid(const char *name)
 {
 #ifndef NOUSERS
     struct passwd *pw;
     HTList *me = known_pwd;
 
     while (HTList_nextObject(me)) {
-	USER_DATA *data = (USER_DATA *)(me->object);
+	USER_DATA *data = (USER_DATA *) (me->object);
+
 	if (!strcmp(name, data->name))
 	    return data->user;
     }
 
     if ((pw = getpwnam(name)) != 0) {
 	CTRACE((tfp, "%s(%s) returned (%s:%d:...)\n",
-		    "HTAA_NameToUid: getpwnam",
-		    name,
-		    pw->pw_name, (int) pw->pw_uid));
+		"HTAA_NameToUid: getpwnam",
+		name,
+		pw->pw_name, (int) pw->pw_uid));
 	save_uid_info(pw->pw_name, (int) pw->pw_uid);
 	return (int) pw->pw_uid;
     }
@@ -712,31 +706,32 @@
 }
 
 /* PUBLIC							HTAA_GidToName
-**		GET THE GROUP NAME
-** ON ENTRY:
-**      The group-id
-**
-** ON EXIT:
-**      returns the group name, or an empty string if not found.
-*/
-PUBLIC char * HTAA_GidToName ARGS1(int, gid)
+ *		GET THE GROUP NAME
+ * ON ENTRY:
+ *      The group-id
+ *
+ * ON EXIT:
+ *      returns the group name, or an empty string if not found.
+ */
+const char *HTAA_GidToName(int gid)
 {
 #ifndef NOUSERS
     struct group *gr;
     HTList *me = known_grp;
 
     while (HTList_nextObject(me)) {
-	USER_DATA *data = (USER_DATA *)(me->object);
+	USER_DATA *data = (USER_DATA *) (me->object);
+
 	if (gid == data->user)
 	    return data->name;
     }
 
     if ((gr = getgrgid(gid)) != 0
-     && gr->gr_name != 0) {
+	&& gr->gr_name != 0) {
 	CTRACE((tfp, "%s(%d) returned (%s:%d:...)\n",
-		    "HTAA_GidToName: getgrgid",
-		    gid,
-		    gr->gr_name, (int) gr->gr_gid));
+		"HTAA_GidToName: getgrgid",
+		gid,
+		gr->gr_name, (int) gr->gr_gid));
 	save_gid_info(gr->gr_name, (int) gr->gr_gid);
 	return gr->gr_name;
     }
@@ -745,30 +740,31 @@
 }
 
 /* PUBLIC							HTAA_NameToGid
-**		GET THE GROUP ID
-** ON ENTRY:
-**      The group-name
-**
-** ON EXIT:
-**      returns the group id, or NONESUCH if not found.
-*/
-PUBLIC int HTAA_NameToGid ARGS1(char *, name)
+ *		GET THE GROUP ID
+ * ON ENTRY:
+ *      The group-name
+ *
+ * ON EXIT:
+ *      returns the group id, or NONESUCH if not found.
+ */
+int HTAA_NameToGid(const char *name)
 {
 #ifndef NOUSERS
     struct group *gr;
     HTList *me = known_grp;
 
     while (HTList_nextObject(me)) {
-	USER_DATA *data = (USER_DATA *)(me->object);
+	USER_DATA *data = (USER_DATA *) (me->object);
+
 	if (!strcmp(name, data->name))
 	    return data->user;
     }
 
     if ((gr = getgrnam(name)) != 0) {
 	CTRACE((tfp, "%s(%s) returned (%s:%d:...)\n",
-		    "HTAA_NameToGid: getgrnam",
-		    name,
-		    gr->gr_name, (int) gr->gr_gid));
+		"HTAA_NameToGid: getgrnam",
+		name,
+		gr->gr_name, (int) gr->gr_gid));
 	save_gid_info(gr->gr_name, (int) gr->gr_gid);
 	return (int) gr->gr_gid;
     }
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/HTGroup.c
+++ lynx-cur-2.8.6/WWW/Library/Implementation/HTGroup.c
@@ -1,95 +1,90 @@
-
 /* MODULE							HTGroup.c
-**		GROUP FILE ROUTINES
-**
-**	Contains group file parser and routines to match IP
-**	address templates and to find out group membership.
-**
-**
-** AUTHORS:
-**	AL	Ari Luotonen	luotonen@dxcern.cern.ch
-**
-** HISTORY:
-**
-**
-** BUGS:
-**
-**
-**
-** GROUP DEFINITION GRAMMAR:
-**
-**	string = "sequence of alphanumeric characters"
-**	user_name ::= string
-**	group_name ::= string
-**	group_ref ::= group_name
-**	user_def ::= user_name | group_ref
-**	user_def_list ::= user_def { ',' user_def }
-**	user_part = user_def | '(' user_def_list ')'
-**
-**	templ = "sequence of alphanumeric characters and '*'s"
-**	ip_number_mask ::= templ '.' templ '.' templ '.' templ
-**	domain_name_mask ::= templ { '.' templ }
-**	address ::= ip_number_mask | domain_name_mask
-**	address_def ::= address
-**	address_def_list ::= address_def { ',' address_def }
-**	address_part = address_def | '(' address_def_list ')'
-**
-**	item ::= [user_part] ['@' address_part]
-**	item_list ::= item { ',' item }
-**	group_def ::= item_list
-**	group_decl ::= group_name ':' group_def
-**
-*/
-
+ *		GROUP FILE ROUTINES
+ *
+ *	Contains group file parser and routines to match IP
+ *	address templates and to find out group membership.
+ *
+ *
+ * AUTHORS:
+ *	AL	Ari Luotonen	luotonen@dxcern.cern.ch
+ *
+ * HISTORY:
+ *
+ *
+ * BUGS:
+ *
+ *
+ *
+ * GROUP DEFINITION GRAMMAR:
+ *
+ *	string = "sequence of alphanumeric characters"
+ *	user_name ::= string
+ *	group_name ::= string
+ *	group_ref ::= group_name
+ *	user_def ::= user_name | group_ref
+ *	user_def_list ::= user_def { ',' user_def }
+ *	user_part = user_def | '(' user_def_list ')'
+ *
+ *	templ = "sequence of alphanumeric characters and '*'s"
+ *	ip_number_mask ::= templ '.' templ '.' templ '.' templ
+ *	domain_name_mask ::= templ { '.' templ }
+ *	address ::= ip_number_mask | domain_name_mask
+ *	address_def ::= address
+ *	address_def_list ::= address_def { ',' address_def }
+ *	address_part = address_def | '(' address_def_list ')'
+ *
+ *	item ::= [user_part] ['@' address_part]
+ *	item_list ::= item { ',' item }
+ *	group_def ::= item_list
+ *	group_decl ::= group_name ':' group_def
+ *
+ */
 
 #include <HTUtils.h>
 
 #include <HTAAUtil.h>
-#include <HTLex.h>	/* Lexical analysor	*/
-#include <HTGroup.h>	/* Implemented here	*/
+#include <HTLex.h>		/* Lexical analysor     */
+#include <HTGroup.h>		/* Implemented here     */
 
 #include <LYUtils.h>
 #include <LYLeaks.h>
 
 /*
-** Group file parser
-*/
+ * Group file parser
+ */
 
 typedef HTList UserDefList;
 typedef HTList AddressDefList;
 
 typedef struct {
-    UserDefList *	user_def_list;
-    AddressDefList *	address_def_list;
+    UserDefList *user_def_list;
+    AddressDefList *address_def_list;
 } Item;
 
 typedef struct {
-    char *	name;
-    GroupDef *	translation;
+    char *name;
+    GroupDef *translation;
 } Ref;
 
-
-
-PRIVATE void syntax_error ARGS3(FILE *,	 fp,
-				char *,	 msg,
-				LexItem, lex_item)
+static void syntax_error(FILE *fp, const char *msg,
+			 LexItem lex_item)
 {
     char buffer[41];
     int cnt = 0;
     int ch;
 
-    while ((ch = getc(fp)) != EOF  &&  ch != '\n')
-	if (cnt < 40) buffer[cnt++] = (char) ch;
-    buffer[cnt] = (char)0;
+    while ((ch = getc(fp)) != EOF && ch != '\n')
+	if (cnt < 40)
+	    buffer[cnt++] = (char) ch;
+    buffer[cnt] = (char) 0;
 
     CTRACE((tfp, "%s %d before: '%s'\nHTGroup.c: %s (got %s)\n",
-		"HTGroup.c: Syntax error in rule file at line",
-		HTlex_line, buffer, msg, lex_verbose(lex_item)));
+	    "HTGroup.c: Syntax error in rule file at line",
+	    HTlex_line, buffer, msg, lex_verbose(lex_item)));
     HTlex_line++;
 }
 
-
-PRIVATE AddressDefList *parse_address_part ARGS1(FILE *, fp)
+static AddressDefList *parse_address_part(FILE *fp)
 {
     AddressDefList *address_def_list = NULL;
     LexItem lex_item;
@@ -98,7 +93,7 @@
     lex_item = lex(fp);
     if (lex_item == LEX_ALPH_STR || lex_item == LEX_TMPL_STR)
 	only_one = YES;
-    else if (lex_item != LEX_OPEN_PAREN  ||
+    else if (lex_item != LEX_OPEN_PAREN ||
 	     ((lex_item = lex(fp)) != LEX_ALPH_STR &&
 	      lex_item != LEX_TMPL_STR)) {
 	syntax_error(fp, "Expecting a single address or '(' beginning list",
@@ -107,23 +102,24 @@
     }
     address_def_list = HTList_new();
 
-    for(;;) {
+    for (;;) {
 	Ref *ref = typecalloc(Ref);
+
 	if (ref == NULL)
 	    outofmem(__FILE__, "parse_address_part");
 	ref->name = NULL;
 	ref->translation = NULL;
 	StrAllocCopy(ref->name, HTlex_buffer);
 
-	HTList_addObject(address_def_list, (void*)ref);
+	HTList_addObject(address_def_list, (void *) ref);
 
 	if (only_one || (lex_item = lex(fp)) != LEX_ITEM_SEP)
 	    break;
 	/*
-	** Here lex_item == LEX_ITEM_SEP; after item separator it
-	** is ok to have one or more newlines (LEX_REC_SEP) and
-	** they are ignored (continuation line).
-	*/
+	 * Here lex_item == LEX_ITEM_SEP; after item separator it
+	 * is ok to have one or more newlines (LEX_REC_SEP) and
+	 * they are ignored (continuation line).
+	 */
 	do {
 	    lex_item = lex(fp);
 	} while (lex_item == LEX_REC_SEP);
@@ -145,8 +141,7 @@
     return address_def_list;
 }
 
-
-PRIVATE UserDefList *parse_user_part ARGS1(FILE *, fp)
+static UserDefList *parse_user_part(FILE *fp)
 {
     UserDefList *user_def_list = NULL;
     LexItem lex_item;
@@ -155,7 +150,7 @@
     lex_item = lex(fp);
     if (lex_item == LEX_ALPH_STR)
 	only_one = YES;
-    else if (lex_item != LEX_OPEN_PAREN  ||
+    else if (lex_item != LEX_OPEN_PAREN ||
 	     (lex_item = lex(fp)) != LEX_ALPH_STR) {
 	syntax_error(fp, "Expecting a single name or '(' beginning list",
 		     lex_item);
@@ -165,21 +160,22 @@
 
     for (;;) {
 	Ref *ref = typecalloc(Ref);
+
 	if (ref == NULL)
 	    outofmem(__FILE__, "parse_user_part");
 	ref->name = NULL;
 	ref->translation = NULL;
 	StrAllocCopy(ref->name, HTlex_buffer);
 
-	HTList_addObject(user_def_list, (void*)ref);
+	HTList_addObject(user_def_list, (void *) ref);
 
 	if (only_one || (lex_item = lex(fp)) != LEX_ITEM_SEP)
 	    break;
 	/*
-	** Here lex_item == LEX_ITEM_SEP; after item separator it
-	** is ok to have one or more newlines (LEX_REC_SEP) and
-	** they are ignored (continuation line).
-	*/
+	 * Here lex_item == LEX_ITEM_SEP; after item separator it
+	 * is ok to have one or more newlines (LEX_REC_SEP) and
+	 * they are ignored (continuation line).
+	 */
 	do {
 	    lex_item = lex(fp);
 	} while (lex_item == LEX_REC_SEP);
@@ -201,8 +197,7 @@
     return user_def_list;
 }
 
-
-PRIVATE Item *parse_item ARGS1(FILE *, fp)
+static Item *parse_item(FILE *fp)
 {
     Item *item = NULL;
     UserDefList *user_def_list = NULL;
@@ -222,8 +217,7 @@
 	    lex_item == LEX_OPEN_PAREN) {
 	    unlex(lex_item);
 	    address_def_list = parse_address_part(fp);
-	}
-	else {
+	} else {
 	    if (user_def_list) {
 		HTList_delete(user_def_list);	/* @@@@ */
 		user_def_list = NULL;
@@ -232,8 +226,8 @@
 			 lex_item);
 	    return NULL;
 	}
-    }
-    else unlex(lex_item);
+    } else
+	unlex(lex_item);
 
     if (!user_def_list && !address_def_list) {
 	syntax_error(fp, "Empty item not allowed", lex_item);
@@ -247,30 +241,29 @@
     return item;
 }
 
-
-PRIVATE ItemList *parse_item_list ARGS1(FILE *, fp)
+static ItemList *parse_item_list(FILE *fp)
 {
     ItemList *item_list = HTList_new();
     Item *item;
     LexItem lex_item;
 
-    for(;;) {
+    for (;;) {
 	if (!(item = parse_item(fp))) {
 	    HTList_delete(item_list);	/* @@@@ */
 	    item_list = NULL;
 	    return NULL;
 	}
-	HTList_addObject(item_list, (void*)item);
+	HTList_addObject(item_list, (void *) item);
 	lex_item = lex(fp);
 	if (lex_item != LEX_ITEM_SEP) {
 	    unlex(lex_item);
 	    return item_list;
 	}
 	/*
-	** Here lex_item == LEX_ITEM_SEP; after item separator it
-	** is ok to have one or more newlines (LEX_REC_SEP) and
-	** they are ignored (continuation line).
-	*/
+	 * Here lex_item == LEX_ITEM_SEP; after item separator it
+	 * is ok to have one or more newlines (LEX_REC_SEP) and
+	 * they are ignored (continuation line).
+	 */
 	do {
 	    lex_item = lex(fp);
 	} while (lex_item == LEX_REC_SEP);
@@ -278,8 +271,7 @@
     }
 }
 
-
-PUBLIC GroupDef *HTAA_parseGroupDef ARGS1(FILE *, fp)
+GroupDef *HTAA_parseGroupDef(FILE *fp)
 {
     ItemList *item_list = NULL;
     GroupDef *group_def = NULL;
@@ -301,8 +293,7 @@
     return group_def;
 }
 
-
-PRIVATE GroupDef *parse_group_decl ARGS1(FILE *, fp)
+static GroupDef *parse_group_decl(FILE *fp)
 {
     char *group_name = NULL;
     GroupDef *group_def = NULL;
@@ -334,20 +325,18 @@
     return group_def;
 }
 
-
-
 /*
-** Group manipulation routines
-*/
+ * Group manipulation routines
+ */
 
-PRIVATE GroupDef *find_group_def ARGS2(GroupDefList *,	group_list,
-				       CONST char *,	group_name)
+static GroupDef *find_group_def(GroupDefList *group_list,
+				const char *group_name)
 {
     if (group_list && group_name) {
 	GroupDefList *cur = group_list;
 	GroupDef *group_def;
 
-	while (NULL != (group_def = (GroupDef*)HTList_nextObject(cur))) {
+	while (NULL != (group_def = (GroupDef *) HTList_nextObject(cur))) {
 	    if (!strcmp(group_name, group_def->group_name)) {
 		return group_def;
 	    }
@@ -356,19 +345,18 @@
     return NULL;
 }
 
-
-PUBLIC void HTAA_resolveGroupReferences ARGS2(GroupDef *,	group_def,
-					      GroupDefList *,	group_def_list)
+void HTAA_resolveGroupReferences(GroupDef *group_def,
+				 GroupDefList *group_def_list)
 {
     if (group_def && group_def->item_list && group_def_list) {
 	ItemList *cur1 = group_def->item_list;
 	Item *item;
 
-	while (NULL != (item = (Item*)HTList_nextObject(cur1))) {
+	while (NULL != (item = (Item *) HTList_nextObject(cur1))) {
 	    UserDefList *cur2 = item->user_def_list;
 	    Ref *ref;
 
-	    while (NULL != (ref = (Ref*)HTList_nextObject(cur2)))
+	    while (NULL != (ref = (Ref *) HTList_nextObject(cur2)))
 		ref->translation = find_group_def(group_def_list, ref->name);
 
 	    /* Does NOT translate address_def_list */
@@ -376,16 +364,14 @@
     }
 }
 
-
-PRIVATE void add_group_def ARGS2(GroupDefList *, group_def_list,
-				 GroupDef *,	 group_def)
+static void add_group_def(GroupDefList *group_def_list,
+			  GroupDef *group_def)
 {
     HTAA_resolveGroupReferences(group_def, group_def_list);
-    HTList_addObject(group_def_list, (void*)group_def);
+    HTList_addObject(group_def_list, (void *) group_def);
 }
 
-
-PRIVATE GroupDefList *parse_group_file ARGS1(FILE *, fp)
+static GroupDefList *parse_group_file(FILE *fp)
 {
     GroupDefList *group_def_list = HTList_new();
     GroupDef *group_def;
@@ -396,53 +382,53 @@
     return group_def_list;
 }
 
-
 /*
-** Trace functions
-*/
+ * Trace functions
+ */
 
-PRIVATE void print_item ARGS1(Item *, item)
+static void print_item(Item *item)
 {
     if (!item)
 	fprintf(tfp, "\tNULL-ITEM\n");
     else {
 	UserDefList *cur1 = item->user_def_list;
 	AddressDefList *cur2 = item->address_def_list;
-	Ref *user_ref = (Ref*)HTList_nextObject(cur1);
-	Ref *addr_ref = (Ref*)HTList_nextObject(cur2);
+	Ref *user_ref = (Ref *) HTList_nextObject(cur1);
+	Ref *addr_ref = (Ref *) HTList_nextObject(cur2);
 
 	if (user_ref) {
 	    fprintf(tfp, "\t[%s%s", user_ref->name,
 		    (user_ref->translation ? "*REF*" : ""));
-	    while (NULL != (user_ref = (Ref*)HTList_nextObject(cur1)))
+	    while (NULL != (user_ref = (Ref *) HTList_nextObject(cur1)))
 		fprintf(tfp, "; %s%s", user_ref->name,
 			(user_ref->translation ? "*REF*" : ""));
 	    fprintf(tfp, "] ");
-	} else fprintf(tfp, "\tANYBODY ");
+	} else
+	    fprintf(tfp, "\tANYBODY ");
 
 	if (addr_ref) {
 	    fprintf(tfp, "@ [%s", addr_ref->name);
-	    while (NULL != (addr_ref = (Ref*)HTList_nextObject(cur2)))
+	    while (NULL != (addr_ref = (Ref *) HTList_nextObject(cur2)))
 		fprintf(tfp, "; %s", addr_ref->name);
 	    fprintf(tfp, "]\n");
-	} else fprintf(tfp, "@ ANYADDRESS\n");
+	} else
+	    fprintf(tfp, "@ ANYADDRESS\n");
     }
 }
 
-
-PRIVATE void print_item_list ARGS1(ItemList *, item_list)
+static void print_item_list(ItemList *item_list)
 {
     ItemList *cur = item_list;
     Item *item;
 
     if (!item_list)
 	fprintf(tfp, "EMPTY");
-    else while (NULL != (item = (Item*)HTList_nextObject(cur)))
-	print_item(item);
+    else
+	while (NULL != (item = (Item *) HTList_nextObject(cur)))
+	    print_item(item);
 }
 
-
-PUBLIC void HTAA_printGroupDef ARGS1(GroupDef *, group_def)
+void HTAA_printGroupDef(GroupDef *group_def)
 {
     if (!group_def) {
 	fprintf(tfp, "\nNULL RECORD\n");
@@ -456,154 +442,148 @@
     fprintf(tfp, "\n");
 }
 
-
-PRIVATE void print_group_def_list ARGS1(GroupDefList *, group_list)
+static void print_group_def_list(GroupDefList *group_list)
 {
     GroupDefList *cur = group_list;
     GroupDef *group_def;
 
-    while (NULL != (group_def = (GroupDef*)HTList_nextObject(cur)))
+    while (NULL != (group_def = (GroupDef *) HTList_nextObject(cur)))
 	HTAA_printGroupDef(group_def);
 }
 
-
-
 /*
-** IP address template matching
-*/
+ * IP address template matching
+ */
 
-/* PRIVATE						part_match()
-**		MATCH ONE PART OF INET ADDRESS AGAIST
-**		A PART OF MASK (inet address has 4 parts)
-** ON ENTRY:
-**	tcur	pointer to the beginning of template part.
-**	icur	pointer to the beginning of actual inet
-**		number part.
-**
-** ON EXIT:
-**	returns	YES, if match.
-*/
-PRIVATE BOOL part_match ARGS2(CONST char *, tcur,
-			      CONST char *, icur)
+/* static						part_match()
+ *		MATCH ONE PART OF INET ADDRESS AGAIST
+ *		A PART OF MASK (inet address has 4 parts)
+ * ON ENTRY:
+ *	tcur	pointer to the beginning of template part.
+ *	icur	pointer to the beginning of actual inet
+ *		number part.
+ *
+ * ON EXIT:
+ *	returns	YES, if match.
+ */
+static BOOL part_match(const char *tcur,
+		       const char *icur)
 {
     char required[4];
     char actual[4];
-    CONST char *cur;
+    const char *cur;
     int cnt;
     BOOL status;
 
-    if (!tcur || !icur) return NO;
+    if (!tcur || !icur)
+	return NO;
 
-    cur=tcur;
-    cnt=0;
-    while (cnt < 3  &&  *cur && *cur != '.')
+    cur = tcur;
+    cnt = 0;
+    while (cnt < 3 && *cur && *cur != '.')
 	required[cnt++] = *(cur++);
-    required[cnt] = (char)0;
+    required[cnt] = (char) 0;
 
-    cur=icur;
-    cnt=0;
-    while (cnt < 3  &&  *cur && *cur != '.')
+    cur = icur;
+    cnt = 0;
+    while (cnt < 3 && *cur && *cur != '.')
 	actual[cnt++] = *(cur++);
-    actual[cnt] = (char)0;
+    actual[cnt] = (char) 0;
 
     status = HTAA_templateMatch(required, actual);
     CTRACE((tfp, "part_match: req: '%s' act: '%s' match: %s\n",
-		required, actual, (status ? "yes" : "no")));
+	    required, actual, (status ? "yes" : "no")));
 
     return status;
 }
 
-
-
-/* PRIVATE						ip_number_match()
-**		MATCH INET NUMBER AGAINST AN INET NUMBER MASK
-** ON ENTRY:
-**	template	mask to match agaist, e.g., 128.141.*.*
-**	the_inet_addr	actual inet address, e.g., 128.141.201.74
-**
-** ON EXIT:
-**	returns		YES, if match;  NO, if not.
-*/
-PRIVATE BOOL ip_number_match ARGS2(CONST char *,	template,
-				   CONST char *,	the_inet_addr)
+/* static						ip_number_match()
+ *		MATCH INET NUMBER AGAINST AN INET NUMBER MASK
+ * ON ENTRY:
+ *	template	mask to match agaist, e.g., 128.141.*.*
+ *	the_inet_addr	actual inet address, e.g., 128.141.201.74
+ *
+ * ON EXIT:
+ *	returns		YES, if match;  NO, if not.
+ */
+static BOOL ip_number_match(const char *ctemplate,
+			    const char *the_inet_addr)
 {
-    CONST char *tcur = template;
-    CONST char *icur = the_inet_addr;
+    const char *tcur = ctemplate;
+    const char *icur = the_inet_addr;
     int cnt;
 
-    for (cnt=0; cnt<4; cnt++) {
+    for (cnt = 0; cnt < 4; cnt++) {
 	if (!tcur || !icur || !part_match(tcur, icur))
 	    return NO;
-	if (NULL != (tcur = strchr(tcur, '.'))) tcur++;
-	if (NULL != (icur = strchr(icur, '.'))) icur++;
+	if (NULL != (tcur = strchr(tcur, '.')))
+	    tcur++;
+	if (NULL != (icur = strchr(icur, '.')))
+	    icur++;
     }
     return YES;
 }
 
-
-
-/* PRIVATE						is_domain_mask()
-**		DETERMINE IF A GIVEN MASK IS A
-**		DOMAIN NAME MASK OR AN INET NUMBER MASK
-** ON ENTRY:
-**	mask	either a domain name mask,
-**		e.g.
-**			*.cern.ch
-**
-**		or an inet number mask,
-**		e.g.
-**			128.141.*.*
-**
-** ON EXIT:
-**	returns	YES, if mask is a domain name mask.
-**		NO, if it is an inet number mask.
-*/
-PRIVATE BOOL is_domain_mask ARGS1(CONST char *,	mask)
+/* static						is_domain_mask()
+ *		DETERMINE IF A GIVEN MASK IS A
+ *		DOMAIN NAME MASK OR AN INET NUMBER MASK
+ * ON ENTRY:
+ *	mask	either a domain name mask,
+ *		e.g.
+ *			*.cern.ch
+ *
+ *		or an inet number mask,
+ *		e.g.
+ *			128.141.*.*
+ *
+ * ON EXIT:
+ *	returns	YES, if mask is a domain name mask.
+ *		NO, if it is an inet number mask.
+ */
+static BOOL is_domain_mask(const char *mask)
 {
-    CONST char *cur = mask;
+    const char *cur = mask;
 
-    if (!mask) return NO;
+    if (!mask)
+	return NO;
 
     while (*cur) {
-	if (*cur != '.'  &&  *cur != '*'  &&  (*cur < '0' || *cur > '9'))
-	    return YES;	/* Even one non-digit makes it a domain name mask */
+	if (*cur != '.' && *cur != '*' && (*cur < '0' || *cur > '9'))
+	    return YES;		/* Even one non-digit makes it a domain name mask */
 	cur++;
     }
-    return NO;	/* All digits and dots, so it is an inet number mask */
+    return NO;			/* All digits and dots, so it is an inet number mask */
 }
 
-
-
-/* PRIVATE							ip_mask_match()
-**		MATCH AN IP NUMBER MASK OR IP NAME MASK
-**		AGAINST ACTUAL IP NUMBER OR IP NAME
-**
-** ON ENTRY:
-**	mask		mask.  Mask may be either an inet number
-**			mask or a domain name mask,
-**			e.g.
-**				128.141.*.*
-**			or
-**				*.cern.ch
-**
-**	ip_number	IP number of connecting host.
-**	ip_name		IP name of the connecting host.
-**
-** ON EXIT:
-**	returns		YES, if hostname/internet number
-**			matches the mask.
-**			NO, if no match (no fire).
-*/
-PRIVATE BOOL ip_mask_match ARGS3(CONST char *,	mask,
-				 CONST char *,	ip_number,
-				 CONST char *,	ip_name)
+/* static							ip_mask_match()
+ *		MATCH AN IP NUMBER MASK OR IP NAME MASK
+ *		AGAINST ACTUAL IP NUMBER OR IP NAME
+ *
+ * ON ENTRY:
+ *	mask		mask.  Mask may be either an inet number
+ *			mask or a domain name mask,
+ *			e.g.
+ *				128.141.*.*
+ *			or
+ *				*.cern.ch
+ *
+ *	ip_number	IP number of connecting host.
+ *	ip_name		IP name of the connecting host.
+ *
+ * ON EXIT:
+ *	returns		YES, if hostname/internet number
+ *			matches the mask.
+ *			NO, if no match (no fire).
+ */
+static BOOL ip_mask_match(const char *mask,
+			  const char *ip_number,
+			  const char *ip_name)
 {
     if (mask && (ip_number || ip_name)) {
 	if (is_domain_mask(mask)) {
 	    if (HTAA_templateMatch(mask, ip_name))
 		return YES;
-	}
-	else {
+	} else {
 	    if (ip_number_match(mask, ip_number))
 		return YES;
 	}
@@ -611,20 +591,17 @@
     return NO;
 }
 
-
-
-
-PRIVATE BOOL ip_in_def_list ARGS3(AddressDefList *,	address_def_list,
-				  char *,		ip_number,
-				  char *,		ip_name)
+static BOOL ip_in_def_list(AddressDefList *address_def_list,
+			   char *ip_number,
+			   char *ip_name)
 {
     if (address_def_list && (ip_number || ip_name)) {
 	AddressDefList *cur = address_def_list;
 	Ref *ref;
 
-	while (NULL != (ref = (Ref*)HTList_nextObject(cur))) {
+	while (NULL != (ref = (Ref *) HTList_nextObject(cur))) {
 	    /* Value of ref->translation is ignored, i.e., */
-	    /* no recursion for ip address tamplates.	  */
+	    /* no recursion for ip address tamplates.     */
 	    if (ip_mask_match(ref->name, ip_number, ip_name))
 		return YES;
 	}
@@ -632,50 +609,49 @@
     return NO;
 }
 
-
 /*
-** Group file cached reading
-*/
+ * Group file cached reading
+ */
 
 typedef struct {
-    char *	   group_filename;
-    GroupDefList * group_list;
+    char *group_filename;
+    GroupDefList *group_list;
 } GroupCache;
 
 typedef HTList GroupCacheList;
 
-PRIVATE GroupCacheList *group_cache_list = NULL;
-
+static GroupCacheList *group_cache_list = NULL;
 
-PUBLIC GroupDefList *HTAA_readGroupFile ARGS1(CONST char *, filename)
+GroupDefList *HTAA_readGroupFile(const char *filename)
 {
     FILE *fp;
     GroupCache *group_cache;
 
-    if (isEmpty(filename)) return NULL;
+    if (isEmpty(filename))
+	return NULL;
 
     if (!group_cache_list)
 	group_cache_list = HTList_new();
     else {
 	GroupCacheList *cur = group_cache_list;
 
-	while (NULL != (group_cache = (GroupCache*)HTList_nextObject(cur))) {
+	while (NULL != (group_cache = (GroupCache *) HTList_nextObject(cur))) {
 	    if (!strcmp(filename, group_cache->group_filename)) {
 		CTRACE((tfp, "%s '%s' %s\n",
-			    "HTAA_readGroupFile: group file",
-			    filename, "already found in cache"));
+			"HTAA_readGroupFile: group file",
+			filename, "already found in cache"));
 		return group_cache->group_list;
-	    } /* if cache match */
-	} /* while cached files remain */
-    } /* cache exists */
+	    }			/* if cache match */
+	}			/* while cached files remain */
+    }				/* cache exists */
 
     CTRACE((tfp, "HTAA_readGroupFile: reading group file `%s'\n",
-		filename));
+	    filename));
 
     if (!(fp = fopen(filename, TXT_R))) {
 	CTRACE((tfp, "%s '%s'\n",
-		    "HTAA_readGroupFile: unable to open group file",
-		    filename));
+		"HTAA_readGroupFile: unable to open group file",
+		filename));
 	return NULL;
     }
 
@@ -685,7 +661,7 @@
     group_cache->group_filename = NULL;
     StrAllocCopy(group_cache->group_filename, filename);
     group_cache->group_list = parse_group_file(fp);
-    HTList_addObject(group_cache_list, (void*)group_cache);
+    HTList_addObject(group_cache_list, (void *) group_cache);
     fclose(fp);
 
     CTRACE((tfp, "Read group file '%s', results follow:\n", filename));
@@ -695,29 +671,28 @@
     return group_cache->group_list;
 }
 
-
 /* PUBLIC					HTAA_userAndInetInGroup()
-**		CHECK IF USER BELONGS TO TO A GIVEN GROUP
-**		AND THAT THE CONNECTION COMES FROM AN
-**		ADDRESS THAT IS ALLOWED BY THAT GROUP
-** ON ENTRY:
-**	group		the group definition structure.
-**	username	connecting user.
-**	ip_number	browser host IP number, optional.
-**	ip_name		browser host IP name, optional.
-**			However, one of ip_number or ip_name
-**			must be given.
-** ON EXIT:
-**	returns		HTAA_IP_MASK, if IP address mask was
-**			reason for failing.
-**			HTAA_NOT_MEMBER, if user does not belong
-**			to the group.
-**			HTAA_OK if both IP address and user are ok.
-*/
-PUBLIC HTAAFailReasonType HTAA_userAndInetInGroup ARGS4(GroupDef *, group,
-							char *,	    username,
-							char *,	    ip_number,
-							char *,	    ip_name)
+ *		CHECK IF USER BELONGS TO TO A GIVEN GROUP
+ *		AND THAT THE CONNECTION COMES FROM AN
+ *		ADDRESS THAT IS ALLOWED BY THAT GROUP
+ * ON ENTRY:
+ *	group		the group definition structure.
+ *	username	connecting user.
+ *	ip_number	browser host IP number, optional.
+ *	ip_name		browser host IP name, optional.
+ *			However, one of ip_number or ip_name
+ *			must be given.
+ * ON EXIT:
+ *	returns		HTAA_IP_MASK, if IP address mask was
+ *			reason for failing.
+ *			HTAA_NOT_MEMBER, if user does not belong
+ *			to the group.
+ *			HTAA_OK if both IP address and user are ok.
+ */
+HTAAFailReasonType HTAA_userAndInetInGroup(GroupDef *group,
+					   char *username,
+					   char *ip_number,
+					   char *ip_name)
 {
     HTAAFailReasonType reason = HTAA_NOT_MEMBER;
 
@@ -725,7 +700,7 @@
 	ItemList *cur1 = group->item_list;
 	Item *item;
 
-	while (NULL != (item = (Item*)HTList_nextObject(cur1))) {
+	while (NULL != (item = (Item *) HTList_nextObject(cur1))) {
 	    if (!item->address_def_list ||	/* Any address allowed */
 		ip_in_def_list(item->address_def_list, ip_number, ip_name)) {
 
@@ -735,34 +710,34 @@
 		    UserDefList *cur2 = item->user_def_list;
 		    Ref *ref;
 
-		    while (NULL != (ref = (Ref*)HTList_nextObject(cur2))) {
+		    while (NULL != (ref = (Ref *) HTList_nextObject(cur2))) {
 
-			if (ref->translation) {	/* Group, check recursively */
+			if (ref->translation) {		/* Group, check recursively */
 			    reason = HTAA_userAndInetInGroup(ref->translation,
 							     username,
-							     ip_number,ip_name);
+							     ip_number, ip_name);
 			    if (reason == HTAA_OK)
 				return HTAA_OK;
-			}
-			else {	/* Username, check directly */
+			} else {	/* Username, check directly */
 			    if (username && *username &&
-				0==strcmp(ref->name, username))
+				0 == strcmp(ref->name, username))
 				return HTAA_OK;
 			}
-		    } /* Every user/group name in this group */
-		} /* search for username */
-	    } /* IP address ok */
-	    else {
+			/* Every user/group name in this group */
+		    }
+		    /* search for username */
+		}
+		/* IP address ok */
+	    } else {
 		reason = HTAA_IP_MASK;
 	    }
-	} /* while items in group */
-    } /* valid parameters */
-
+	}			/* while items in group */
+    }
+    /* valid parameters */
     return reason;		/* No match, or invalid parameters */
 }
 
-
-PUBLIC void GroupDef_delete ARGS1(GroupDef *, group_def)
+void GroupDef_delete(GroupDef *group_def)
 {
     if (group_def) {
 	FREE(group_def->group_name);
@@ -773,4 +748,3 @@
 	FREE(group_def);
     }
 }
-
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/HTAABrow.c
+++ lynx-cur-2.8.6/WWW/Library/Implementation/HTAABrow.c
@@ -1,149 +1,151 @@
 
 /* MODULE							HTAABrow.c
-**		BROWSER SIDE ACCESS AUTHORIZATION MODULE
-**
-**	Contains the code for keeping track on server hostnames,
-**	port numbers, scheme names, usernames, passwords
-**	(and servers' public keys).
-**
-** IMPORTANT:
-**	Routines in this module use dynamic allocation, but free
-**	automatically all the memory reserved by them.
-**
-**	Therefore the caller never has to (and never should)
-**	free() any object returned by these functions.
-**
-**	Therefore also all the strings returned by this package
-**	are only valid until the next call to the same function
-**	is made.  This approach is selected, because of the nature
-**	of access authorization: no string returned by the package
-**	needs to be valid longer than until the next call.
-**
-**	This also makes it easy to plug the AA package in:
-**	you don't have to ponder whether to free() something
-**	here or is it done somewhere else (because it is always
-**	done somewhere else).
-**
-**	The strings that the package needs to store are copied
-**	so the original strings given as parameters to AA
-**	functions may be freed or modified with no side effects.
-**
-**	The AA package does not free() anything else than what
-**	it has itself allocated.
-**
-** AUTHORS:
-**	AL	Ari Luotonen	luotonen@dxcern.cern.ch
-**
-** HISTORY:
-**	Oct 17	AL	Made corrections suggested by marca:
-**			Added  if (!realm->username) return NULL;
-**			Changed some ""s to NULLs.
-**			Now doing calloc() to init uuencode source;
-**			otherwise HTUU_encode() reads uninitialized memory
-**			every now and then (not a real bug but not pretty).
-**			Corrected the formula for uuencode destination size.
-**
-** 28 Apr 1997	AJL	Do Proxy Authorisation.
-**
-** BUGS:
-**
-**
-*/
+ *		BROWSER SIDE ACCESS AUTHORIZATION MODULE
+ *
+ *	Contains the code for keeping track on server hostnames,
+ *	port numbers, scheme names, usernames, passwords
+ *	(and servers' public keys).
+ *
+ * IMPORTANT:
+ *	Routines in this module use dynamic allocation, but free
+ *	automatically all the memory reserved by them.
+ *
+ *	Therefore the caller never has to (and never should)
+ *	free() any object returned by these functions.
+ *
+ *	Therefore also all the strings returned by this package
+ *	are only valid until the next call to the same function
+ *	is made.  This approach is selected, because of the nature
+ *	of access authorization: no string returned by the package
+ *	needs to be valid longer than until the next call.
+ *
+ *	This also makes it easy to plug the AA package in:
+ *	you don't have to ponder whether to free() something
+ *	here or is it done somewhere else (because it is always
+ *	done somewhere else).
+ *
+ *	The strings that the package needs to store are copied
+ *	so the original strings given as parameters to AA
+ *	functions may be freed or modified with no side effects.
+ *
+ *	The AA package does not free() anything else than what
+ *	it has itself allocated.
+ *
+ * AUTHORS:
+ *	AL	Ari Luotonen	luotonen@dxcern.cern.ch
+ *
+ * HISTORY:
+ *	Oct 17	AL	Made corrections suggested by marca:
+ *			Added  if (!realm->username) return NULL;
+ *			Changed some ""s to NULLs.
+ *			Now doing calloc() to init uuencode source;
+ *			otherwise HTUU_encode() reads uninitialized memory
+ *			every now and then (not a real bug but not pretty).
+ *			Corrected the formula for uuencode destination size.
+ *
+ * 28 Apr 1997	AJL	Do Proxy Authorisation.
+ *
+ * BUGS:
+ *
+ *
+ */
 
 #include <HTUtils.h>
 #include <HTString.h>
-#include <HTParse.h>		/* URL parsing function		*/
-#include <HTList.h>		/* HTList object		*/
-#include <HTAlert.h>		/* HTConfirm(), HTPrompt()	*/
-#include <HTAAUtil.h>		/* AA common to both sides	*/
-#include <HTAssoc.h>		/* Assoc list			*/
+#include <HTParse.h>		/* URL parsing function         */
+#include <HTList.h>		/* HTList object                */
+#include <HTAlert.h>		/* HTConfirm(), HTPrompt()      */
+#include <HTAAUtil.h>		/* AA common to both sides      */
+#include <HTAssoc.h>		/* Assoc list                   */
 #include <HTAccess.h>		/* Are we using an HTTP gateway? */
-#include <HTAABrow.h>		/* Implemented here		*/
-#include <HTUU.h>		/* Uuencoding and uudecoding	*/
+#include <HTAABrow.h>		/* Implemented here             */
+#include <HTUU.h>		/* Uuencoding and uudecoding    */
 
 #include <LYLeaks.h>
 
 /*
-**  Local datatype definitions
-**
-**  HTAAServer contains all the information about one server.
-*/
+ *  Local datatype definitions
+ *
+ *  HTAAServer contains all the information about one server.
+ */
 typedef struct {
 
-    char *	hostname;	/* Host's name			*/
-    int		portnumber;	/* Port number			*/
-    BOOL	IsProxy;	/* Is it a proxy?		*/
-    HTList *	setups;		/* List of protection setups	*/
-				/* on this server; i.e., valid	*/
-				/* authentication schemes and	*/
-				/* templates when to use them.	*/
-				/* This is actually a list of	*/
-				/* HTAASetup objects.		*/
-    HTList *	realms;		/* Information about passwords	*/
+    char *hostname;		/* Host's name                  */
+    int portnumber;		/* Port number                  */
+    BOOL IsProxy;		/* Is it a proxy?               */
+    HTList *setups;		/* List of protection setups 
+				   on this server; i.e., valid
+				   authentication schemes and
+				   templates when to use them.
+				   This is actually a list of
+				   HTAASetup objects.           */
+    HTList *realms;		/* Information about passwords  */
 } HTAAServer;
 
 /*
-**  HTAASetup contains information about one server's one
-**  protected tree of documents.
-*/
+ *  HTAASetup contains information about one server's one
+ *  protected tree of documents.
+ */
 typedef struct {
-    HTAAServer *server;		/* Which server serves this tree	     */
-    char *	template;	/* Template for this tree		     */
-    HTList *	valid_schemes;	/* Valid authentic.schemes		     */
-    HTAssocList**scheme_specifics;/* Scheme specific params		     */
-    BOOL	retry;		/* Failed last time -- reprompt (or whatever)*/
+    HTAAServer *server;		/* Which server serves this tree             */
+    char *ctemplate;		/* Template for this tree                    */
+    HTList *valid_schemes;	/* Valid authentic.schemes                   */
+    HTAssocList **scheme_specifics;	/* Scheme specific params                  */
+    BOOL retry;			/* Failed last time -- reprompt (or whatever) */
 } HTAASetup;
 
 /*
-**  Information about usernames and passwords in
-**  Basic and Pubkey authentication schemes;
-*/
+ *  Information about usernames and passwords in
+ *  Basic and Pubkey authentication schemes;
+ */
 typedef struct {
-    char *	realmname;	/* Password domain name		*/
-    char *	username;	/* Username in that domain	*/
-    char *	password;	/* Corresponding password	*/
+    char *realmname;		/* Password domain name         */
+    char *username;		/* Username in that domain      */
+    char *password;		/* Corresponding password       */
 } HTAARealm;
 
 /*
-**  To free off all globals. - FM
-*/
-PRIVATE void free_HTAAGlobals NOPARAMS;
-PRIVATE BOOL free_HTAAGlobalsSet = FALSE;
-PRIVATE char *HTAA_composeAuthResult = NULL;
-PRIVATE char *compose_auth_stringResult = NULL;	/* Uuencoded presentation */
+ *  To free off all globals. - FM
+ */
+static void free_HTAAGlobals(void);
+static BOOL free_HTAAGlobalsSet = FALSE;
+static char *HTAA_composeAuthResult = NULL;
+static char *compose_auth_stringResult = NULL;	/* Uuencoded presentation */
 
 /*
-**  Module-wide global variables
-*/
-PRIVATE HTList *server_table	= NULL;	/* Browser's info about servers	     */
-PRIVATE char *secret_key	= NULL;	/* Browser's latest secret key       */
-PRIVATE HTAASetup *current_setup= NULL;	/* The server setup we are currently */
-					/* talking to			     */
-PRIVATE char *current_hostname	= NULL;	/* The server's name and portnumber  */
-PRIVATE int current_portnumber	= 80;	/* where we are currently trying to  */
-					/* connect.			     */
-PRIVATE char *current_docname	= NULL; /* The document's name we are	     */
-					/* trying to access.		     */
-PRIVATE char *HTAAForwardAuth	= NULL;	/* Authorization: line to forward    */
-					/* (used by gateway httpds)	     */
-PRIVATE HTAASetup *proxy_setup	= NULL;	/* Same as above, but for Proxy -AJL */
-PRIVATE char *proxy_hostname	= NULL;
-PRIVATE char *proxy_docname	= NULL;
-PRIVATE int proxy_portnumber	= 80;
-
+ *  Module-wide global variables
+ */
+static HTList *server_table = NULL;	/* Browser's info about servers      */
+static char *secret_key = NULL;	/* Browser's latest secret key       */
+static HTAASetup *current_setup = NULL;		/* The server setup we are currently */
+
+					/* talking to                        */
+static char *current_hostname = NULL;	/* The server's name and portnumber  */
+static int current_portnumber = 80;	/* where we are currently trying to  */
+
+					/* connect.                          */
+static char *current_docname = NULL;	/* The document's name we are        */
+
+					/* trying to access.                 */
+static char *HTAAForwardAuth = NULL;	/* Authorization: line to forward    */
+
+					/* (used by gateway httpds)          */
+static HTAASetup *proxy_setup = NULL;	/* Same as above, but for Proxy -AJL */
+static char *proxy_hostname = NULL;
+static char *proxy_docname = NULL;
+static int proxy_portnumber = 80;
 
 /*** HTAAForwardAuth for enabling gateway-httpds to forward Authorization ***/
 
-PUBLIC void HTAAForwardAuth_set ARGS2(
-	CONST char *,	scheme_name,
-	CONST char *,	scheme_specifics)
+void HTAAForwardAuth_set(const char *scheme_name,
+			 const char *scheme_specifics)
 {
-    int len = 20 + (scheme_name      ? strlen(scheme_name)      : 0)
-		 + (scheme_specifics ? strlen(scheme_specifics) : 0);
+    int len = 20 + (scheme_name ? strlen(scheme_name) : 0)
+    + (scheme_specifics ? strlen(scheme_specifics) : 0);
 
     FREE(HTAAForwardAuth);
     if ((HTAAForwardAuth = typecallocn(char, len)) == 0)
-	outofmem(__FILE__, "HTAAForwardAuth_set");
+	  outofmem(__FILE__, "HTAAForwardAuth_set");
 
     strcpy(HTAAForwardAuth, "Authorization: ");
     if (scheme_name) {
@@ -155,47 +157,45 @@
     }
 }
 
-PUBLIC void HTAAForwardAuth_reset NOARGS
+void HTAAForwardAuth_reset(void)
 {
     FREE(HTAAForwardAuth);
 }
 
-
 /**************************** HTAAServer ***********************************/
 
-PRIVATE void HTAASetup_delete PARAMS((HTAASetup * killme));	/* Forward */
+static void HTAASetup_delete(HTAASetup * killme);	/* Forward */
 
-/* PRIVATE						HTAAServer_new()
-**		ALLOCATE A NEW NODE TO HOLD SERVER INFO
-**		AND ADD IT TO THE LIST OF SERVERS
-** ON ENTRY:
-**	hostname	is the name of the host that the server
-**			is running in.
-**	portnumber	is the portnumber which the server listens.
-**	IsProxy		should be TRUE if this is a proxy.
-**
-** ON EXIT:
-**	returns		the newly-allocated node with all the strings
-**			duplicated.
-**			Strings will be automatically freed by
-**			the function HTAAServer_delete(), which also
-**			frees the node itself.
-*/
-PRIVATE HTAAServer *HTAAServer_new ARGS3(
-	CONST char*,	hostname,
-	int,		portnumber,
-	BOOL,		IsProxy)
+/* static						HTAAServer_new()
+ *		ALLOCATE A NEW NODE TO HOLD SERVER INFO
+ *		AND ADD IT TO THE LIST OF SERVERS
+ * ON ENTRY:
+ *	hostname	is the name of the host that the server
+ *			is running in.
+ *	portnumber	is the portnumber which the server listens.
+ *	IsProxy		should be TRUE if this is a proxy.
+ *
+ * ON EXIT:
+ *	returns		the newly-allocated node with all the strings
+ *			duplicated.
+ *			Strings will be automatically freed by
+ *			the function HTAAServer_delete(), which also
+ *			frees the node itself.
+ */
+static HTAAServer *HTAAServer_new(const char *hostname,
+				  int portnumber,
+				  BOOL IsProxy)
 {
     HTAAServer *server;
 
     if ((server = typecalloc(HTAAServer)) == 0)
-	outofmem(__FILE__, "HTAAServer_new");
+	  outofmem(__FILE__, "HTAAServer_new");
 
-    server->hostname	= NULL;
-    server->portnumber	= (portnumber > 0 ? portnumber : 80);
-    server->IsProxy	= IsProxy;
-    server->setups	= HTList_new();
-    server->realms	= HTList_new();
+    server->hostname = NULL;
+    server->portnumber = (portnumber > 0 ? portnumber : 80);
+    server->IsProxy = IsProxy;
+    server->setups = HTList_new();
+    server->realms = HTList_new();
 
     if (hostname)
 	StrAllocCopy(server->hostname, hostname);
@@ -203,25 +203,23 @@
     if (!server_table)
 	server_table = HTList_new();
 
-    HTList_addObject(server_table, (void*)server);
+    HTList_addObject(server_table, (void *) server);
 
     return server;
 }
 
-
-/* PRIVATE						HTAAServer_delete()
-**
-**	DELETE THE ENTRY FOR THE SERVER FROM THE HOST TABLE,
-**	AND FREE THE MEMORY USED BY IT.
-**
-** ON ENTRY:
-**	killme		points to the HTAAServer to be freed.
-**
-** ON EXIT:
-**	returns		nothing.
-*/
-PRIVATE void HTAAServer_delete ARGS1(
-	HTAAServer *,	killme)
+/* static						HTAAServer_delete()
+ *
+ *	DELETE THE ENTRY FOR THE SERVER FROM THE HOST TABLE,
+ *	AND FREE THE MEMORY USED BY IT.
+ *
+ * ON ENTRY:
+ *	killme		points to the HTAAServer to be freed.
+ *
+ * ON EXIT:
+ *	returns		nothing.
+ */
+static void HTAAServer_delete(HTAAServer *killme)
 {
     int n, i;
     HTAASetup *setup;
@@ -232,8 +230,8 @@
 	if (killme->setups != NULL) {
 	    n = HTList_count(killme->setups);
 	    for (i = (n - 1); i >= 0; i--) {
-		if ((setup = (HTAASetup*)HTList_objectAt(killme->setups,
-							 i)) != NULL) {
+		if ((setup = (HTAASetup *) HTList_objectAt(killme->setups,
+							   i)) != NULL) {
 		    HTAASetup_delete(setup);
 		    setup = NULL;
 		}
@@ -243,7 +241,7 @@
 	}
 
 	cur = killme->realms;
-	while (NULL != (realm = (HTAARealm*)HTList_nextObject(cur))) {
+	while (NULL != (realm = (HTAARealm *) HTList_nextObject(cur))) {
 	    FREE(realm->realmname);
 	    FREE(realm->username);
 	    FREE(realm->password);
@@ -254,29 +252,28 @@
 
 	FREE(killme->hostname);
 
-	HTList_removeObject(server_table, (void*)killme);
+	HTList_removeObject(server_table, (void *) killme);
 	FREE(killme);
     }
 }
 
-/* PRIVATE						HTAAServer_lookup()
-**		LOOK UP SERVER BY HOSTNAME AND PORTNUMBER
-** ON ENTRY:
-**	hostname	obvious.
-**	portnumber	if non-positive defaults to 80.
-**	IsProxy		should be TRUE if this is a proxy.
-**
-**	Looks up the server in the module-global server_table.
-**
-** ON EXIT:
-**	returns		pointer to a HTAAServer structure
-**			representing the looked-up server.
-**			NULL, if not found.
-*/
-PRIVATE HTAAServer *HTAAServer_lookup ARGS3(
-	CONST char *,	hostname,
-	int,		portnumber,
-	BOOL,		IsProxy)
+/* static						HTAAServer_lookup()
+ *		LOOK UP SERVER BY HOSTNAME AND PORTNUMBER
+ * ON ENTRY:
+ *	hostname	obvious.
+ *	portnumber	if non-positive defaults to 80.
+ *	IsProxy		should be TRUE if this is a proxy.
+ *
+ *	Looks up the server in the module-global server_table.
+ *
+ * ON EXIT:
+ *	returns		pointer to a HTAAServer structure
+ *			representing the looked-up server.
+ *			NULL, if not found.
+ */
+static HTAAServer *HTAAServer_lookup(const char *hostname,
+				     int portnumber,
+				     BOOL IsProxy)
 {
     if (hostname) {
 	HTList *cur = server_table;
@@ -285,46 +282,44 @@
 	if (portnumber <= 0)
 	    portnumber = 80;
 
-	while (NULL != (server = (HTAAServer*)HTList_nextObject(cur))) {
-	    if (server->portnumber == portnumber  &&
-		0==strcmp(server->hostname, hostname) &&
+	while (NULL != (server = (HTAAServer *) HTList_nextObject(cur))) {
+	    if (server->portnumber == portnumber &&
+		0 == strcmp(server->hostname, hostname) &&
 		server->IsProxy == IsProxy)
 		return server;
 	}
     }
-    return NULL;	/* NULL parameter, or not found */
+    return NULL;		/* NULL parameter, or not found */
 }
 
-
 /*************************** HTAASetup *******************************/
 
-/* PRIVATE						HTAASetup_lookup()
-**	FIGURE OUT WHICH AUTHENTICATION SETUP THE SERVER
-**	IS USING FOR A GIVEN FILE ON A GIVEN HOST AND PORT
-**
-** ON ENTRY:
-**	hostname	is the name of the server host machine.
-**	portnumber	is the port that the server is running in.
-**	docname		is the (URL-)pathname of the document we
-**			are trying to access.
-**	IsProxy		should be TRUE if this is a proxy.
-**
-**	This function goes through the information known about
-**	all the setups of the server, and finds out if the given
-**	filename resides in one of the protected directories.
-**
-** ON EXIT:
-**	returns		NULL if no match.
-**			Otherwise, a HTAASetup structure representing
-**			the protected server setup on the corresponding
-**			document tree.
-**
-*/
-PRIVATE HTAASetup *HTAASetup_lookup ARGS4(
-	CONST char *,	hostname,
-	int,		portnumber,
-	CONST char *,	docname,
-	BOOL,		IsProxy)
+/* static						HTAASetup_lookup()
+ *	FIGURE OUT WHICH AUTHENTICATION SETUP THE SERVER
+ *	IS USING FOR A GIVEN FILE ON A GIVEN HOST AND PORT
+ *
+ * ON ENTRY:
+ *	hostname	is the name of the server host machine.
+ *	portnumber	is the port that the server is running in.
+ *	docname		is the (URL-)pathname of the document we
+ *			are trying to access.
+ *	IsProxy		should be TRUE if this is a proxy.
+ *
+ *	This function goes through the information known about
+ *	all the setups of the server, and finds out if the given
+ *	filename resides in one of the protected directories.
+ *
+ * ON EXIT:
+ *	returns		NULL if no match.
+ *			Otherwise, a HTAASetup structure representing
+ *			the protected server setup on the corresponding
+ *			document tree.
+ *
+ */
+static HTAASetup *HTAASetup_lookup(const char *hostname,
+				   int portnumber,
+				   const char *docname,
+				   BOOL IsProxy)
 {
     HTAAServer *server;
     HTAASetup *setup;
@@ -340,60 +335,58 @@
 	HTList *cur = server->setups;
 
 	CTRACE((tfp, "%s %s (%s:%d:%s)\n",
-		    "HTAASetup_lookup: resolving setup for",
-		    (IsProxy ? "proxy" : "server"),
-		    hostname, portnumber, docname));
+		"HTAASetup_lookup: resolving setup for",
+		(IsProxy ? "proxy" : "server"),
+		hostname, portnumber, docname));
 
-	while (NULL != (setup = (HTAASetup*)HTList_nextObject(cur))) {
-	    if (HTAA_templateMatch(setup->template, docname)) {
+	while (NULL != (setup = (HTAASetup *) HTList_nextObject(cur))) {
+	    if (HTAA_templateMatch(setup->ctemplate, docname)) {
 		CTRACE((tfp, "%s `%s' %s `%s'\n",
-			    "HTAASetup_lookup:", docname,
-			    "matched template", setup->template));
+			"HTAASetup_lookup:", docname,
+			"matched template", setup->ctemplate));
 		return setup;
 	    } else {
 		CTRACE((tfp, "%s `%s' %s `%s'\n",
-			    "HTAASetup_lookup:", docname,
-			    "did NOT match template", setup->template));
+			"HTAASetup_lookup:", docname,
+			"did NOT match template", setup->ctemplate));
 	    }
-	} /* while setups remain */
-    } /* if valid parameters and server found */
-
+	}			/* while setups remain */
+    }
+    /* if valid parameters and server found */
     CTRACE((tfp, "%s `%s' %s\n",
-		 "HTAASetup_lookup: No template matched",
-		 NONNULL(docname),
-		 "(so probably not protected)"));
+	    "HTAASetup_lookup: No template matched",
+	    NONNULL(docname),
+	    "(so probably not protected)"));
 
-    return NULL;	/* NULL in parameters, or not found */
+    return NULL;		/* NULL in parameters, or not found */
 }
 
-/* PRIVATE						HTAASetup_new()
-**			CREATE A NEW SETUP NODE
-** ON ENTRY:
-**	server		is a pointer to a HTAAServer structure
-**			to which this setup belongs.
-**	template	documents matching this template
-**			are protected according to this setup.
-**	valid_schemes	a list containing all valid authentication
-**			schemes for this setup.
-**			If NULL, all schemes are disallowed.
-**	scheme_specifics is an array of assoc lists, which
-**			contain scheme specific parameters given
-**			by server in Authenticate: fields.
-**			If NULL, all scheme specifics are
-**			set to NULL.
-** ON EXIT:
-**	returns		a new HTAASetup node, and also adds it as
-**			part of the HTAAServer given as parameter.
-*/
-PRIVATE HTAASetup *HTAASetup_new ARGS4(
-	HTAAServer *,	server,
-	char *,		template,
-	HTList *,	valid_schemes,
-	HTAssocList **,	scheme_specifics)
+/* static						HTAASetup_new()
+ *			CREATE A NEW SETUP NODE
+ * ON ENTRY:
+ *	server		is a pointer to a HTAAServer structure
+ *			to which this setup belongs.
+ *	ctemplate	documents matching this template
+ *			are protected according to this setup.
+ *	valid_schemes	a list containing all valid authentication
+ *			schemes for this setup.
+ *			If NULL, all schemes are disallowed.
+ *	scheme_specifics is an array of assoc lists, which
+ *			contain scheme specific parameters given
+ *			by server in Authenticate: fields.
+ *			If NULL, all scheme specifics are
+ *			set to NULL.
+ * ON EXIT:
+ *	returns		a new HTAASetup node, and also adds it as
+ *			part of the HTAAServer given as parameter.
+ */
+static HTAASetup *HTAASetup_new(HTAAServer *server, char *ctemplate,
+				HTList *valid_schemes,
+				HTAssocList **scheme_specifics)
 {
     HTAASetup *setup;
 
-    if (!server || isEmpty(template))
+    if (!server || isEmpty(ctemplate))
 	return NULL;
 
     if ((setup = typecalloc(HTAASetup)) == 0)
@@ -401,32 +394,31 @@
 
     setup->retry = NO;
     setup->server = server;
-    setup->template = NULL;
-    if (template)
-	StrAllocCopy(setup->template, template);
+    setup->ctemplate = NULL;
+    if (ctemplate)
+	StrAllocCopy(setup->ctemplate, ctemplate);
     setup->valid_schemes = valid_schemes;
     setup->scheme_specifics = scheme_specifics;
 
-    HTList_addObject(server->setups, (void*)setup);
+    HTList_addObject(server->setups, (void *) setup);
 
     return setup;
 }
 
-/* PRIVATE						HTAASetup_delete()
-**			FREE A HTAASetup STRUCTURE
-** ON ENTRY:
-**	killme		is a pointer to the structure to free().
-**
-** ON EXIT:
-**	returns		nothing.
-*/
-PRIVATE void HTAASetup_delete ARGS1(
-	HTAASetup *,	killme)
+/* static						HTAASetup_delete()
+ *			FREE A HTAASetup STRUCTURE
+ * ON ENTRY:
+ *	killme		is a pointer to the structure to free().
+ *
+ * ON EXIT:
+ *	returns		nothing.
+ */
+static void HTAASetup_delete(HTAASetup * killme)
 {
     int scheme;
 
     if (killme) {
-	FREE(killme->template);
+	FREE(killme->ctemplate);
 	if (killme->valid_schemes) {
 	    HTList_delete(killme->valid_schemes);
 	    killme->valid_schemes = NULL;
@@ -439,22 +431,20 @@
     }
 }
 
-/* PRIVATE					HTAASetup_updateSpecifics()
-*		COPY SCHEME SPECIFIC PARAMETERS
-**		TO HTAASetup STRUCTURE
-** ON ENTRY:
-**	setup		destination setup structure.
-**	specifics	string array containing scheme
-**			specific parameters for each scheme.
-**			If NULL, all the scheme specific
-**			parameters are set to NULL.
-**
-** ON EXIT:
-**	returns		nothing.
-*/
-PRIVATE void HTAASetup_updateSpecifics ARGS2(
-	HTAASetup *,	setup,
-	HTAssocList **,	specifics)
+/* static					HTAASetup_updateSpecifics()
+ *		COPY SCHEME SPECIFIC PARAMETERS
+ *		TO HTAASetup STRUCTURE
+ * ON ENTRY:
+ *	setup		destination setup structure.
+ *	specifics	string array containing scheme
+ *			specific parameters for each scheme.
+ *			If NULL, all the scheme specific
+ *			parameters are set to NULL.
+ *
+ * ON EXIT:
+ *	returns		nothing.
+ */
+static void HTAASetup_updateSpecifics(HTAASetup * setup, HTAssocList **specifics)
 {
     int scheme;
 
@@ -470,54 +460,51 @@
     }
 }
 
-
 /*************************** HTAARealm **********************************/
 
-/* PRIVATE						HTAARealm_lookup()
-**		LOOKUP HTAARealm STRUCTURE BY REALM NAME
-** ON ENTRY:
-**	realm_table	a list of realm objects.
-**	realmname	is the name of realm to look for.
-**
-** ON EXIT:
-**	returns		the realm.  NULL, if not found.
-*/
-PRIVATE HTAARealm *HTAARealm_lookup ARGS2(
-	HTList *,	realm_table,
-	CONST char *,	realmname)
+/* static						HTAARealm_lookup()
+ *		LOOKUP HTAARealm STRUCTURE BY REALM NAME
+ * ON ENTRY:
+ *	realm_table	a list of realm objects.
+ *	realmname	is the name of realm to look for.
+ *
+ * ON EXIT:
+ *	returns		the realm.  NULL, if not found.
+ */
+static HTAARealm *HTAARealm_lookup(HTList *realm_table,
+				   const char *realmname)
 {
     if (realm_table && realmname) {
 	HTList *cur = realm_table;
 	HTAARealm *realm;
 
-	while (NULL != (realm = (HTAARealm*)HTList_nextObject(cur))) {
-	    if (0==strcmp(realm->realmname, realmname))
+	while (NULL != (realm = (HTAARealm *) HTList_nextObject(cur))) {
+	    if (0 == strcmp(realm->realmname, realmname))
 		return realm;
 	}
     }
-    return NULL;	/* No table, NULL param, or not found */
+    return NULL;		/* No table, NULL param, or not found */
 }
 
-/* PRIVATE						HTAARealm_new()
-**		CREATE A NODE CONTAINING USERNAME AND
-**		PASSWORD USED FOR THE GIVEN REALM.
-**		IF REALM ALREADY EXISTS, CHANGE
-**		USERNAME/PASSWORD.
-** ON ENTRY:
-**	realm_table	a list of realms to where to add
-**			the new one, too.
-**	realmname	is the name of the password domain.
-**	username	and
-**	password	are what you can expect them to be.
-**
-** ON EXIT:
-**	returns		the created realm.
-*/
-PRIVATE HTAARealm *HTAARealm_new ARGS4(
-	HTList *,	realm_table,
-	CONST char *,	realmname,
-	CONST char *,	username,
-	CONST char *,	password)
+/* static						HTAARealm_new()
+ *		CREATE A NODE CONTAINING USERNAME AND
+ *		PASSWORD USED FOR THE GIVEN REALM.
+ *		IF REALM ALREADY EXISTS, CHANGE
+ *		USERNAME/PASSWORD.
+ * ON ENTRY:
+ *	realm_table	a list of realms to where to add
+ *			the new one, too.
+ *	realmname	is the name of the password domain.
+ *	username	and
+ *	password	are what you can expect them to be.
+ *
+ * ON EXIT:
+ *	returns		the created realm.
+ */
+static HTAARealm *HTAARealm_new(HTList *realm_table,
+				const char *realmname,
+				const char *username,
+				const char *password)
 {
     HTAARealm *realm;
 
@@ -525,13 +512,14 @@
 
     if (!realm) {
 	if ((realm = typecalloc(HTAARealm)) == 0)
-	    outofmem(__FILE__, "HTAARealm_new");
+	      outofmem(__FILE__, "HTAARealm_new");
+
 	realm->realmname = NULL;
 	realm->username = NULL;
 	realm->password = NULL;
 	StrAllocCopy(realm->realmname, realmname);
 	if (realm_table)
-	    HTList_addObject(realm_table, (void*)realm);
+	    HTList_addObject(realm_table, (void *) realm);
     }
     if (username)
 	StrAllocCopy(realm->username, username);
@@ -541,34 +529,30 @@
     return realm;
 }
 
-
 /***************** Basic and Pubkey Authentication ************************/
 
-/* PRIVATE						compose_auth_string()
-**
-**		COMPOSE Basic OR Pubkey AUTHENTICATION STRING;
-**		PROMPTS FOR USERNAME AND PASSWORD IF NEEDED
-**
-** ON ENTRY:
-**	scheme		is either HTAA_BASIC or HTAA_PUBKEY.
-**	setup		is the current server setup.
-**	IsProxy		should be TRUE if this is a proxy.
-**
-** ON EXIT:
-**	returns		a newly composed authorization string,
-**			(with, of course, a newly generated secret
-**			key and fresh timestamp, if Pubkey-scheme
-**			is being used).
-**			NULL, if something fails.
-** NOTE:
-**	Like throughout the entire AA package, no string or structure
-**	returned by AA package needs to (or should) be freed.
-**
-*/
-PRIVATE char *compose_auth_string ARGS3(
-	HTAAScheme,	scheme,
-	HTAASetup *,	setup,
-	BOOL,		IsProxy)
+/* static						compose_auth_string()
+ *
+ *		COMPOSE Basic OR Pubkey AUTHENTICATION STRING;
+ *		PROMPTS FOR USERNAME AND PASSWORD IF NEEDED
+ *
+ * ON ENTRY:
+ *	scheme		is either HTAA_BASIC or HTAA_PUBKEY.
+ *	setup		is the current server setup.
+ *	IsProxy		should be TRUE if this is a proxy.
+ *
+ * ON EXIT:
+ *	returns		a newly composed authorization string,
+ *			(with, of course, a newly generated secret
+ *			key and fresh timestamp, if Pubkey-scheme
+ *			is being used).
+ *			NULL, if something fails.
+ * NOTE:
+ *	Like throughout the entire AA package, no string or structure
+ *	returned by AA package needs to (or should) be freed.
+ *
+ */
+static char *compose_auth_string(HTAAScheme scheme, HTAASetup * setup, BOOL IsProxy)
 {
     char *cleartext = NULL;	/* Cleartext presentation */
     char *ciphertext = NULL;	/* Encrypted presentation */
@@ -581,15 +565,14 @@
     char *proxiedHost = NULL;
     char *thePort = NULL;
     HTAARealm *realm;
-    char *i_net_addr = "0.0.0.0";	/* Change... @@@@ */
-    char *timestamp = "42";		/* ... these @@@@ */
-
+    const char *i_net_addr = "0.0.0.0";		/* Change... @@@@ */
+    const char *timestamp = "42";	/* ... these @@@@ */
 
     FREE(compose_auth_stringResult);	/* From previous call */
 
     if ((scheme != HTAA_BASIC && scheme != HTAA_PUBKEY) || !setup ||
 	!setup->scheme_specifics || !setup->scheme_specifics[scheme] ||
-	!setup->server  ||  !setup->server->realms)
+	!setup->server || !setup->server->realms)
 	return NULL;
 
     realmname = HTAssocList_lookup(setup->scheme_specifics[scheme], "realm");
@@ -602,31 +585,28 @@
 	  realm->password) || setup->retry) {
 	if (!realm) {
 	    CTRACE((tfp, "%s `%s' %s\n",
-			"compose_auth_string: realm:", realmname,
-			"not found -- creating"));
+		    "compose_auth_string: realm:", realmname,
+		    "not found -- creating"));
 	    realm = HTAARealm_new(setup->server->realms,
 				  realmname, NULL, NULL);
 	}
 	/*
-	 *  The template should be either the '*' global
-	 *  for everything on the server (always true for
-	 *  proxy authorization setups), or a path for
-	 *  the start of a protected limb, with no host
-	 *  field, but we'll check for a host anyway in
-	 *  case a WWW-Protection-Template header set an
-	 *  absolute URL instead of a path.  If we do get
-	 *  a host from this, it will include the port. - FM
+	 * The template should be either the '*' global for everything on the
+	 * server (always true for proxy authorization setups), or a path for
+	 * the start of a protected limb, with no host field, but we'll check
+	 * for a host anyway in case a WWW-Protection-Template header set an
+	 * absolute URL instead of a path.  If we do get a host from this, it
+	 * will include the port.  - FM
 	 */
-	if ((!IsProxy) && using_proxy && setup->template) {
-	    proxiedHost = HTParse(setup->template, "", PARSE_HOST);
+	if ((!IsProxy) && using_proxy && setup->ctemplate) {
+	    proxiedHost = HTParse(setup->ctemplate, "", PARSE_HOST);
 	    if (proxiedHost && *proxiedHost != '\0') {
 		theHost = proxiedHost;
 	    }
 	}
 	/*
-	 *  If we didn't get a host field from the
-	 *  template, set up the host name and port
-	 *  from the setup->server elements. - FM
+	 * If we didn't get a host field from the template, set up the host
+	 * name and port from the setup->server elements.  - FM
 	 */
 	if (!theHost)
 	    theHost = setup->server->hostname;
@@ -635,20 +615,19 @@
 	    HTSprintf0(&thePort, ":%d", setup->server->portnumber);
 	}
 	/*
-	 *  Set up the message for the username prompt,
-	 *  and then issue the prompt.  The default
-	 *  username is included in the call to the
-	 *  prompting function, but the password is
-	 *  NULL-ed and always replaced. - FM
+	 * Set up the message for the username prompt, and then issue the
+	 * prompt.  The default username is included in the call to the
+	 * prompting function, but the password is NULL-ed and always replaced. 
+	 * - FM
 	 */
 	len = strlen(realm->realmname) +
-	      strlen(theHost ?
-		     theHost : "??") + 50;
+	    strlen(theHost ?
+		   theHost : "??") + 50;
 	HTSprintf0(&msg, gettext("Username for '%s' at %s '%s%s':"),
-		     realm->realmname,
-		     (IsProxy ? "proxy" : "server"),
-		     (theHost ? theHost : "??"),
-		     NonNull(thePort));
+		   realm->realmname,
+		   (IsProxy ? "proxy" : "server"),
+		   (theHost ? theHost : "??"),
+		   NonNull(thePort));
 	FREE(proxiedHost);
 	FREE(thePort);
 	username = realm->username;
@@ -663,12 +642,12 @@
 
 	if (!realm->username || !realm->password) {
 	    /*
-	     *  Signals to retry. - FM
+	     * Signals to retry.  - FM
 	     */
 	    return NULL;
 	} else if (*realm->username == '\0') {
 	    /*
-	     *  Signals to abort. - FM
+	     * Signals to abort.  - FM
 	     */
 	    StrAllocCopy(compose_auth_stringResult, "");
 	    return compose_auth_stringResult;
@@ -676,7 +655,7 @@
     }
 
     len = strlen(NonNull(realm->username)) +
-	  strlen(NonNull(realm->password)) + 3;
+	strlen(NonNull(realm->password)) + 3;
 
     if (scheme == HTAA_PUBKEY) {
 #ifdef PUBKEY
@@ -690,7 +669,7 @@
     }
 
     if ((cleartext = typecallocn(char, len)) == 0)
-	outofmem(__FILE__, "compose_auth_string");
+	  outofmem(__FILE__, "compose_auth_string");
 
     if (realm->username)
 	strcpy(cleartext, realm->username);
@@ -712,77 +691,77 @@
 	    strcat(cleartext, secret_key);
 
 	if (!((ciphertext = typecallocn(char, 2 * len)) &&
-	      (compose_auth_stringResult = typecallocn(char, 3 * len))))
-	    outofmem(__FILE__, "compose_auth_string");
+	        (compose_auth_stringResult = typecallocn(char, 3 * len))))
+	      outofmem(__FILE__, "compose_auth_string");
+
 #ifdef PUBKEY
 	HTPK_encrypt(cleartext, ciphertext, server->public_key);
-	HTUU_encode((unsigned char *)ciphertext, strlen(ciphertext),
+	HTUU_encode((unsigned char *) ciphertext, strlen(ciphertext),
 		    compose_auth_stringResult);
 #endif /* PUBKEY */
 	FREE(cleartext);
 	FREE(ciphertext);
-    }
-    else { /* scheme == HTAA_BASIC */
+    } else {			/* scheme == HTAA_BASIC */
 	if (!(compose_auth_stringResult =
-				typecallocn(char, (4 * ((len+2)/3)) + 1)))
-	    outofmem(__FILE__, "compose_auth_string");
-	HTUU_encode((unsigned char *)cleartext, strlen(cleartext),
+	      typecallocn(char, (4 * ((len + 2) / 3)) + 1)))
+	      outofmem(__FILE__, "compose_auth_string");
+
+	HTUU_encode((unsigned char *) cleartext, strlen(cleartext),
 		    compose_auth_stringResult);
 	FREE(cleartext);
     }
     return compose_auth_stringResult;
 }
 
-/* BROWSER PRIVATE					HTAA_selectScheme()
-**		SELECT THE AUTHENTICATION SCHEME TO USE
-** ON ENTRY:
-**	setup	is the server setup structure which can
-**		be used to make the decision about the
-**		used scheme.
-**
-**	When new authentication methods are added to library
-**	this function makes the decision about which one to
-**	use at a given time.  This can be done by inspecting
-**	environment variables etc.
-**
-**	Currently only searches for the first valid scheme,
-**	and if nothing found suggests Basic scheme;
-**
-** ON EXIT:
-**	returns	the authentication scheme to use.
-*/
-PRIVATE HTAAScheme HTAA_selectScheme ARGS1(
-	HTAASetup *,	setup)
+/* BROWSER static					HTAA_selectScheme()
+ *		SELECT THE AUTHENTICATION SCHEME TO USE
+ * ON ENTRY:
+ *	setup	is the server setup structure which can
+ *		be used to make the decision about the
+ *		used scheme.
+ *
+ *	When new authentication methods are added to library
+ *	this function makes the decision about which one to
+ *	use at a given time.  This can be done by inspecting
+ *	environment variables etc.
+ *
+ *	Currently only searches for the first valid scheme,
+ *	and if nothing found suggests Basic scheme;
+ *
+ * ON EXIT:
+ *	returns	the authentication scheme to use.
+ */
+static HTAAScheme HTAA_selectScheme(HTAASetup * setup)
 {
-    HTAAScheme scheme;
+    int scheme;
 
     if (setup && setup->valid_schemes) {
 	for (scheme = HTAA_BASIC; scheme < HTAA_MAX_SCHEMES; scheme++)
-	    if (-1 < HTList_indexOf(setup->valid_schemes, (void*)scheme))
-		return scheme;
+	    if (-1 < HTList_indexOf(setup->valid_schemes, (void *) scheme))
+		return (HTAAScheme) scheme;
     }
     return HTAA_BASIC;
 }
 
 /*
-**  Purpose:	Free off all module globals.
-**  Arguments:	void
-**  Return Value:	void
-**  Remarks/Portability/Dependencies/Restrictions:
-**	To be used at program exit.
-**  Revision History:
-**	06-19-96	created - FM
-*/
-PRIVATE void free_HTAAGlobals NOARGS
+ *  Purpose:	Free off all module globals.
+ *  Arguments:	void
+ *  Return Value:	void
+ *  Remarks/Portability/Dependencies/Restrictions:
+ *	To be used at program exit.
+ *  Revision History:
+ *	06-19-96	created - FM
+ */
+static void free_HTAAGlobals(void)
 {
-    HTAAServer * server;
+    HTAAServer *server;
     int n, i;
 
     if (server_table != NULL) {
 	n = HTList_count(server_table);
 	for (i = (n - 1); i >= 0; i--) {
-	    if ((server = (HTAAServer*)HTList_objectAt(server_table,
-							i)) != NULL) {
+	    if ((server = (HTAAServer *) HTList_objectAt(server_table,
+							 i)) != NULL) {
 		HTAAServer_delete(server);
 		server = NULL;
 	    }
@@ -802,30 +781,29 @@
 }
 
 /* BROWSER PUBLIC					HTAA_composeAuth()
-**
-**	SELECT THE AUTHENTICATION SCHEME AND
-**	COMPOSE THE ENTIRE AUTHORIZATION HEADER LINE
-**	IF WE ALREADY KNOW THAT THE HOST REQUIRES AUTHENTICATION
-**
-** ON ENTRY:
-**	hostname	is the hostname of the server.
-**	portnumber	is the portnumber in which the server runs.
-**	docname		is the pathname of the document (as in URL)
-**	IsProxy		should be TRUE if this is a proxy.
-**
-** ON EXIT:
-**	returns	NULL, if no authorization seems to be needed, or
-**		if it is the entire Authorization: line, e.g.
-**
-**		   "Authorization: Basic username:password"
-**
-**		As usual, this string is automatically freed.
-*/
-PUBLIC char *HTAA_composeAuth ARGS4(
-	CONST char *,	hostname,
-	CONST int,	portnumber,
-	CONST char *,	docname,
-	BOOL,		IsProxy)
+ *
+ *	SELECT THE AUTHENTICATION SCHEME AND
+ *	COMPOSE THE ENTIRE AUTHORIZATION HEADER LINE
+ *	IF WE ALREADY KNOW THAT THE HOST REQUIRES AUTHENTICATION
+ *
+ * ON ENTRY:
+ *	hostname	is the hostname of the server.
+ *	portnumber	is the portnumber in which the server runs.
+ *	docname		is the pathname of the document (as in URL)
+ *	IsProxy		should be TRUE if this is a proxy.
+ *
+ * ON EXIT:
+ *	returns	NULL, if no authorization seems to be needed, or
+ *		if it is the entire Authorization: line, e.g.
+ *
+ *		   "Authorization: Basic username:password"
+ *
+ *		As usual, this string is automatically freed.
+ */
+char *HTAA_composeAuth(const char *hostname,
+		       const int portnumber,
+		       const char *docname,
+		       BOOL IsProxy)
 {
     char *auth_string;
     BOOL retry;
@@ -833,8 +811,8 @@
     int len;
 
     /*
-    **  Setup atexit() freeing if not done already. - FM
-    */
+     * Setup atexit() freeing if not done already.  - FM
+     */
     if (!free_HTAAGlobalsSet) {
 #ifdef LY_FIND_LEAKS
 	atexit(free_HTAAGlobals);
@@ -843,17 +821,16 @@
     }
 
     /*
-    ** Make gateway httpds pass authorization field as it was received.
-    ** (This still doesn't really work because Authenticate: headers
-    **  from remote server are not forwarded to client yet so it cannot
-    **  really know that it should send authorization;  I will not
-    **  implement it yet because I feel we will soon change radically
-    **  the way requests are represented to allow multithreading
-    **  on server-side.  Life is hard.)
-    */
+     * Make gateway httpds pass authorization field as it was received.  (This
+     * still doesn't really work because Authenticate:  headers from remote
+     * server are not forwarded to client yet so it cannot really know that it
+     * should send authorization; I will not implement it yet because I feel we
+     * will soon change radically the way requests are represented to allow
+     * multithreading on server-side.  Life is hard.)
+     */
     if (HTAAForwardAuth) {
 	CTRACE((tfp, "HTAA_composeAuth: %s\n",
-		    "Forwarding received authorization"));
+		"Forwarding received authorization"));
 	StrAllocCopy(HTAA_composeAuthResult, HTAAForwardAuth);
 	HTAAForwardAuth_reset();	/* Just a precaution */
 	return HTAA_composeAuthResult;
@@ -863,15 +840,15 @@
 
     if (IsProxy) {
 	/*
-	**  Proxy Authorization required. - AJL
-	*/
+	 * Proxy Authorization required.  - AJL
+	 */
 
 	CTRACE((tfp, "Composing Proxy Authorization for %s:%d/%s\n",
-		    hostname, portnumber, docname));
+		hostname, portnumber, docname));
 
-	if (proxy_portnumber  != portnumber       ||
-	    !proxy_hostname   || !proxy_docname   ||
-	    !hostname         || !docname         ||
+	if (proxy_portnumber != portnumber ||
+	    !proxy_hostname || !proxy_docname ||
+	    !hostname || !docname ||
 	    0 != strcmp(proxy_hostname, hostname) ||
 	    0 != strcmp(proxy_docname, docname)) {
 
@@ -900,53 +877,55 @@
 	    return NULL;
 
 	switch (scheme = HTAA_selectScheme(proxy_setup)) {
-	  case HTAA_BASIC:
-	  case HTAA_PUBKEY:
+	case HTAA_BASIC:
+	case HTAA_PUBKEY:
 	    auth_string = compose_auth_string(scheme, proxy_setup, IsProxy);
 	    break;
-	  case HTAA_KERBEROS_V4:
+	case HTAA_KERBEROS_V4:
 	    /* OTHER AUTHENTICATION ROUTINES ARE CALLED HERE */
-	  default:
+	default:
 	    {
 		char *msg = NULL;
+
 		HTSprintf0(&msg, "%s `%s'",
-			gettext("This client doesn't know how to compose proxy authorization information for scheme"),
-			HTAAScheme_name(scheme));
+			   gettext("This client doesn't know how to compose proxy authorization information for scheme"),
+			   HTAAScheme_name(scheme));
 		HTAlert(msg);
 		FREE(msg);
 		auth_string = NULL;
 	    }
-	} /* switch scheme */
+	}			/* switch scheme */
 
 	proxy_setup->retry = NO;
 
 	if (!auth_string)
 	    /*
-	    **  Signal a failure. - FM
-	    */
-	    return NULL;  /* Added by marca. */
+	     * Signal a failure.  - FM
+	     */
+	    return NULL;	/* Added by marca. */
 	if (*auth_string == '\0') {
 	    /*
-	    **  Signal an abort. - FM
-	    */
+	     * Signal an abort.  - FM
+	     */
 	    StrAllocCopy(HTAA_composeAuthResult, "");
-	    return(HTAA_composeAuthResult);
+	    return (HTAA_composeAuthResult);
 	}
-	len = strlen(auth_string) + strlen((char *)HTAAScheme_name(scheme)) + 26;
+	len = strlen(auth_string) + strlen(HTAAScheme_name(scheme)) + 26;
 	if ((HTAA_composeAuthResult = typecallocn(char, len)) == 0)
-	    outofmem(__FILE__, "HTAA_composeAuth");
+	      outofmem(__FILE__, "HTAA_composeAuth");
+
 	strcpy(HTAA_composeAuthResult, "Proxy-Authorization: ");
 
     } else {
 	/*
-	**  Normal WWW authorization.
-	*/
+	 * Normal WWW authorization.
+	 */
 	CTRACE((tfp, "Composing Authorization for %s:%d/%s\n",
-		    hostname, portnumber, docname));
+		hostname, portnumber, docname));
 
 	if (current_portnumber != portnumber ||
 	    !current_hostname || !current_docname ||
-	    !hostname         || !docname         ||
+	    !hostname || !docname ||
 	    0 != strcmp(current_hostname, hostname) ||
 	    0 != strcmp(current_docname, docname)) {
 
@@ -975,42 +954,44 @@
 	    return NULL;
 
 	switch (scheme = HTAA_selectScheme(current_setup)) {
-	  case HTAA_BASIC:
-	  case HTAA_PUBKEY:
+	case HTAA_BASIC:
+	case HTAA_PUBKEY:
 	    auth_string = compose_auth_string(scheme, current_setup, IsProxy);
 	    break;
-	  case HTAA_KERBEROS_V4:
+	case HTAA_KERBEROS_V4:
 	    /* OTHER AUTHENTICATION ROUTINES ARE CALLED HERE */
-	  default:
+	default:
 	    {
 		char *msg = 0;
+
 		HTSprintf0(&msg, "%s `%s'",
-			gettext("This client doesn't know how to compose authorization information for scheme"),
-			HTAAScheme_name(scheme));
+			   gettext("This client doesn't know how to compose authorization information for scheme"),
+			   HTAAScheme_name(scheme));
 		HTAlert(msg);
 		FREE(msg);
 		auth_string = NULL;
 	    }
-	} /* switch scheme */
+	}			/* switch scheme */
 
 	current_setup->retry = NO;
 
 	if (!auth_string)
 	    /*
-	    **  Signal a failure. - FM
-	    */
-	    return NULL;  /* Added by marca. */
+	     * Signal a failure.  - FM
+	     */
+	    return NULL;	/* Added by marca. */
 	if (*auth_string == '\0') {
 	    /*
-	    **  Signal an abort. - FM
-	    */
+	     * Signal an abort.  - FM
+	     */
 	    StrAllocCopy(HTAA_composeAuthResult, "");
-	    return(HTAA_composeAuthResult);
+	    return (HTAA_composeAuthResult);
 	}
 
-	len = strlen(auth_string) + strlen((char *)HTAAScheme_name(scheme)) + 20;
+	len = strlen(auth_string) + strlen(HTAAScheme_name(scheme)) + 20;
 	if ((HTAA_composeAuthResult = typecallocn(char, len)) == 0)
-	    outofmem(__FILE__, "HTAA_composeAuth");
+	      outofmem(__FILE__, "HTAA_composeAuth");
+
 	strcpy(HTAA_composeAuthResult, "Authorization: ");
     }
 
@@ -1021,50 +1002,49 @@
 }
 
 /* BROWSER PUBLIC				HTAA_shouldRetryWithAuth()
-**
-**		DETERMINES IF WE SHOULD RETRY THE SERVER
-**		WITH AUTHORIZATION
-**		(OR IF ALREADY RETRIED, WITH A DIFFERENT
-**		USERNAME AND/OR PASSWORD (IF MISSPELLED))
-** ON ENTRY:
-**	start_of_headers is the first block already read from socket,
-**			but status line skipped; i.e., points to the
-**			start of the header section.
-**	length		is the remaining length of the first block.
-**	soc		is the socket to read the rest of server reply.
-**	IsProxy		should be TRUE if this is a proxy.
-**
-**			This function should only be called when
-**			server has replied with a 401 (Unauthorized)
-**			status code.
-** ON EXIT:
-**	returns		YES, if connection should be retried.
-**			     The node containing all the necessary
-**			     information is
-**				* either constructed if it does not exist
-**				* or password is reset to NULL to indicate
-**				  that username and password should be
-**				  reprompted when composing Authorization:
-**				  field (in function HTAA_composeAuth()).
-**			NO, otherwise.
-*/
-PUBLIC BOOL HTAA_shouldRetryWithAuth ARGS4(
-	char *,		start_of_headers,
-	int,		length,
-	int,		soc,
-	BOOL,		IsProxy)
+ *
+ *		DETERMINES IF WE SHOULD RETRY THE SERVER
+ *		WITH AUTHORIZATION
+ *		(OR IF ALREADY RETRIED, WITH A DIFFERENT
+ *		USERNAME AND/OR PASSWORD (IF MISSPELLED))
+ * ON ENTRY:
+ *	start_of_headers is the first block already read from socket,
+ *			but status line skipped; i.e., points to the
+ *			start of the header section.
+ *	length		is the remaining length of the first block.
+ *	soc		is the socket to read the rest of server reply.
+ *	IsProxy		should be TRUE if this is a proxy.
+ *
+ *			This function should only be called when
+ *			server has replied with a 401 (Unauthorized)
+ *			status code.
+ * ON EXIT:
+ *	returns		YES, if connection should be retried.
+ *			     The node containing all the necessary
+ *			     information is
+ *				* either constructed if it does not exist
+ *				* or password is reset to NULL to indicate
+ *				  that username and password should be
+ *				  reprompted when composing Authorization:
+ *				  field (in function HTAA_composeAuth()).
+ *			NO, otherwise.
+ */
+BOOL HTAA_shouldRetryWithAuth(char *start_of_headers,
+			      int length,
+			      int soc,
+			      BOOL IsProxy)
 {
     HTAAScheme scheme;
     char *line = NULL;
     int num_schemes = 0;
     HTList *valid_schemes = HTList_new();
     HTAssocList **scheme_specifics = NULL;
-    char *template = NULL;
+    char *ctemplate = NULL;
     char *temp = NULL;
 
     /*
-    **  Setup atexit() freeing if not done already. - FM
-    */
+     * Setup atexit() freeing if not done already.  - FM
+     */
     if (!free_HTAAGlobalsSet) {
 #ifdef LY_FIND_LEAKS
 	atexit(free_HTAAGlobals);
@@ -1073,12 +1053,12 @@
     }
 
     /*
-    **  Read server reply header lines
-    */
+     * Read server reply header lines
+     */
     CTRACE((tfp, "Server reply header lines:\n"));
 
     HTAA_setupReader(start_of_headers, length, soc);
-    while (NULL != (line = HTAA_getUnfoldedLine())  &&  *line != '\0') {
+    while (NULL != (line = HTAA_getUnfoldedLine()) && *line != '\0') {
 	CTRACE((tfp, "%s\n", line));
 
 	if (strchr(line, ':')) {	/* Valid header line */
@@ -1089,27 +1069,28 @@
 	    char *args = p;
 
 	    if ((IsProxy &&
-		 0==strcasecomp(fieldname, "Proxy-Authenticate:")) ||
+		 0 == strcasecomp(fieldname, "Proxy-Authenticate:")) ||
 		(!IsProxy &&
-		 0==strcasecomp(fieldname, "WWW-Authenticate:"))) {
+		 0 == strcasecomp(fieldname, "WWW-Authenticate:"))) {
 		if (!(arg1 && *arg1 && args && *args)) {
 		    HTSprintf0(&temp, gettext("Invalid header '%s%s%s%s%s'"), line,
-				  ((arg1 && *arg1) ? " "  : ""),
-				  ((arg1 && *arg1) ? arg1 : ""),
-				  ((args && *args) ? " "  : ""),
-				  ((args && *args) ? args : ""));
+			       (!isEmpty(arg1) ? " " : ""),
+			       (!isEmpty(arg1) ? arg1 : ""),
+			       (!isEmpty(args) ? " " : ""),
+			       (!isEmpty(args) ? args : ""));
 		    HTAlert(temp);
 		    FREE(temp);
-		}
-		else if (HTAA_UNKNOWN != (scheme = HTAAScheme_enum(arg1))) {
-		    HTList_addObject(valid_schemes, (void*)scheme);
+		} else if (HTAA_UNKNOWN != (scheme = HTAAScheme_enum(arg1))) {
+		    HTList_addObject(valid_schemes, (void *) scheme);
 		    if (!scheme_specifics) {
 			int i;
+
 			scheme_specifics =
 			    typecallocn(HTAssocList *, HTAA_MAX_SCHEMES);
+
 			if (!scheme_specifics)
 			    outofmem(__FILE__, "HTAA_shouldRetryWithAuth");
-			for (i=0; i < HTAA_MAX_SCHEMES; i++)
+			for (i = 0; i < HTAA_MAX_SCHEMES; i++)
 			    scheme_specifics[i] = NULL;
 		    }
 		    scheme_specifics[scheme] = HTAA_parseArgList(args);
@@ -1124,44 +1105,41 @@
 	    }
 
 	    else if (!IsProxy &&
-		     0==strcasecomp(fieldname, "WWW-Protection-Template:")) {
+		     0 == strcasecomp(fieldname, "WWW-Protection-Template:")) {
 		CTRACE((tfp, "Protection template set to `%s'\n", arg1));
-		StrAllocCopy(template, arg1);
+		StrAllocCopy(ctemplate, arg1);
 	    }
 
-	} /* if a valid header line */
-	else {
+	} else {
 	    CTRACE((tfp, "Invalid header line `%s' ignored\n", line));
-	} /* else invalid header line */
+	}
 
 	FREE(line);
-    } /* while header lines remain */
+    }				/* while header lines remain */
     FREE(line);
 
-
     /*
-    **  So should we retry with authorization?
-    */
+     * So should we retry with authorization?
+     */
     if (IsProxy) {
 	if (num_schemes == 0) {
 	    /*
-	    **  No proxy authorization valid
-	    */
+	     * No proxy authorization valid
+	     */
 	    proxy_setup = NULL;
 	    return NO;
 	}
 	/*
-	**  Doing it for proxy.  -AJL
-	*/
+	 * Doing it for proxy.  -AJL
+	 */
 	if (proxy_setup && proxy_setup->server) {
 	    /*
-	    **  We have already tried with proxy authorization.
-	    **  Either we don't have access or username or
-	    **  password was misspelled.
-	    **
-	    **  Update scheme-specific parameters
-	    **  (in case they have expired by chance).
-	    */
+	     * We have already tried with proxy authorization.  Either we don't
+	     * have access or username or password was misspelled.
+	     *
+	     * Update scheme-specific parameters (in case they have expired by
+	     * chance).
+	     */
 	    HTAASetup_updateSpecifics(proxy_setup, scheme_specifics);
 
 	    if (NO == HTConfirm(AUTH_FAILED_PROMPT)) {
@@ -1169,33 +1147,33 @@
 		return NO;
 	    } else {
 		/*
-		**  Re-ask username+password (if misspelled).
-		*/
+		 * Re-ask username+password (if misspelled).
+		 */
 		proxy_setup->retry = YES;
 		return YES;
 	    }
 	} else {
 	    /*
-	    **  proxy_setup == NULL, i.e., we have a
-	    **  first connection to a protected server or
-	    **  the server serves a wider set of documents
-	    **  than we expected so far.
-	    */
+	     * proxy_setup == NULL, i.e., we have a first connection to a
+	     * protected server or the server serves a wider set of documents
+	     * than we expected so far.
+	     */
 	    HTAAServer *server = HTAAServer_lookup(proxy_hostname,
 						   proxy_portnumber,
 						   IsProxy);
+
 	    if (!server) {
 		server = HTAAServer_new(proxy_hostname,
 					proxy_portnumber,
 					IsProxy);
 	    }
-	    if (!template)	/* Proxy matches everything  -AJL */
-		StrAllocCopy(template, "*");
+	    if (!ctemplate)	/* Proxy matches everything  -AJL */
+		StrAllocCopy(ctemplate, "*");
 	    proxy_setup = HTAASetup_new(server,
-					  template,
-					  valid_schemes,
-					  scheme_specifics);
-	    FREE(template);
+					ctemplate,
+					valid_schemes,
+					scheme_specifics);
+	    FREE(ctemplate);
 
 	    HTAlert(gettext("Proxy authorization required -- retrying"));
 	    return YES;
@@ -1203,24 +1181,23 @@
 	/* Never reached */
     }
     /*
-    **  Normal WWW authorization.
-    */
+     * Normal WWW authorization.
+     */
     if (num_schemes == 0) {
 	/*
-	**  No authorization valid.
-	*/
+	 * No authorization valid.
+	 */
 	current_setup = NULL;
 	return NO;
     }
     if (current_setup && current_setup->server) {
 	/*
-	**  So we have already tried with WWW authorization.
-	**  Either we don't have access or username or
-	**  password was misspelled.
-	**
-	**  Update scheme-specific parameters
-	**  (in case they have expired by chance).
-	*/
+	 * So we have already tried with WWW authorization.  Either we don't
+	 * have access or username or password was misspelled.
+	 *
+	 * Update scheme-specific parameters (in case they have expired by
+	 * chance).
+	 */
 	HTAASetup_updateSpecifics(current_setup, scheme_specifics);
 
 	if (NO == HTConfirm(AUTH_FAILED_PROMPT)) {
@@ -1228,33 +1205,33 @@
 	    return NO;
 	} else {
 	    /*
-	    **  Re-ask username+password (if misspelled).
-	    */
+	     * Re-ask username+password (if misspelled).
+	     */
 	    current_setup->retry = YES;
 	    return YES;
 	}
     } else {
 	/*
-	**  current_setup == NULL, i.e., we have a
-	**  first connection to a protected server or
-	**  the server serves a wider set of documents
-	**  than we expected so far.
-	*/
+	 * current_setup == NULL, i.e., we have a first connection to a
+	 * protected server or the server serves a wider set of documents than
+	 * we expected so far.
+	 */
 	HTAAServer *server = HTAAServer_lookup(current_hostname,
 					       current_portnumber,
 					       IsProxy);
+
 	if (!server) {
 	    server = HTAAServer_new(current_hostname,
 				    current_portnumber,
 				    IsProxy);
 	}
-	if (!template)
-	    template = HTAA_makeProtectionTemplate(current_docname);
+	if (!ctemplate)
+	    ctemplate = HTAA_makeProtectionTemplate(current_docname);
 	current_setup = HTAASetup_new(server,
-				      template,
+				      ctemplate,
 				      valid_schemes,
 				      scheme_specifics);
-	FREE(template);
+	FREE(ctemplate);
 
 	HTAlert(gettext("Access without authorization denied -- retrying"));
 	return YES;
@@ -1263,26 +1240,25 @@
 }
 
 /*
-**  This function clears all authorization information by
-**  invoking the free_HTAAGlobals() function, which normally
-**  is invoked at exit.  It allows a browser command to do
-**  this at any time, for example, if the user is leaving
-**  the terminal for a period of time, but does not want
-**  to end the current session.  - FM
-*/
-PUBLIC void HTClearHTTPAuthInfo NOARGS
+ *  This function clears all authorization information by
+ *  invoking the free_HTAAGlobals() function, which normally
+ *  is invoked at exit.  It allows a browser command to do
+ *  this at any time, for example, if the user is leaving
+ *  the terminal for a period of time, but does not want
+ *  to end the current session.  - FM
+ */
+void HTClearHTTPAuthInfo(void)
 {
     /*
-    **  Need code to check cached documents against the
-    **  protection templates, and do something to ensure
-    **  that any protected documents no longer can be
-    **  accessed without a new retrieval. - FM
-    */
+     * Need code to check cached documents against the protection templates,
+     * and do something to ensure that any protected documents no longer can be
+     * accessed without a new retrieval.  - FM
+     */
 
     /*
-    **  Now free all of the authorization info, and
-    **  reset the free_HTAAGlobalsSet flag. - FM
-    */
+     * Now free all of the authorization info, and reset the
+     * free_HTAAGlobalsSet flag.  - FM
+     */
     free_HTAAGlobals();
     free_HTAAGlobalsSet = FALSE;
 }
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/HTAAUtil.c
+++ lynx-cur-2.8.6/WWW/Library/Implementation/HTAAUtil.c
@@ -1,52 +1,52 @@
 /* MODULE							HTAAUtil.c
-**		COMMON PARTS OF ACCESS AUTHORIZATION MODULE
-**			FOR BOTH SERVER AND BROWSER
-**
-** IMPORTANT:
-**	Routines in this module use dynamic allocation, but free
-**	automatically all the memory reserved by them.
-**
-**	Therefore the caller never has to (and never should)
-**	free() any object returned by these functions.
-**
-**	Therefore also all the strings returned by this package
-**	are only valid until the next call to the same function
-**	is made.  This approach is selected, because of the nature
-**	of access authorization: no string returned by the package
-**	needs to be valid longer than until the next call.
-**
-**	This also makes it easy to plug the AA package in:
-**	you don't have to ponder whether to free() something
-**	here or is it done somewhere else (because it is always
-**	done somewhere else).
-**
-**	The strings that the package needs to store are copied
-**	so the original strings given as parameters to AA
-**	functions may be freed or modified with no side effects.
-**
-**	The AA package does not free() anything else than what
-**	it has itself allocated.
-**
-**	AA (Access Authorization) package means modules which
-**	names start with HTAA.
-**
-** AUTHORS:
-**	AL	Ari Luotonen	luotonen@dxcern.cern.ch
-**	MD	Mark Donszelmann    duns@vxdeop.cern.ch
-**
-** HISTORY:
-**	 8 Nov 93  MD	(VMS only) Added case insensitive comparison in HTAA_templateCaseMatch
-**
-**
-** BUGS:
-**
-**
-*/
+ *		COMMON PARTS OF ACCESS AUTHORIZATION MODULE
+ *			FOR BOTH SERVER AND BROWSER
+ *
+ * IMPORTANT:
+ *	Routines in this module use dynamic allocation, but free
+ *	automatically all the memory reserved by them.
+ *
+ *	Therefore the caller never has to (and never should)
+ *	free() any object returned by these functions.
+ *
+ *	Therefore also all the strings returned by this package
+ *	are only valid until the next call to the same function
+ *	is made.  This approach is selected, because of the nature
+ *	of access authorization: no string returned by the package
+ *	needs to be valid longer than until the next call.
+ *
+ *	This also makes it easy to plug the AA package in:
+ *	you don't have to ponder whether to free() something
+ *	here or is it done somewhere else (because it is always
+ *	done somewhere else).
+ *
+ *	The strings that the package needs to store are copied
+ *	so the original strings given as parameters to AA
+ *	functions may be freed or modified with no side effects.
+ *
+ *	The AA package does not free() anything else than what
+ *	it has itself allocated.
+ *
+ *	AA (Access Authorization) package means modules which
+ *	names start with HTAA.
+ *
+ * AUTHORS:
+ *	AL	Ari Luotonen	luotonen@dxcern.cern.ch
+ *	MD	Mark Donszelmann    duns@vxdeop.cern.ch
+ *
+ * HISTORY:
+ *	 8 Nov 93  MD	(VMS only) Added case insensitive comparison in HTAA_templateCaseMatch
+ *
+ *
+ * BUGS:
+ *
+ *
+ */
 
 #include <HTUtils.h>
 
-#include <HTAAUtil.h>	/* Implemented here	*/
-#include <HTAssoc.h>	/* Assoc list		*/
+#include <HTAAUtil.h>		/* Implemented here     */
+#include <HTAssoc.h>		/* Assoc list           */
 #include <HTTCP.h>
 #include <HTTP.h>
 
@@ -54,16 +54,16 @@
 #include <LYLeaks.h>
 
 /* PUBLIC						HTAAScheme_enum()
-**		TRANSLATE SCHEME NAME INTO
-**		A SCHEME ENUMERATION
-**
-** ON ENTRY:
-**	name		is a string representing the scheme name.
-**
-** ON EXIT:
-**	returns		the enumerated constant for that scheme.
-*/
-PUBLIC HTAAScheme HTAAScheme_enum ARGS1(CONST char*, name)
+ *		TRANSLATE SCHEME NAME INTO
+ *		A SCHEME ENUMERATION
+ *
+ * ON ENTRY:
+ *	name		is a string representing the scheme name.
+ *
+ * ON EXIT:
+ *	returns		the enumerated constant for that scheme.
+ */
+HTAAScheme HTAAScheme_enum(const char *name)
 {
     char *upcased = NULL;
 
@@ -94,297 +94,285 @@
     }
 }
 
-
 /* PUBLIC						HTAAScheme_name()
-**			GET THE NAME OF A GIVEN SCHEME
-** ON ENTRY:
-**	scheme		is one of the scheme enum values:
-**			HTAA_NONE, HTAA_BASIC, HTAA_PUBKEY, ...
-**
-** ON EXIT:
-**	returns		the name of the scheme, i.e.
-**			"None", "Basic", "Pubkey", ...
-*/
-PUBLIC char *HTAAScheme_name ARGS1(HTAAScheme, scheme)
+ *			GET THE NAME OF A GIVEN SCHEME
+ * ON ENTRY:
+ *	scheme		is one of the scheme enum values:
+ *			HTAA_NONE, HTAA_BASIC, HTAA_PUBKEY, ...
+ *
+ * ON EXIT:
+ *	returns		the name of the scheme, i.e.
+ *			"None", "Basic", "Pubkey", ...
+ */
+const char *HTAAScheme_name(HTAAScheme scheme)
 {
     switch (scheme) {
-	case HTAA_NONE:
-	    return "None";
-	case HTAA_BASIC:
-	    return "Basic";
-	case HTAA_PUBKEY:
-	    return "Pubkey";
-	case HTAA_KERBEROS_V4:
-	    return "KerberosV4";
-	case HTAA_KERBEROS_V5:
-	    return "KerberosV5";
-	case HTAA_UNKNOWN:
-	    return "UNKNOWN";
-	default:
-	    return "THIS-IS-A-BUG";
+    case HTAA_NONE:
+	return "None";
+    case HTAA_BASIC:
+	return "Basic";
+    case HTAA_PUBKEY:
+	return "Pubkey";
+    case HTAA_KERBEROS_V4:
+	return "KerberosV4";
+    case HTAA_KERBEROS_V5:
+	return "KerberosV5";
+    case HTAA_UNKNOWN:
+	return "UNKNOWN";
+    default:
+	return "THIS-IS-A-BUG";
     }
 }
 
-
 /* PUBLIC						    HTAAMethod_enum()
-**		TRANSLATE METHOD NAME INTO AN ENUMERATED VALUE
-** ON ENTRY:
-**	name		is the method name to translate.
-**
-** ON EXIT:
-**	returns		HTAAMethod enumerated value corresponding
-**			to the given name.
-*/
-PUBLIC HTAAMethod HTAAMethod_enum ARGS1(CONST char *, name)
+ *		TRANSLATE METHOD NAME INTO AN ENUMERATED VALUE
+ * ON ENTRY:
+ *	name		is the method name to translate.
+ *
+ * ON EXIT:
+ *	returns		HTAAMethod enumerated value corresponding
+ *			to the given name.
+ */
+HTAAMethod HTAAMethod_enum(const char *name)
 {
     if (!name)
 	return METHOD_UNKNOWN;
 
-    if (0==strcasecomp(name, "GET"))
+    if (0 == strcasecomp(name, "GET"))
 	return METHOD_GET;
-    else if (0==strcasecomp(name, "PUT"))
+    else if (0 == strcasecomp(name, "PUT"))
 	return METHOD_PUT;
     else
 	return METHOD_UNKNOWN;
 }
 
-
 /* PUBLIC						HTAAMethod_name()
-**			GET THE NAME OF A GIVEN METHOD
-** ON ENTRY:
-**	method		is one of the method enum values:
-**			METHOD_GET, METHOD_PUT, ...
-**
-** ON EXIT:
-**	returns		the name of the scheme, i.e.
-**			"GET", "PUT", ...
-*/
-PUBLIC char *HTAAMethod_name ARGS1(HTAAMethod, method)
+ *			GET THE NAME OF A GIVEN METHOD
+ * ON ENTRY:
+ *	method		is one of the method enum values:
+ *			METHOD_GET, METHOD_PUT, ...
+ *
+ * ON EXIT:
+ *	returns		the name of the scheme, i.e.
+ *			"GET", "PUT", ...
+ */
+const char *HTAAMethod_name(HTAAMethod method)
 {
     switch (method) {
-      case METHOD_GET:
-	  return "GET";
-      case METHOD_PUT:
-	  return "PUT";
-      case METHOD_UNKNOWN:
-	  return "UNKNOWN";
-      default:
-	  return "THIS-IS-A-BUG";
+    case METHOD_GET:
+	return "GET";
+    case METHOD_PUT:
+	return "PUT";
+    case METHOD_UNKNOWN:
+	return "UNKNOWN";
+    default:
+	return "THIS-IS-A-BUG";
     }
 }
 
-
 /* PUBLIC						HTAAMethod_inList()
-**		IS A METHOD IN A LIST OF METHOD NAMES
-** ON ENTRY:
-**	method		is the method to look for.
-**	list		is a list of method names.
-**
-** ON EXIT:
-**	returns		YES, if method was found.
-**			NO, if not found.
-*/
-PUBLIC BOOL HTAAMethod_inList ARGS2(HTAAMethod, method,
-				    HTList *,	list)
+ *		IS A METHOD IN A LIST OF METHOD NAMES
+ * ON ENTRY:
+ *	method		is the method to look for.
+ *	list		is a list of method names.
+ *
+ * ON EXIT:
+ *	returns		YES, if method was found.
+ *			NO, if not found.
+ */
+BOOL HTAAMethod_inList(HTAAMethod method, HTList *list)
 {
     HTList *cur = list;
     char *item;
 
-    while (NULL != (item = (char*)HTList_nextObject(cur))) {
+    while (NULL != (item = (char *) HTList_nextObject(cur))) {
 	CTRACE((tfp, " %s", item));
 	if (method == HTAAMethod_enum(item))
 	    return YES;
     }
 
-    return NO;	/* Not found */
+    return NO;			/* Not found */
 }
 
-
 /* PUBLIC						HTAA_templateMatch()
-**		STRING COMPARISON FUNCTION FOR FILE NAMES
-**		   WITH ONE WILDCARD * IN THE TEMPLATE
-** NOTE:
-**	This is essentially the same code as in HTRules.c, but it
-**	cannot be used because it is embedded in between other code.
-**	(In fact, HTRules.c should use this routine, but then this
-**	 routine would have to be more sophisticated... why is life
-**	 sometimes so hard...)
-**
-** ON ENTRY:
-**	template	is a template string to match the file name
-**			against, may contain a single wildcard
-**			character * which matches zero or more
-**			arbitrary characters.
-**	filename	is the filename (or pathname) to be matched
-**			against the template.
-**
-** ON EXIT:
-**	returns		YES, if filename matches the template.
-**			NO, otherwise.
-*/
-PUBLIC BOOL HTAA_templateMatch ARGS2(CONST char *, template,
-				     CONST char *, filename)
+ *		STRING COMPARISON FUNCTION FOR FILE NAMES
+ *		   WITH ONE WILDCARD * IN THE TEMPLATE
+ * NOTE:
+ *	This is essentially the same code as in HTRules.c, but it
+ *	cannot be used because it is embedded in between other code.
+ *	(In fact, HTRules.c should use this routine, but then this
+ *	 routine would have to be more sophisticated... why is life
+ *	 sometimes so hard...)
+ *
+ * ON ENTRY:
+ *	ctemplate	is a template string to match the file name
+ *			against, may contain a single wildcard
+ *			character * which matches zero or more
+ *			arbitrary characters.
+ *	filename	is the filename (or pathname) to be matched
+ *			against the template.
+ *
+ * ON EXIT:
+ *	returns		YES, if filename matches the template.
+ *			NO, otherwise.
+ */
+BOOL HTAA_templateMatch(const char *ctemplate,
+			const char *filename)
 {
-    CONST char *p = template;
-    CONST char *q = filename;
+    const char *p = ctemplate;
+    const char *q = filename;
     int m;
 
-    for (; *p  &&  *q  &&  *p == *q; p++, q++)	/* Find first mismatch */
-	; /* do nothing else */
+    for (; *p && *q && *p == *q; p++, q++)	/* Find first mismatch */
+	;			/* do nothing else */
 
     if (!*p && !*q)
-	return YES;			/* Equally long equal strings */
-    else if ('*' == *p) {		/* Wildcard */
-	p++;				/* Skip wildcard character */
+	return YES;		/* Equally long equal strings */
+    else if ('*' == *p) {	/* Wildcard */
+	p++;			/* Skip wildcard character */
 	m = strlen(q) - strlen(p);	/* Amount to match to wildcard */
 	if (m < 0)
-	    return NO;			/* No match, filename too short */
+	    return NO;		/* No match, filename too short */
 	else {			/* Skip the matched characters and compare */
-	    if (strcmp(p, q+m))
+	    if (strcmp(p, q + m))
 		return NO;	/* Tail mismatch */
 	    else
 		return YES;	/* Tail match */
 	}
-    }	/* if wildcard */
-    else
+	/* if wildcard */
+    } else
 	return NO;		/* Length or character mismatch */
 }
 
-
 /* PUBLIC						HTAA_templateCaseMatch()
-**		STRING COMPARISON FUNCTION FOR FILE NAMES
-**		   WITH ONE WILDCARD * IN THE TEMPLATE (Case Insensitive)
-** NOTE:
-**	This is essentially the same code as in HTAA_templateMatch, but
-**	it compares case insensitive (for VMS). Reason for this routine
-**	is that HTAA_templateMatch gets called from several places, also
-**	there where a case sensitive match is needed, so one cannot just
-**	change the HTAA_templateMatch routine for VMS.
-**
-** ON ENTRY:
-**	template	is a template string to match the file name
-**			against, may contain a single wildcard
-**			character * which matches zero or more
-**			arbitrary characters.
-**	filename	is the filename (or pathname) to be matched
-**			against the template.
-**
-** ON EXIT:
-**	returns		YES, if filename matches the template.
-**			NO, otherwise.
-*/
-PUBLIC BOOL HTAA_templateCaseMatch ARGS2(CONST char *, template,
-					 CONST char *, filename)
+ *		STRING COMPARISON FUNCTION FOR FILE NAMES
+ *		   WITH ONE WILDCARD * IN THE TEMPLATE (Case Insensitive)
+ * NOTE:
+ *	This is essentially the same code as in HTAA_templateMatch, but
+ *	it compares case insensitive (for VMS). Reason for this routine
+ *	is that HTAA_templateMatch gets called from several places, also
+ *	there where a case sensitive match is needed, so one cannot just
+ *	change the HTAA_templateMatch routine for VMS.
+ *
+ * ON ENTRY:
+ *	template	is a template string to match the file name
+ *			against, may contain a single wildcard
+ *			character * which matches zero or more
+ *			arbitrary characters.
+ *	filename	is the filename (or pathname) to be matched
+ *			against the template.
+ *
+ * ON EXIT:
+ *	returns		YES, if filename matches the template.
+ *			NO, otherwise.
+ */
+BOOL HTAA_templateCaseMatch(const char *ctemplate,
+			    const char *filename)
 {
-    CONST char *p = template;
-    CONST char *q = filename;
+    const char *p = ctemplate;
+    const char *q = filename;
     int m;
 
     /* Find first mismatch */
-    for (; *p  &&  *q  &&  TOUPPER(*p) == TOUPPER(*q); p++, q++)
-	; /* do nothing else */
+    for (; *p && *q && TOUPPER(*p) == TOUPPER(*q); p++, q++) ;	/* do nothing else */
 
     if (!*p && !*q)
-	return YES;			/* Equally long equal strings */
-    else if ('*' == *p) {		/* Wildcard */
-	p++;				/* Skip wildcard character */
+	return YES;		/* Equally long equal strings */
+    else if ('*' == *p) {	/* Wildcard */
+	p++;			/* Skip wildcard character */
 	m = strlen(q) - strlen(p);	/* Amount to match to wildcard */
 	if (m < 0)
-	    return NO;			/* No match, filename too short */
+	    return NO;		/* No match, filename too short */
 	else {			/* Skip the matched characters and compare */
-	    if (strcasecomp(p, q+m))
+	    if (strcasecomp(p, q + m))
 		return NO;	/* Tail mismatch */
 	    else
 		return YES;	/* Tail match */
 	}
-    }	/* if wildcard */
-    else
+	/* if wildcard */
+    } else
 	return NO;		/* Length or character mismatch */
 }
 
-
 /* PUBLIC					HTAA_makeProtectionTemplate()
-**		CREATE A PROTECTION TEMPLATE FOR THE FILES
-**		IN THE SAME DIRECTORY AS THE GIVEN FILE
-**		(Used by server if there is no fancier way for
-**		it to tell the client, and by browser if server
-**		didn't send WWW-ProtectionTemplate: field)
-** ON ENTRY:
-**	docname is the document pathname (from URL).
-**
-** ON EXIT:
-**	returns a template matching docname, and other files
-**		files in that directory.
-**
-**		E.g.  /foo/bar/x.html  =>  /foo/bar/ *
-**						    ^
-**				Space only to prevent it from
-**				being a comment marker here,
-**				there really isn't any space.
-*/
-PUBLIC char *HTAA_makeProtectionTemplate ARGS1(CONST char *, docname)
+ *		CREATE A PROTECTION TEMPLATE FOR THE FILES
+ *		IN THE SAME DIRECTORY AS THE GIVEN FILE
+ *		(Used by server if there is no fancier way for
+ *		it to tell the client, and by browser if server
+ *		didn't send WWW-ProtectionTemplate: field)
+ * ON ENTRY:
+ *	docname is the document pathname (from URL).
+ *
+ * ON EXIT:
+ *	returns a template matching docname, and other files
+ *		files in that directory.
+ *
+ *		E.g.  /foo/bar/x.html  =>  /foo/bar/ *
+ *						    ^
+ *				Space only to prevent it from
+ *				being a comment marker here,
+ *				there really isn't any space.
+ */
+char *HTAA_makeProtectionTemplate(const char *docname)
 {
-    char *template = NULL;
+    char *ctemplate = NULL;
     char *slash = NULL;
 
     if (docname) {
-	StrAllocCopy(template, docname);
-	slash = strrchr(template, '/');
+	StrAllocCopy(ctemplate, docname);
+	slash = strrchr(ctemplate, '/');
 	if (slash)
 	    slash++;
 	else
-	    slash = template;
+	    slash = ctemplate;
 	*slash = '\0';
-	StrAllocCat(template, "*");
-    }
-    else
-	StrAllocCopy(template, "*");
+	StrAllocCat(ctemplate, "*");
+    } else
+	StrAllocCopy(ctemplate, "*");
 
     CTRACE((tfp, "make_template: made template `%s' for file `%s'\n",
-		template, docname));
+	    ctemplate, docname));
 
-    return template;
+    return ctemplate;
 }
 
-
 /*
-** Skip leading whitespace from *s forward
-*/
+ * Skip leading whitespace from *s forward
+ */
 #define SKIPWS(s) while (*s==' ' || *s=='\t') s++;
 
 /*
-** Kill trailing whitespace starting from *(s-1) backwards
-*/
+ * Kill trailing whitespace starting from *(s-1) backwards
+ */
 #define KILLWS(s) {char *c=s-1; while (*c==' ' || *c=='\t') *(c--)='\0';}
 
-
 /* PUBLIC						HTAA_parseArgList()
-**		PARSE AN ARGUMENT LIST GIVEN IN A HEADER FIELD
-** ON ENTRY:
-**	str	is a comma-separated list:
-**
-**			item, item, item
-**		where
-**			item ::= value
-**			       | name=value
-**			       | name="value"
-**
-**		Leading and trailing whitespace is ignored
-**		everywhere except inside quotes, so the following
-**		examples are equal:
-**
-**			name=value,foo=bar
-**			 name="value",foo="bar"
-**			  name = value ,  foo = bar
-**			   name = "value" ,  foo = "bar"
-**
-** ON EXIT:
-**	returns a list of name-value pairs (actually HTAssocList*).
-**		For items with no name, just value, the name is
-**		the number of order number of that item. E.g.
-**		"1" for the first, etc.
-*/
-PUBLIC HTAssocList *HTAA_parseArgList ARGS1(char *, str)
+ *		PARSE AN ARGUMENT LIST GIVEN IN A HEADER FIELD
+ * ON ENTRY:
+ *	str	is a comma-separated list:
+ *
+ *			item, item, item
+ *		where
+ *			item ::= value
+ *			       | name=value
+ *			       | name="value"
+ *
+ *		Leading and trailing whitespace is ignored
+ *		everywhere except inside quotes, so the following
+ *		examples are equal:
+ *
+ *			name=value,foo=bar
+ *			 name="value",foo="bar"
+ *			  name = value ,  foo = bar
+ *			   name = "value" ,  foo = "bar"
+ *
+ * ON EXIT:
+ *	returns a list of name-value pairs (actually HTAssocList*).
+ *		For items with no name, just value, the name is
+ *		the number of order number of that item. E.g.
+ *		"1" for the first, etc.
+ */
+HTAssocList *HTAA_parseArgList(char *str)
 {
     HTAssocList *assoc_list = HTAssocList_new();
     char *cur = NULL;
@@ -395,109 +383,106 @@
 	return assoc_list;
 
     while (*str) {
-	SKIPWS(str);				/* Skip leading whitespace */
+	SKIPWS(str);		/* Skip leading whitespace */
 	cur = str;
 	n++;
 
-	while (*cur  &&  *cur != '='  &&  *cur != ',')
-	    cur++;	/* Find end of name (or lonely value without a name) */
-	KILLWS(cur);	/* Kill trailing whitespace */
+	while (*cur && *cur != '=' && *cur != ',')
+	    cur++;		/* Find end of name (or lonely value without a name) */
+	KILLWS(cur);		/* Kill trailing whitespace */
 
-	if (*cur == '=') {			/* Name followed by a value */
-	    *(cur++) = '\0';			/* Terminate name */
+	if (*cur == '=') {	/* Name followed by a value */
+	    *(cur++) = '\0';	/* Terminate name */
 	    StrAllocCopy(name, str);
-	    SKIPWS(cur);			/* Skip WS leading the value */
+	    SKIPWS(cur);	/* Skip WS leading the value */
 	    str = cur;
-	    if (*str == '"') {			/* Quoted value */
+	    if (*str == '"') {	/* Quoted value */
 		str++;
 		cur = str;
-		while (*cur  &&  *cur != '"')
+		while (*cur && *cur != '"')
 		    cur++;
 		if (*cur == '"')
-		    *(cur++) = '\0';		/* Terminate value */
+		    *(cur++) = '\0';	/* Terminate value */
 		/* else it is lacking terminating quote */
-		SKIPWS(cur);			/* Skip WS leading comma */
+		SKIPWS(cur);	/* Skip WS leading comma */
 		if (*cur == ',')
-		    cur++;			/* Skip separating colon */
-	    }
-	    else {				/* Unquoted value */
-		while (*cur  &&  *cur != ',')
+		    cur++;	/* Skip separating colon */
+	    } else {		/* Unquoted value */
+		while (*cur && *cur != ',')
 		    cur++;
-		KILLWS(cur);			/* Kill trailing whitespace */
+		KILLWS(cur);	/* Kill trailing whitespace */
 		if (*cur == ',')
 		    *(cur++) = '\0';
 		/* else *cur already NULL */
 	    }
-	}
-	else {	/* No name, just a value */
+	} else {		/* No name, just a value */
 	    if (*cur == ',')
-		*(cur++) = '\0';		/* Terminate value */
+		*(cur++) = '\0';	/* Terminate value */
 	    /* else last value on line (already terminated by NULL) */
 	    HTSprintf0(&name, "%d", n);		/* Item order number for name */
 	}
 	HTAssocList_add(assoc_list, name, str);
 	str = cur;
-    } /* while *str */
+    }				/* while *str */
 
     FREE(name);
     return assoc_list;
 }
 
-
 /************** HEADER LINE READER -- DOES UNFOLDING *************************/
 
 #define BUFFER_SIZE	1024
 
-PRIVATE size_t buffer_length;
-PRIVATE char *buffer = 0;
-PRIVATE char *start_pointer;
-PRIVATE char *end_pointer;
-PRIVATE int in_soc = -1;
+static size_t buffer_length;
+static char *buffer = 0;
+static char *start_pointer;
+static char *end_pointer;
+static int in_soc = -1;
 
 #ifdef LY_FIND_LEAKS
-PRIVATE void FreeHTAAUtil NOARGS
+static void FreeHTAAUtil(void)
 {
     FREE(buffer);
 }
 #endif /* LY_FIND_LEAKS */
 
 /* PUBLIC						HTAA_setupReader()
-**		SET UP HEADER LINE READER, i.e., give
-**		the already-read-but-not-yet-processed
-**		buffer of text to be read before more
-**		is read from the socket.
-** ON ENTRY:
-**	start_of_headers is a pointer to a buffer containing
-**			the beginning of the header lines
-**			(rest will be read from a socket).
-**	length		is the number of valid characters in
-**			'start_of_headers' buffer.
-**	soc		is the socket to use when start_of_headers
-**			buffer is used up.
-** ON EXIT:
-**	returns		nothing.
-**			Subsequent calls to HTAA_getUnfoldedLine()
-**			will use this buffer first and then
-**			proceed to read from socket.
-*/
-PUBLIC void HTAA_setupReader ARGS3(char *,	start_of_headers,
-				   int,		length,
-				   int,		soc)
+ *		SET UP HEADER LINE READER, i.e., give
+ *		the already-read-but-not-yet-processed
+ *		buffer of text to be read before more
+ *		is read from the socket.
+ * ON ENTRY:
+ *	start_of_headers is a pointer to a buffer containing
+ *			the beginning of the header lines
+ *			(rest will be read from a socket).
+ *	length		is the number of valid characters in
+ *			'start_of_headers' buffer.
+ *	soc		is the socket to use when start_of_headers
+ *			buffer is used up.
+ * ON EXIT:
+ *	returns		nothing.
+ *			Subsequent calls to HTAA_getUnfoldedLine()
+ *			will use this buffer first and then
+ *			proceed to read from socket.
+ */
+void HTAA_setupReader(char *start_of_headers,
+		      int length,
+		      int soc)
 {
     if (!start_of_headers)
-	length = 0;	       /* initialize length (is this reached at all?) */
-    if (buffer == NULL) {				       /* first call? */
+	length = 0;		/* initialize length (is this reached at all?) */
+    if (buffer == NULL) {	/* first call? */
 	buffer_length = length;
-	if (buffer_length < BUFFER_SIZE)     /* would fall below BUFFER_SIZE? */
+	if (buffer_length < BUFFER_SIZE)	/* would fall below BUFFER_SIZE? */
 	    buffer_length = BUFFER_SIZE;
-	buffer = (char*)malloc((size_t)(sizeof(char)*(buffer_length + 1)));
-    }
-    else if (length > (int)buffer_length) {		  /* need more space? */
+	buffer = (char *) malloc((size_t) (sizeof(char) * (buffer_length + 1)));
+    } else if (length > (int) buffer_length) {	/* need more space? */
 	buffer_length = length;
-	buffer = (char*)realloc((char*)buffer,
-				(size_t)(sizeof(char)*(buffer_length + 1)));
+	buffer = (char *) realloc((char *) buffer,
+				  (size_t) (sizeof(char) * (buffer_length + 1)));
     }
-    if (buffer == NULL) outofmem(__FILE__, "HTAA_setupReader");
+    if (buffer == NULL)
+	outofmem(__FILE__, "HTAA_setupReader");
 #ifdef LY_FIND_LEAKS
     atexit(FreeHTAAUtil);
 #endif
@@ -506,37 +491,35 @@
 	strncpy(buffer, start_of_headers, length);
 	buffer[length] = '\0';
 	end_pointer = buffer + length;
-    }
-    else {
+    } else {
 	*start_pointer = '\0';
 	end_pointer = start_pointer;
     }
     in_soc = soc;
 }
 
-
 /* PUBLIC						HTAA_getUnfoldedLine()
-**		READ AN UNFOLDED HEADER LINE FROM SOCKET
-** ON ENTRY:
-**	HTAA_setupReader must absolutely be called before
-**	this function to set up internal buffer.
-**
-** ON EXIT:
-**	returns a newly-allocated character string representing
-**		the read line.	The line is unfolded, i.e.
-**		lines that begin with whitespace are appended
-**		to current line.  E.g.
-**
-**			Field-Name: Blaa-Blaa
-**			 This-Is-A-Continuation-Line
-**			 Here-Is_Another
-**
-**		is seen by the caller as:
-**
-**	Field-Name: Blaa-Blaa This-Is-A-Continuation-Line Here-Is_Another
-**
-*/
-PUBLIC char *HTAA_getUnfoldedLine NOARGS
+ *		READ AN UNFOLDED HEADER LINE FROM SOCKET
+ * ON ENTRY:
+ *	HTAA_setupReader must absolutely be called before
+ *	this function to set up internal buffer.
+ *
+ * ON EXIT:
+ *	returns a newly-allocated character string representing
+ *		the read line.	The line is unfolded, i.e.
+ *		lines that begin with whitespace are appended
+ *		to current line.  E.g.
+ *
+ *			Field-Name: Blaa-Blaa
+ *			 This-Is-A-Continuation-Line
+ *			 Here-Is_Another
+ *
+ *		is seen by the caller as:
+ *
+ *	Field-Name: Blaa-Blaa This-Is-A-Continuation-Line Here-Is_Another
+ *
+ */
+char *HTAA_getUnfoldedLine(void)
 {
     char *line = NULL;
     char *cur;
@@ -545,16 +528,16 @@
 
     if (in_soc < 0) {
 	CTRACE((tfp, "%s %s\n",
-		    "HTAA_getUnfoldedLine: buffer not initialized",
-		    "with function HTAA_setupReader()"));
+		"HTAA_getUnfoldedLine: buffer not initialized",
+		"with function HTAA_setupReader()"));
 	return NULL;
     }
 
-    for(;;) {
+    for (;;) {
 
 	/* Reading from socket */
 
-	if (start_pointer >= end_pointer) {/*Read the next block and continue*/
+	if (start_pointer >= end_pointer) {	/*Read the next block and continue */
 #ifdef USE_SSL
 	    if (SSL_handle)
 		count = SSL_read(SSL_handle, buffer, BUFFER_SIZE);
@@ -576,37 +559,33 @@
 		*cur = TOASCII(*cur);
 		cur++;
 	    }
-#endif /*NOT_ASCII*/
+#endif /*NOT_ASCII */
 	}
 	cur = start_pointer;
 
-
 	/* Unfolding */
 
 	if (peek_for_folding) {
-	    if (*cur != ' '  &&  *cur != '\t')
+	    if (*cur != ' ' && *cur != '\t')
 		return line;	/* Ok, no continuation line */
 	    else		/* So this is a continuation line, continue */
 		peek_for_folding = NO;
 	}
 
-
 	/* Finding end-of-line */
 
-	while (cur < end_pointer && *cur != '\n') /* Find the end-of-line */
-	    cur++;				  /* (or end-of-buffer).  */
-
+	while (cur < end_pointer && *cur != '\n')	/* Find the end-of-line */
+	    cur++;		/* (or end-of-buffer).  */
 
 	/* Terminating line */
 
 	if (cur < end_pointer) {	/* So *cur==LF, terminate line */
-	    *cur = '\0';		/* Overwrite LF */
-	    if (*(cur-1) == '\r')
-		*(cur-1) = '\0';	/* Overwrite CR */
+	    *cur = '\0';	/* Overwrite LF */
+	    if (*(cur - 1) == '\r')
+		*(cur - 1) = '\0';	/* Overwrite CR */
 	    peek_for_folding = YES;	/* Check for a continuation line */
 	}
 
-
 	/* Copying the result */
 
 	if (line)
@@ -614,7 +593,7 @@
 	else
 	    StrAllocCopy(line, start_pointer);	/* A new line */
 
-	start_pointer = cur+1;	/* Skip the read line */
+	start_pointer = cur + 1;	/* Skip the read line */
 
-    } /* forever */
+    }				/* forever */
 }
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/HTGopher.c
+++ lynx-cur-2.8.6/WWW/Library/Implementation/HTGopher.c
@@ -1,19 +1,19 @@
 /*			GOPHER ACCESS				HTGopher.c
-**			=============
-**
-**  History:
-**	26 Sep 90	Adapted from other accesses (News, HTTP) TBL
-**	29 Nov 91	Downgraded to C, for portable implementation.
-**	10 Mar 96	Foteos Macrides (macrides@sci.wfbr.edu).  Added a
-**			  form-based CSO/PH gateway.  Can be invoked via a
-**			  "cso://host[:port]/" or "gopher://host:105/2"
-**			  URL.	If a gopher URL is used with a query token
-**			  ('?'), the old ISINDEX procedure will be used
-**			  instead of the form-based gateway.
-**	15 Mar 96	Foteos Macrides (macrides@sci.wfbr.edu).  Pass
-**			  port 79, gtype 0 gopher URLs to the finger
-**			  gateway.
-*/
+ *			=============
+ *
+ *  History:
+ *	26 Sep 90	Adapted from other accesses (News, HTTP) TBL
+ *	29 Nov 91	Downgraded to C, for portable implementation.
+ *	10 Mar 96	Foteos Macrides (macrides@sci.wfbr.edu).  Added a
+ *			  form-based CSO/PH gateway.  Can be invoked via a
+ *			  "cso://host[:port]/" or "gopher://host:105/2"
+ *			  URL.	If a gopher URL is used with a query token
+ *			  ('?'), the old ISINDEX procedure will be used
+ *			  instead of the form-based gateway.
+ *	15 Mar 96	Foteos Macrides (macrides@sci.wfbr.edu).  Pass
+ *			  port 79, gtype 0 gopher URLs to the finger
+ *			  gateway.
+ */
 
 #include <HTUtils.h>		/* Coding convention macros */
 
@@ -24,8 +24,8 @@
 #include <HTFinger.h>
 
 /*
-**  Implements.
-*/
+ *  Implements.
+ */
 #include <HTGopher.h>
 
 #define GOPHER_PORT 70		/* See protocol spec */
@@ -34,8 +34,8 @@
 #define LINE_LENGTH 256		/* Bug */
 
 /*
-**  Gopher entity types.
-*/
+ *  Gopher entity types.
+ */
 #define GOPHER_TEXT		'0'
 #define GOPHER_MENU		'1'
 #define GOPHER_CSO		'2'
@@ -47,15 +47,15 @@
 #define GOPHER_TELNET		'8'
 #define GOPHER_BINARY		'9'
 #define GOPHER_GIF		'g'
-#define GOPHER_HTML		'h'		/* HTML */
-#define GOPHER_CHTML		'H'		/* HTML */
+#define GOPHER_HTML		'h'	/* HTML */
+#define GOPHER_CHTML		'H'	/* HTML */
 #define GOPHER_SOUND		's'
-#define GOPHER_WWW		'w'		/* W3 address */
+#define GOPHER_WWW		'w'	/* W3 address */
 #define GOPHER_IMAGE		'I'
 #define GOPHER_TN3270		'T'
 #define GOPHER_INFO		'i'
 #define GOPHER_DUPLICATE	'+'
-#define GOPHER_PLUS_IMAGE	':'		/* Addition from Gopher Plus */
+#define GOPHER_PLUS_IMAGE	':'	/* Addition from Gopher Plus */
 #define GOPHER_PLUS_MOVIE	';'
 #define GOPHER_PLUS_SOUND	'<'
 #define GOPHER_PLUS_PDF		'P'
@@ -63,8 +63,8 @@
 #include <HTFormat.h>
 
 /*
-**  Hypertext object building machinery.
-*/
+ *  Hypertext object building machinery.
+ */
 #include <HTML.h>
 
 #include <LYStrings.h>
@@ -77,136 +77,133 @@
 #define END(e) (*targetClass.end_element)(target, e, 0)
 #define FREE_TARGET (*targetClass._free)(target)
 
-#define GOPHER_PROGRESS(foo) HTAlert(foo)
-
 #define NEXT_CHAR HTGetCharacter()
 
 /*
-**  Module-wide variables.
-*/
-PRIVATE int s;				/* Socket for gopher or CSO host */
+ *  Module-wide variables.
+ */
+static int s;			/* Socket for gopher or CSO host */
 
 struct _HTStructured {
-	CONST HTStructuredClass * isa;	/* For gopher streams */
-	/* ... */
+    const HTStructuredClass *isa;	/* For gopher streams */
+    /* ... */
 };
 
-PRIVATE HTStructured *target;		/* the new gopher hypertext */
-PRIVATE HTStructuredClass targetClass;	/* Its action routines */
+static HTStructured *target;	/* the new gopher hypertext */
+static HTStructuredClass targetClass;	/* Its action routines */
 
-struct _HTStream
-{
-  HTStreamClass * isa;			/* For form-based CSO  gateway - FM */
+struct _HTStream {
+    HTStreamClass *isa;		/* For form-based CSO  gateway - FM */
 };
 
-typedef struct _CSOfield_info {		/* For form-based CSO gateway - FM */
-    struct _CSOfield_info *	next;
-    char *			name;
-    char *			attributes;
-    char *			description;
-    int				id;
-    int				lookup;
-    int				indexed;
-    int				url;
-    int				max_size;
-    int				defreturn;
-    int				explicit_return;
-    int				reserved;
-    int				public;
-    char			name_buf[16];	/* Avoid malloc if we can */
-    char			desc_buf[32];	/* Avoid malloc if we can */
-    char			attr_buf[80];	/* Avoid malloc if we can */
+typedef struct _CSOfield_info {	/* For form-based CSO gateway - FM */
+    struct _CSOfield_info *next;
+    char *name;
+    char *attributes;
+    char *description;
+    int id;
+    int lookup;
+    int indexed;
+    int url;
+    int max_size;
+    int defreturn;
+    int explicit_return;
+    int reserved;
+    int gpublic;
+    char name_buf[16];		/* Avoid malloc if we can */
+    char desc_buf[32];		/* Avoid malloc if we can */
+    char attr_buf[80];		/* Avoid malloc if we can */
 } CSOfield_info;
 
-PRIVATE CSOfield_info *CSOfields = NULL; /* For form-based CSO gateway - FM */
+static CSOfield_info *CSOfields = NULL;		/* For form-based CSO gateway - FM */
 
-typedef struct _CSOformgen_context {	 /* For form-based CSO gateway - FM */
-    char *		host;
-    char *		seek;
-    CSOfield_info *	fld;
-    int			port;
-    int			cur_line;
-    int			cur_off;
-    int			rep_line;
-    int			rep_off;
-    int			public_override;
-    int			field_select;
+typedef struct _CSOformgen_context {	/* For form-based CSO gateway - FM */
+    char *host;
+    char *seek;
+    CSOfield_info *fld;
+    int port;
+    int cur_line;
+    int cur_off;
+    int rep_line;
+    int rep_off;
+    int public_override;
+    int field_select;
 } CSOformgen_context;
 
 /*	Matrix of allowed characters in filenames
-**	=========================================
-*/
-PRIVATE BOOL acceptable[256];
-PRIVATE BOOL acceptable_inited = NO;
+ *	=========================================
+ */
+static BOOL acceptable[256];
+static BOOL acceptable_inited = NO;
 
-PRIVATE void init_acceptable NOARGS
+static void init_acceptable(void)
 {
     unsigned int i;
-    char * good =
-      "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./-_$";
-    for(i = 0; i < 256; i++)
+    const char *good =
+    "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./-_$";
+
+    for (i = 0; i < 256; i++)
 	acceptable[i] = NO;
-    for(; *good; good++)
-	acceptable[(unsigned int)*good] = YES;
+    for (; *good; good++)
+	acceptable[(unsigned int) *good] = YES;
     acceptable_inited = YES;
 }
 
 /*	Decode one hex character
-**	========================
-*/
-PRIVATE CONST char hex[17] = "0123456789abcdef";
+ *	========================
+ */
+static const char hex[17] = "0123456789abcdef";
 
-PRIVATE char from_hex ARGS1(char, c)
+static char from_hex(char c)
 {
-    return (char) (       (c>='0')&&(c<='9') ? c-'0'
-			: (c>='A')&&(c<='F') ? c-'A'+10
-			: (c>='a')&&(c<='f') ? c-'a'+10
-			:		       0);
+    return (char) ((c >= '0') && (c <= '9') ? c - '0'
+		   : (c >= 'A') && (c <= 'F') ? c - 'A' + 10
+		   : (c >= 'a') && (c <= 'f') ? c - 'a' + 10
+		   : 0);
 }
 
 /*	Paste in an Anchor
-**	==================
-**
-**	The title of the destination is set, as there is no way
-**	of knowing what the title is when we arrive.
-**
-** On entry,
-**	HT	is in append mode.
-**	text	points to the text to be put into the file, 0 terminated.
-**	addr	points to the hypertext refernce address 0 terminated.
-*/
-PUBLIC BOOLEAN HT_Is_Gopher_URL=FALSE;
+ *	==================
+ *
+ *	The title of the destination is set, as there is no way
+ *	of knowing what the title is when we arrive.
+ *
+ * On entry,
+ *	HT	is in append mode.
+ *	text	points to the text to be put into the file, 0 terminated.
+ *	addr	points to the hypertext refernce address 0 terminated.
+ */
+BOOLEAN HT_Is_Gopher_URL = FALSE;
 
-PRIVATE void write_anchor ARGS2(CONST char *,text, CONST char *,addr)
+static void write_anchor(const char *text, const char *addr)
 {
     BOOL present[HTML_A_ATTRIBUTES];
-    CONST char * value[HTML_A_ATTRIBUTES];
+    const char *value[HTML_A_ATTRIBUTES];
 
     int i;
 
     for (i = 0; i < HTML_A_ATTRIBUTES; i++)
 	present[i] = 0;
     present[HTML_A_HREF] = YES;
-    ((CONST char **)value)[HTML_A_HREF] = addr;
+    ((const char **) value)[HTML_A_HREF] = addr;
     present[HTML_A_TITLE] = YES;
-    ((CONST char **)value)[HTML_A_TITLE] = text;
+    ((const char **) value)[HTML_A_TITLE] = text;
 
-    CTRACE((tfp,"HTGopher: adding URL: %s\n",addr));
+    CTRACE((tfp, "HTGopher: adding URL: %s\n", addr));
 
-    HT_Is_Gopher_URL = TRUE;  /* tell HTML.c that this is a Gopher URL */
-    (*targetClass.start_element)(target, HTML_A, present,
-				 (CONST char **)value, -1, 0);
+    HT_Is_Gopher_URL = TRUE;	/* tell HTML.c that this is a Gopher URL */
+    (*targetClass.start_element) (target, HTML_A, present,
+				  (const char **) value, -1, 0);
 
     PUTS(text);
     END(HTML_A);
 }
 
 /*	Parse a Gopher Menu document
-**	============================
-*/
-PRIVATE void parse_menu ARGS2(
-	CONST char *,		arg GCC_UNUSED,
-	HTParentAnchor *,	anAnchor)
+ *	============================
+ */
+static void parse_menu(const char *arg GCC_UNUSED,
+		       HTParentAnchor *anAnchor)
 {
     char gtype;
     int ich;
@@ -215,7 +212,7 @@
     char *host = NULL;
     char *port;
     char *p = line;
-    CONST char *title;
+    const char *title;
     int bytes = 0;
     int BytesReported = 0;
     char buffer[128];
@@ -223,7 +220,6 @@
 #define TAB		'\t'
 #define HEX_ESCAPE	'%'
 
-
     START(HTML_HTML);
     PUTC('\n');
     START(HTML_HEAD);
@@ -248,20 +244,22 @@
     END(HTML_H1);
     PUTC('\n');
     START(HTML_PRE);
-    while ((ich=NEXT_CHAR) != EOF) {
+    while ((ich = NEXT_CHAR) != EOF) {
 
 	if (interrupted_in_htgetcharacter) {
-	    CTRACE((tfp, "HTGopher: Interrupted in HTGetCharacter, apparently.\n"));
+	    CTRACE((tfp,
+		    "HTGopher: Interrupted in HTGetCharacter, apparently.\n"));
 	    goto end_html;
 	}
 
-	if ((char)ich != LF) {
-	    *p = (char) ich;    /* Put character in line */
-	    if (p< &line[BIG-1]) p++;
+	if ((char) ich != LF) {
+	    *p = (char) ich;	/* Put character in line */
+	    if (p < &line[BIG - 1])
+		p++;
 
 	} else {
 	    *p++ = '\0';	/* Terminate line */
-	    bytes += p-line;	/* add size */
+	    bytes += p - line;	/* add size */
 	    p = line;		/* Scan it to parse it */
 	    port = 0;		/* Flag "not parsed" */
 	    CTRACE((tfp, "HTGopher: Menu item: %s\n", line));
@@ -274,14 +272,14 @@
 	    }
 
 	    /* Break on line with a dot by itself */
-	    if ((gtype=='.') && ((*p=='\r') || (*p==0)))
+	    if ((gtype == '.') && ((*p == '\r') || (*p == 0)))
 		break;
 
 	    if (gtype && *p) {
 		name = p;
 		selector = strchr(name, TAB);
 		if (selector) {
-		    *selector++ = '\0'; /* Terminate name */
+		    *selector++ = '\0';		/* Terminate name */
 		    /*
 		     * Gopher+ Type=0+ objects can be binary, and will
 		     * have 9 or 5 beginning their selector.  Make sure
@@ -293,23 +291,26 @@
 			gtype = *selector;
 		    host = strchr(selector, TAB);
 		    if (host) {
-			*host++ = '\0'; /* Terminate selector */
+			*host++ = '\0';		/* Terminate selector */
 			port = strchr(host, TAB);
 			if (port) {
 			    char *junk;
+
 			    port[0] = ':';	/* delimit host a la W3 */
 			    junk = strchr(port, TAB);
-			    if (junk) *junk++ = '\0';	/* Chop port */
-			    if ((port[1]=='0') && (!port[2]))
-				port[0] = '\0'; /* 0 means none */
-			} /* no port */
-		    } /* host ok */
-		} /* selector ok */
-	    } /* gtype and name ok */
-
+			    if (junk)
+				*junk++ = '\0';		/* Chop port */
+			    if ((port[1] == '0') && (!port[2]))
+				port[0] = '\0';		/* 0 means none */
+			}	/* no port */
+		    }		/* host ok */
+		}		/* selector ok */
+	    }
+	    /* gtype and name ok */
 	    /* Nameless files are a separator line */
 	    if (gtype == GOPHER_TEXT) {
-		int i = strlen(name)-1;
+		int i = strlen(name) - 1;
+
 		while (name[i] == ' ' && i >= 0)
 		    name[i--] = '\0';
 		if (i < 0)
@@ -321,112 +322,109 @@
 		write_anchor(name, selector);
 
 	    } else if (gtype == GOPHER_INFO) {
-	    /* Information or separator line */
+		/* Information or separator line */
 		PUTS("       ");
 		PUTS(name);
 
-	    } else if (port) {		/* Other types need port */
+	    } else if (port) {	/* Other types need port */
 		char *address = 0;
-		char *format = *selector ? "%s//%s@%s/" : "%s//%s/";
+		const char *format = *selector ? "%s//%s@%s/" : "%s//%s/";
 
 		if (gtype == GOPHER_TELNET) {
 		    PUTS(" (TEL) ");
 		    HTSprintf0(&address, format, STR_TELNET_URL, selector, host);
-		}
-		else if (gtype == GOPHER_TN3270)
-		{
+		} else if (gtype == GOPHER_TN3270) {
 		    PUTS("(3270) ");
 		    HTSprintf0(&address, format, STR_TN3270_URL, selector, host);
-		}
-		else {			/* If parsed ok */
+		} else {	/* If parsed ok */
 		    char *r;
 
-		    switch(gtype) {
-			case GOPHER_TEXT:
-			    PUTS("(FILE) ");
-			    break;
-			case GOPHER_MENU:
-			    PUTS(" (DIR) ");
-			    break;
-			case GOPHER_CSO:
-			    PUTS(" (CSO) ");
-			    break;
-			case GOPHER_PCBINARY:
-			    PUTS(" (BIN) ");
-			    break;
-			case GOPHER_UUENCODED:
-			    PUTS(" (UUE) ");
-			    break;
-			case GOPHER_INDEX:
-			    PUTS("  (?)  ");
-			    break;
-			case GOPHER_BINARY:
-			    PUTS(" (BIN) ");
-			    break;
-			case GOPHER_GIF:
-			case GOPHER_IMAGE:
-			case GOPHER_PLUS_IMAGE:
-			    PUTS(" (IMG) ");
-			    break;
-			case GOPHER_SOUND:
-			case GOPHER_PLUS_SOUND:
-			    PUTS(" (SND) ");
-			    break;
-			case GOPHER_MACBINHEX:
-			    PUTS(" (HQX) ");
-			    break;
-			case GOPHER_HTML:
-			case GOPHER_CHTML:
-			    PUTS("(HTML) ");
-			    break;
-			case 'm':
-			    PUTS("(MIME) ");
-			    break;
-			case GOPHER_PLUS_MOVIE:
-			    PUTS(" (MOV) ");
-			    break;
-			case GOPHER_PLUS_PDF:
-			    PUTS(" (PDF) ");
-			    break;
-			default:
-			    PUTS("(UNKN) ");
-			    break;
+		    switch (gtype) {
+		    case GOPHER_TEXT:
+			PUTS("(FILE) ");
+			break;
+		    case GOPHER_MENU:
+			PUTS(" (DIR) ");
+			break;
+		    case GOPHER_CSO:
+			PUTS(" (CSO) ");
+			break;
+		    case GOPHER_PCBINARY:
+			PUTS(" (BIN) ");
+			break;
+		    case GOPHER_UUENCODED:
+			PUTS(" (UUE) ");
+			break;
+		    case GOPHER_INDEX:
+			PUTS("  (?)  ");
+			break;
+		    case GOPHER_BINARY:
+			PUTS(" (BIN) ");
+			break;
+		    case GOPHER_GIF:
+		    case GOPHER_IMAGE:
+		    case GOPHER_PLUS_IMAGE:
+			PUTS(" (IMG) ");
+			break;
+		    case GOPHER_SOUND:
+		    case GOPHER_PLUS_SOUND:
+			PUTS(" (SND) ");
+			break;
+		    case GOPHER_MACBINHEX:
+			PUTS(" (HQX) ");
+			break;
+		    case GOPHER_HTML:
+		    case GOPHER_CHTML:
+			PUTS("(HTML) ");
+			break;
+		    case 'm':
+			PUTS("(MIME) ");
+			break;
+		    case GOPHER_PLUS_MOVIE:
+			PUTS(" (MOV) ");
+			break;
+		    case GOPHER_PLUS_PDF:
+			PUTS(" (PDF) ");
+			break;
+		    default:
+			PUTS("(UNKN) ");
+			break;
 		    }
 
 		    HTSprintf0(&address, "//%s/%c", host, gtype);
 
-		    for(r = selector; *r; r++) { /* Encode selector string */
+		    for (r = selector; *r; r++) {	/* Encode selector string */
 			if (acceptable[UCH(*r)]) {
 			    HTSprintf(&address, "%c", *r);
 			} else {
 			    HTSprintf(&address, "%c%c%c",
-				HEX_ESCAPE,	/* Means hex coming */
-				hex[(TOASCII(*r)) >> 4],
-				hex[(TOASCII(*r)) & 15]);
+				      HEX_ESCAPE,	/* Means hex coming */
+				      hex[(TOASCII(*r)) >> 4],
+				      hex[(TOASCII(*r)) & 15]);
 			}
 		    }
 		}
 		/* Error response from Gopher doesn't deserve to
 		   be a hyperlink. */
-		if (strcmp (address, "gopher://error.host:1/0"))
+		if (strcmp(address, "gopher://error.host:1/0"))
 		    write_anchor(name, address);
 		else
 		    PUTS(name);
 		FREE(address);
-	    } else { /* parse error */
+	    } else {		/* parse error */
 		CTRACE((tfp, "HTGopher: Bad menu item.\n"));
 		PUTS(line);
 
-	    } /* parse error */
+	    }			/* parse error */
 
 	    PUTC('\n');
-	    p = line;	/* Start again at beginning of line */
+	    p = line;		/* Start again at beginning of line */
 
-	} /* if end of line */
+	}			/* if end of line */
 
-    } /* Loop over characters */
+    }				/* Loop over characters */
 
-end_html:
+  end_html:
     END(HTML_PRE);
     PUTC('\n');
     END(HTML_BODY);
@@ -439,27 +437,26 @@
 }
 
 /*	Parse a Gopher CSO document from an ISINDEX query.
-**	==================================================
-**
-**   Accepts an open socket to a CSO server waiting to send us
-**   data and puts it on the screen in a reasonable manner.
-**
-**   Perhaps this data can be automatically linked to some
-**   other source as well???
-**
-**  Taken from hacking by Lou Montulli@ukanaix.cc.ukans.edu
-**  on XMosaic-1.1, and put on libwww 2.11 by Arthur Secret,
-**  secret@dxcern.cern.ch .
-*/
-PRIVATE void parse_cso ARGS2(
-	CONST char *,		arg,
-	HTParentAnchor *,	anAnchor)
+ *	==================================================
+ *
+ *   Accepts an open socket to a CSO server waiting to send us
+ *   data and puts it on the screen in a reasonable manner.
+ *
+ *   Perhaps this data can be automatically linked to some
+ *   other source as well???
+ *
+ *  Taken from hacking by Lou Montulli@ukanaix.cc.ukans.edu
+ *  on XMosaic-1.1, and put on libwww 2.11 by Arthur Secret,
+ *  secret@dxcern.cern.ch .
+ */
+static void parse_cso(const char *arg,
+		      HTParentAnchor *anAnchor)
 {
     int ich;
     char line[BIG];
     char *p = line;
-    char *second_colon, last_char='\0';
-    CONST char *title;
+    char *second_colon, last_char = '\0';
+    const char *title;
 
     START(HTML_HEAD);
     PUTC('\n');
@@ -484,107 +481,99 @@
     START(HTML_PRE);
 
     /*
-    **	Start grabbing chars from the network.
-    */
-    while ((ich=NEXT_CHAR) != EOF)
-	{
-	    if ((char)ich != LF)
-		{
-		    *p = (char) ich;    /* Put character in line */
-		    if (p< &line[BIG-1]) p++;
-		}
-	    else
-		{
-		    *p = '\0';		/* Terminate line */
-		    p = line;		/* Scan it to parse it */
-		    /*
-		    **	OK we now have a line in 'p'.
-		    **	Lets parse it and print it.
-		    */
+     * Start grabbing chars from the network.
+     */
+    while ((ich = NEXT_CHAR) != EOF) {
+	if ((char) ich != LF) {
+	    *p = (char) ich;	/* Put character in line */
+	    if (p < &line[BIG - 1])
+		p++;
+	} else {
+	    *p = '\0';		/* Terminate line */
+	    p = line;		/* Scan it to parse it */
+	    /*
+	     * OK we now have a line in 'p'.  Lets parse it and print it.
+	     */
 
-		    /*
-		    **	Break on line that begins with a 2.
-		    **	It's the end of data.
-		    */
-		    if (*p == '2')
-			break;
+	    /*
+	     * Break on line that begins with a 2.  It's the end of data.
+	     */
+	    if (*p == '2')
+		break;
 
-		    /*
-		    **	Lines beginning with 5 are errors.
-		    **	Print them and quit.
-		    */
-		    if (*p == '5') {
+	    /*
+	     * Lines beginning with 5 are errors.  Print them and quit.
+	     */
+	    if (*p == '5') {
+		START(HTML_H2);
+		PUTS(p + 4);
+		END(HTML_H2);
+		break;
+	    }
+
+	    if (*p == '-') {
+		/*
+		 * Data lines look like -200:#:
+		 * where # is the search result number and can be multiple
+		 * digits (infinite?).
+		 * Find the second colon and check the digit to the left of it
+		 * to see if they are diferent.  If they are then a different
+		 * person is starting.  Make this line an <h2>.
+		 */
+
+		/*
+		 * Find the second_colon.
+		 */
+		second_colon = strchr(strchr(p, ':') + 1, ':');
+
+		if (second_colon != NULL) {	/* error check */
+
+		    if (*(second_colon - 1) != last_char)
+			/* print seperator */
+		    {
+			END(HTML_PRE);
 			START(HTML_H2);
-			PUTS(p+4);
-			END(HTML_H2);
-			break;
 		    }
 
-		    if (*p == '-') {
-			/*
-			**  Data lines look like  -200:#:
-			**  where # is the search result number and can be
-			**  multiple digits (infinite?).
-			**  Find the second colon and check the digit to the
-			**  left of it to see if they are diferent.
-			**  If they are then a different person is starting.
-			**  Make this line an <h2>.
-			*/
+		    /*
+		     * Right now the record appears with the alias (first line)
+		     * as the header and the rest as <pre> text.
+		     *
+		     * It might look better with the name as the header and the
+		     * rest as a <ul> with <li> tags.  I'm not sure whether the
+		     * name field comes in any special order or if its even
+		     * required in a record, so for now the first line is the
+		     * header no matter what it is (it's almost always the
+		     * alias).
+		     *
+		     * A <dl> with the first line as the <DT> and the rest as
+		     * some form of <DD> might good also?
+		     */
 
-			/*
-			**  Find the second_colon.
-			*/
-			second_colon = strchr( strchr(p,':')+1, ':');
-
-			if(second_colon != NULL) {  /* error check */
-
-			    if (*(second_colon-1) != last_char)
-				/* print seperator */
-			    {
-				END(HTML_PRE);
-				START(HTML_H2);
-			    }
+		    /*
+		     * Print data.
+		     */
+		    PUTS(second_colon + 1);
+		    PUTC('\n');
 
+		    if (*(second_colon - 1) != last_char)
+			/* end seperator */
+		    {
+			END(HTML_H2);
+			START(HTML_PRE);
+		    }
 
-			    /*
-			    **	Right now the record appears with the alias
-			    **	(first line) as the header and the rest as
-			    **	<pre> text.
-			    **	It might look better with the name as the
-			    **	header and the rest as a <ul> with <li> tags.
-			    **	I'm not sure whether the name field comes in
-			    **	any special order or if its even required in
-			    **	a record, so for now the first line is the
-			    **	header no matter what it is (it's almost
-			    **	always the alias).
-			    **	A <dl> with the first line as the <DT> and
-			    **	the rest as some form of <DD> might good also?
-			    */
-
-			    /*
-			    **	Print data.
-			    */
-			    PUTS(second_colon+1);
-			    PUTC('\n');
-
-			    if (*(second_colon-1) != last_char)
-				/* end seperator */
-			    {
-				END(HTML_H2);
-				START(HTML_PRE);
-			    }
+		    /*
+		     * Save the char before the second colon for comparison on
+		     * the next pass.
+		     */
+		    last_char = *(second_colon - 1);
 
-			    /*
-			    **	Save the char before the second colon
-			    **	for comparison on the next pass.
-			    */
-			    last_char =  *(second_colon-1) ;
-
-			} /* end if second_colon */
-		    } /* end if *p == '-' */
-		} /* if end of line */
+		}		/* end if second_colon */
+	    }			/* end if *p == '-' */
+	}			/* if end of line */
 
-	} /* Loop over characters */
+    }				/* Loop over characters */
 
     /* end the text block */
     PUTC('\n');
@@ -592,17 +581,16 @@
     PUTC('\n');
     FREE_TARGET;
 
-    return;  /* all done */
-} /* end of procedure */
+    return;			/* all done */
+}				/* end of procedure */
 
 /*	Display a Gopher CSO ISINDEX cover page.
-**	========================================
-*/
-PRIVATE void display_cso ARGS2(
-	CONST char *,		arg,
-	HTParentAnchor *,	anAnchor)
+ *	========================================
+ */
+static void display_cso(const char *arg,
+			HTParentAnchor *anAnchor)
 {
-    CONST char * title;
+    const char *title;
 
     START(HTML_HEAD);
     PUTC('\n');
@@ -621,8 +609,8 @@
     if ((title = HTAnchor_title(anAnchor)))
 	PUTS(title);
     else {
-       PUTS(arg);
-       PUTS(INDEX_SEGMENT);
+	PUTS(arg);
+	PUTS(INDEX_SEGMENT);
     }
     END(HTML_H1);
     PUTS(GOPHER_CSO_INDEX_SUBTITLE);
@@ -640,13 +628,12 @@
 }
 
 /*	Display a Gopher Index document.
-**	================================
-*/
-PRIVATE void display_index ARGS2(
-				  CONST char *, arg,
-				  HTParentAnchor *,anAnchor)
+ *	================================
+ */
+static void display_index(const char *arg,
+			  HTParentAnchor *anAnchor)
 {
-    CONST char * title;
+    const char *title;
 
     START(HTML_HEAD);
     PUTC('\n');
@@ -666,8 +653,8 @@
     if ((title = HTAnchor_title(anAnchor)))
 	PUTS(title);
     else {
-       PUTS(arg);
-       PUTS(INDEX_SEGMENT);
+	PUTS(arg);
+	PUTS(INDEX_SEGMENT);
     }
     END(HTML_H1);
     PUTS(GOPHER_INDEX_SUBTITLE);
@@ -682,38 +669,40 @@
 }
 
 /*	De-escape a selector into a command.
-**	====================================
-**
-**	The % hex escapes are converted. Otheriwse, the string is copied.
-*/
-PRIVATE void de_escape ARGS2(char *, command, CONST char *, selector)
+ *	====================================
+ *
+ *	The % hex escapes are converted. Otheriwse, the string is copied.
+ */
+static void de_escape(char *command, const char *selector)
 {
-    CONST char * p = selector;
-    char * q = command;
-	if (command == NULL)
-	    outofmem(__FILE__, "HTLoadGopher");
+    const char *p = selector;
+    char *q = command;
+
+    if (command == NULL)
+	outofmem(__FILE__, "HTLoadGopher");
     while (*p) {		/* Decode hex */
 	if (*p == HEX_ESCAPE) {
 	    char c;
 	    unsigned int b;
+
 	    p++;
 	    c = *p++;
-	    b =   from_hex(c);
+	    b = from_hex(c);
 	    c = *p++;
-	    if (!c) break;	/* Odd number of chars! */
-	    *q++ = (char) FROMASCII((b<<4) + from_hex(c));
+	    if (!c)
+		break;		/* Odd number of chars! */
+	    *q++ = (char) FROMASCII((b << 4) + from_hex(c));
 	} else {
 	    *q++ = *p++;	/* Record */
 	}
     }
-    *q++ = '\0';	/* Terminate command */
+    *q++ = '\0';		/* Terminate command */
 }
 
-
 /*	Free the CSOfields structures. - FM
-**	===================================
-*/
-PRIVATE void free_CSOfields NOPARAMS
+ *	===================================
+ */
+static void free_CSOfields(void)
 {
     CSOfield_info *cur = CSOfields;
     CSOfield_info *prev;
@@ -734,22 +723,22 @@
 }
 
 /*	Interpret CSO/PH form template keys. - FM
-**	=========================================
-*/
-PRIVATE void interpret_cso_key ARGS5(
-	char *,			key,
-	char *,			buf,
-	int *,			length,
-	CSOformgen_context *,	ctx,
-	HTStream *,		Target)
+ *	=========================================
+ */
+static void interpret_cso_key(const char *key,
+			      char *buf,
+			      int *length,
+			      CSOformgen_context * ctx,
+			      HTStream *Target)
 {
     CSOfield_info *fld;
 
     if ((fld = ctx->fld) != 0) {
 	/*
-	**  Most substitutions only recognized inside of loops.
-	*/
+	 * Most substitutions only recognized inside of loops.
+	 */
 	int error = 0;
+
 	if (0 == strncmp(key, "$(FID)", 6)) {
 	    sprintf(buf, "%d", fld->id);
 	} else if (0 == strncmp(key, "$(FDESC)", 8)) {
@@ -779,34 +768,34 @@
 	else
 	    fld = ctx->fld->next;
 	switch (ctx->field_select) {
-	  case 0:
+	case 0:
 	    /*
-	    **	'Query' fields, public and lookup attributes.
-	    */
+	     * 'Query' fields, public and lookup attributes.
+	     */
 	    for (; fld; fld = fld->next)
-		 if (fld->public && (fld->lookup==1))
-		     break;
+		if (fld->gpublic && (fld->lookup == 1))
+		    break;
 	    break;
-	  case 1:
+	case 1:
 	    /*
-	    **	'Query' fields, accept lookup attribute.
-	    */
+	     * 'Query' fields, accept lookup attribute.
+	     */
 	    for (; fld; fld = fld->next)
 		if (fld->lookup == 1)
 		    break;
 	    break;
-	  case 2:
+	case 2:
 	    /*
-	    **	'Return' fields, public only.
-	    */
+	     * 'Return' fields, public only.
+	     */
 	    for (; fld; fld = fld->next)
-		if (fld->public)
+		if (fld->gpublic)
 		    break;
 	    break;
-	  case 3:
+	case 3:
 	    /*
-	    **	All fields.
-	    */
+	     * All fields.
+	     */
 	    break;
 	}
 	if (fld) {
@@ -818,8 +807,8 @@
     } else if ((0 == strncmp(key, "$(QFIELDS)", 10)) ||
 	       (0 == strncmp(key, "$(RFIELDS)", 10))) {
 	/*
-	**  Begin iteration sequence.
-	*/
+	 * Begin iteration sequence.
+	 */
 	ctx->rep_line = ctx->cur_line;
 	ctx->rep_off = ctx->cur_off;
 	ctx->fld = (CSOfield_info *) 0;
@@ -830,8 +819,8 @@
 
     } else if (0 == strncmp(key, "$(NAMEFLD)", 10)) {
 	/*
-	**  Special, locate name field.  Flag lookup so QFIELDS will skip it.
-	*/
+	 * Special, locate name field.  Flag lookup so QFIELDS will skip it.
+	 */
 	for (fld = CSOfields; fld; fld = fld->next)
 	    if (strcmp(fld->name, "name") == 0 ||
 		strcmp(fld->name, "Name") == 0) {
@@ -840,20 +829,21 @@
 		break;
 	    }
 	ctx->fld = fld;
-    } else if (0 == strncmp (key, "$(HOST)", 7)) {
-	strcpy (buf, ctx->host);
-    } else if (0 == strncmp (key, "$(PORT)", 7)) {
+    } else if (0 == strncmp(key, "$(HOST)", 7)) {
+	strcpy(buf, ctx->host);
+    } else if (0 == strncmp(key, "$(PORT)", 7)) {
 	sprintf(buf, "%d", ctx->port);
     } else {
 	/*
-	**  No match, dump key to buffer so client sees it for debugging.
-	*/
+	 * No match, dump key to buffer so client sees it for debugging.
+	 */
 	size_t out = 0;
+
 	while (*key && (*key != ')')) {
 	    buf[out++] = (*key++);
-	    if (out > sizeof(buf)-2) {
+	    if (out > sizeof(buf) - 2) {
 		buf[out] = '\0';
-		(*Target->isa->put_block)(Target, buf, strlen(buf));
+		(*Target->isa->put_block) (Target, buf, strlen(buf));
 		out = 0;
 	    }
 	}
@@ -867,23 +857,22 @@
 }
 
 /*	Parse the elements in a CSO/PH fields structure. - FM
-**	=====================================================
-*/
-PRIVATE int parse_cso_field_info ARGS1(
-	CSOfield_info *,	blk)
+ *	=====================================================
+ */
+static int parse_cso_field_info(CSOfield_info *blk)
 {
     char *info, *max_spec;
 
     /*
-    ** Initialize all fields to default values.
-    */
+     * Initialize all fields to default values.
+     */
     blk->indexed = blk->lookup = blk->reserved = blk->max_size = blk->url = 0;
-    blk->defreturn = blk->explicit_return = blk->public = 0;
+    blk->defreturn = blk->explicit_return = blk->gpublic = 0;
 
     /*
-    **	Search for keywords in info string and set values.  Attributes
-    **	are converted to all lower-case for comparison.
-    */
+     * Search for keywords in info string and set values.  Attributes are
+     * converted to all lower-case for comparison.
+     */
     info = blk->attributes;
     LYLowerCase(info);
     if (strstr(info, "indexed "))
@@ -891,7 +880,7 @@
     if (strstr(info, "default "))
 	blk->defreturn = 1;
     if (strstr(info, "public "))
-	blk->public = 1;
+	blk->gpublic = 1;
     if (strstr(info, "lookup "))
 	blk->lookup = 1;
     if (strstr(info, "url ")) {
@@ -909,37 +898,37 @@
 }
 
 /*	Parse a reply from a CSO/PH fields request. - FM
-**	================================================
-*/
-PRIVATE int parse_cso_fields ARGS2(
-	char *,		buf,
-	int,		size)
+ *	================================================
+ */
+static int parse_cso_fields(char *buf,
+			    int size)
 {
     int ich;
     char *p = buf;
     int i, code = 0, prev_code;
     size_t alen;
     char *indx, *name;
-    CSOfield_info *last, *new;
+    CSOfield_info *last, *newf;
 
     last = CSOfields = (CSOfield_info *) 0;
     prev_code = -2555;
     buf[0] = '\0';
 
     /*
-    **	Start grabbing chars from the network.
-    */
+     * Start grabbing chars from the network.
+     */
     while ((ich = NEXT_CHAR) != EOF) {
 	if (interrupted_in_htgetcharacter) {
-	    CTRACE((tfp, "HTLoadCSO: Interrupted in HTGetCharacter, apparently.\n"));
+	    CTRACE((tfp,
+		    "HTLoadCSO: Interrupted in HTGetCharacter, apparently.\n"));
 	    free_CSOfields();
 	    buf[0] = '\0';
 	    return HT_INTERRUPTED;
 	}
 
-	if ((char)ich != LF) {
-	    *p = (char) ich;    /* Put character in buffer */
-	    if (p < &buf[size-1]) {
+	if ((char) ich != LF) {
+	    *p = (char) ich;	/* Put character in buffer */
+	    if (p < &buf[size - 1]) {
 		p++;
 	    }
 	} else {
@@ -950,48 +939,46 @@
 	     */
 
 	    /*
-	    **	Break on line that begins with a 2.
-	    **	It's the end of data.
-	    */
+	     * Break on line that begins with a 2.  It's the end of data.
+	     */
 	    if (*p == '2')
 		break;
 
 	    /*
-	    **	Lines beginning with 5 are errors.
-	    **	Print them and quit.
-	    */
+	     * Lines beginning with 5 are errors.  Print them and quit.
+	     */
 	    if (*p == '5') {
-		strcpy (buf, p);
+		strcpy(buf, p);
 		return 5;
 	    }
 
 	    if (*p == '-') {
 		/*
-		**  Data lines look like  -200:#:
-		**  where # is the search result number and can be
-		**  multiple digits (infinite?).
-		*/
+		 * Data lines look like -200:#:
+		 * where # is the search result number and can be multiple
+		 * digits (infinite?).
+		 */
 
 		/*
-		** Check status, ignore any non-success.
-		*/
-		if (p[1] != '2' )
+		 * Check status, ignore any non-success.
+		 */
+		if (p[1] != '2')
 		    continue;
 
 		/*
-		** Parse fields within returned line into status, ndx, name,
-		** data.
-		*/
+		 * Parse fields within returned line into status, ndx, name,
+		 * data.
+		 */
 		indx = NULL;
 		name = NULL;
 		for (i = 0; p[i]; i++) {
-		    if (p[i] == ':' ) {
+		    if (p[i] == ':') {
 			p[i] = '\0';
 			if (!indx) {
-			    indx = (char *)&p[i+1];
-			    code = atoi (indx);
+			    indx = (char *) &p[i + 1];
+			    code = atoi(indx);
 			} else if (!name) {
-			    name = (char *)&p[i+1];
+			    name = (char *) &p[i + 1];
 			} else {
 			    i++;
 			    break;
@@ -999,121 +986,124 @@
 		    }
 		}
 		/*
-		**  Add data to field structure.
-		*/
+		 * Add data to field structure.
+		 */
 		if (name) {
 		    if (code == prev_code) {
 			/*
-			**  Remaining data are description.
-			**  Save in current info block.
-			*/
-			alen = strlen((char *)&p[i]) + 1;
+			 * Remaining data are description.  Save in current
+			 * info block.
+			 */
+			alen = strlen((char *) &p[i]) + 1;
 			if (alen > sizeof(last->desc_buf)) {
 			    if (last->description != last->desc_buf)
 				FREE(last->description);
-			    if (!(last->description = (char *)malloc(alen))) {
+			    if (!(last->description = (char *) malloc(alen))) {
 				outofmem(__FILE__, "HTLoadCSO");
 			    }
 			}
-			strcpy(last->description, (char *)&p[i]);
+			strcpy(last->description, (char *) &p[i]);
 		    } else {
 			/*
-			**  Initialize new block, append to end of list
-			**  to preserve order.
-			*/
-			new = typecalloc(CSOfield_info);
-			if (!new) {
+			 * Initialize new block, append to end of list to
+			 * preserve order.
+			 */
+			newf = typecalloc(CSOfield_info);
+
+			if (!newf) {
 			    outofmem(__FILE__, "HTLoadCSO");
 			}
 			if (last)
-			    last->next = new;
+			    last->next = newf;
 			else
-			    CSOfields = new;
-			last = new;
+			    CSOfields = newf;
+			last = newf;
 
-			new->next = (CSOfield_info *) 0;
-			new->name = new->name_buf;
+			newf->next = (CSOfield_info *) 0;
+			newf->name = newf->name_buf;
 			alen = strlen(name) + 1;
-			if (alen > sizeof(new->name_buf)) {
-			    if (!(new->name = (char *)malloc(alen))) {
+			if (alen > sizeof(newf->name_buf)) {
+			    if (!(newf->name = (char *) malloc(alen))) {
 				outofmem(__FILE__, "HTLoadCSO");
 			    }
 			}
-			strcpy (new->name, name);
+			strcpy(newf->name, name);
 
-			new->attributes = new->attr_buf;
-			alen = strlen((char *)&p[i]) + 2;
-			if (alen > sizeof(new->attr_buf)) {
-			    if (!(new->attributes = (char *)malloc(alen))) {
+			newf->attributes = newf->attr_buf;
+			alen = strlen((char *) &p[i]) + 2;
+			if (alen > sizeof(newf->attr_buf)) {
+			    if (!(newf->attributes = (char *) malloc(alen))) {
 				outofmem(__FILE__, "HTLoadCSO");
 			    }
 			}
-			strcpy(new->attributes, (char *)&p[i]);
-			strcpy((char *)&new->attributes[alen-2], " ");
-			new->description = new->desc_buf;
-			new->desc_buf[0] = '\0';
-			new->id = atoi(indx);
+			strcpy(newf->attributes, (char *) &p[i]);
+			strcpy((char *) &newf->attributes[alen - 2], " ");
+			newf->description = newf->desc_buf;
+			newf->desc_buf[0] = '\0';
+			newf->id = atoi(indx);
 			/*
-			**  Scan for keywords.
-			*/
-			parse_cso_field_info(new);
+			 * Scan for keywords.
+			 */
+			parse_cso_field_info(newf);
 		    }
 		    prev_code = code;
 		} else
 		    break;
-	    } /* end if *p == '-' */
-	} /* if end of line */
+	    }			/* end if *p == '-' */
+	}			/* if end of line */
 
-    } /* Loop over characters */
+    }				/* Loop over characters */
 
     /* end the text block */
 
     if (buf[0] == '\0') {
-	return -1; /* no response */
+	return -1;		/* no response */
     }
     buf[0] = '\0';
-    return 0;  /* all done */
-} /* end of procedure */
+    return 0;			/* all done */
+}				/* end of procedure */
 
 /*	Generate a form for submitting CSO/PH searches. - FM
-**	====================================================
-*/
-PRIVATE int generate_cso_form ARGS4(
-	char *,		host,
-	int,		port,
-	char *,		buf,
-	HTStream *,	Target)
+ *	====================================================
+ */
+static int generate_cso_form(char *host,
+			     int port,
+			     char *buf,
+			     HTStream *Target)
 {
     int i, j, length;
     size_t out;
     int full_flag = 1;
-    char *key, *line;
+    const char *key;
+    const char *line;
     CSOformgen_context ctx;
-    static char *template[] = {
-   "<HTML>\n<HEAD>\n<TITLE>CSO/PH Query Form for $(HOST)</TITLE>\n</HEAD>\n<BODY>",
-   "<H2><I>CSO/PH Query Form</I> for <EM>$(HOST)</EM></H2>",
-   "To search the database for a name, fill in one or more of the fields",
-   "in the form below and activate the 'Submit query' button.  At least",
-   "one of the entered fields must be flagged as indexed.",
-   "<HR><FORM method=\"POST\" action=\"cso://$(HOST)/\">",
-   "[ <input type=\"submit\" value=\"Submit query\"> | ",
-   "<input type=\"reset\" value=\"Clear fields\"> ]",
-   "<P><DL>",
-   "   <DT>Search parameters (* indicates indexed field):",
-   "   <DD>", "$(NAMEFLD)    <DL COMPACT>\n    <DT><I>$(FDESC)</I>$(FNDX)",
-   "    <DD>Last: <input name=\"q_$(FID)\" type=\"text\" size=49$(FSIZE2)>",
-   "    <DD>First: <input name=\"q_$(FID)\" type=\"text\" size=48$(FSIZE2)>",
-   "$(QFIELDS)    <DT><I>$(FDESC)</I>$(FNDX)",
-   "    <DD><input name=\"q_$(FID)\" type=\"text\" $(FSIZE)>\n$(NEXTFLD)",
-   "    </DL>",
-   "   </DL>\n<P><DL>",
-   "   <DT>Output format:",
-   "   <DD>Returned data option: <select name=\"return\">",
-   "    <option>default<option selected>all<option>selected</select><BR>",
-   "$(RFIELDS)    <input type=\"checkbox\" name=\"r_$(FID)\"$(FDEF)> $(FDESC)<BR>",
-   "$(NEXTFLD)    ",
-   "   </DL></FORM><HR>\n</BODY>\n</HTML>",
-   (char *) 0
+    static const char *ctemplate[] =
+    {
+	"<HTML>\n<HEAD>\n<TITLE>CSO/PH Query Form for $(HOST)</TITLE>\n</HEAD>\n<BODY>",
+	"<H2><I>CSO/PH Query Form</I> for <EM>$(HOST)</EM></H2>",
+	"To search the database for a name, fill in one or more of the fields",
+	"in the form below and activate the 'Submit query' button.  At least",
+	"one of the entered fields must be flagged as indexed.",
+	"<HR><FORM method=\"POST\" action=\"cso://$(HOST)/\">",
+	"[ <input type=\"submit\" value=\"Submit query\"> | ",
+	"<input type=\"reset\" value=\"Clear fields\"> ]",
+	"<P><DL>",
+	"   <DT>Search parameters (* indicates indexed field):",
+	"   <DD>",
+	"$(NAMEFLD)    <DL COMPACT>\n    <DT><I>$(FDESC)</I>$(FNDX)",
+	"    <DD>Last: <input name=\"q_$(FID)\" type=\"text\" size=49$(FSIZE2)>",
+	"    <DD>First: <input name=\"q_$(FID)\" type=\"text\" size=48$(FSIZE2)>",
+	"$(QFIELDS)    <DT><I>$(FDESC)</I>$(FNDX)",
+	"    <DD><input name=\"q_$(FID)\" type=\"text\" $(FSIZE)>\n$(NEXTFLD)",
+	"    </DL>",
+	"   </DL>\n<P><DL>",
+	"   <DT>Output format:",
+	"   <DD>Returned data option: <select name=\"return\">",
+	"    <option>default<option selected>all<option>selected</select><BR>",
+	"$(RFIELDS)    <input type=\"checkbox\" name=\"r_$(FID)\"$(FDEF)> $(FDESC)<BR>",
+	"$(NEXTFLD)    ",
+	"   </DL></FORM><HR>\n</BODY>\n</HTML>",
+	(char *) 0
     };
 
     out = 0;
@@ -1123,53 +1113,55 @@
     ctx.fld = (CSOfield_info *) 0;
     ctx.public_override = full_flag;
     /*
-    **	Parse the strings in the template array to produce HTML document
-    **	to send to client.  First line is skipped for 'full' lists.
-    */
+     * Parse the strings in the template array to produce HTML document to send
+     * to client.  First line is skipped for 'full' lists.
+     */
     out = 0;
     buf[out] = '\0';
-    for (i = full_flag ? /***1***/ 0 : 0; template[i]; i++) {
+    for (i = full_flag ? /***1***/ 0 : 0;
+	 ctemplate[i];
+	 i++) {
 	/*
-	**  Search the current string for substitution, flagged by $(
-	*/
-	for (line=template[i], j = 0; line[j]; j++) {
-	    if ((line[j] == '$') && (line[j+1] == '(')) {
+	 * Search the current string for substitution, flagged by $(
+	 */
+	for (line = ctemplate[i], j = 0; line[j]; j++) {
+	    if ((line[j] == '$') && (line[j + 1] == '(')) {
 		/*
-		** Command detected, flush output buffer and find closing ')'
-		** that delimits the command.
-		*/
+		 * Command detected, flush output buffer and find closing ')'
+		 * that delimits the command.
+		 */
 		buf[out] = '\0';
 		if (out > 0)
-		    (*Target->isa->put_block)(Target, buf, strlen(buf));
+		    (*Target->isa->put_block) (Target, buf, strlen(buf));
 		out = 0;
-		for (key = &line[j]; line[j+1] && (line[j] != ')'); j++)
-		    ;
+		for (key = &line[j]; line[j + 1] && (line[j] != ')'); j++) ;
 		/*
-		**  Save context, interpet command and restore updated context.
-		*/
+		 * Save context, interpet command and restore updated context.
+		 */
 		ctx.cur_line = i;
 		ctx.cur_off = j;
 		interpret_cso_key(key, buf, &length, &ctx, Target);
 		i = ctx.cur_line;
 		j = ctx.cur_off;
-		line = template[i];
+		line = ctemplate[i];
 		out = length;
 
 		if (ctx.seek) {
 		    /*
-		    **	Command wants us to skip (forward) to indicated token.
-		    **	Start at current position.
-		    */
+		     * Command wants us to skip (forward) to indicated token. 
+		     * Start at current position.
+		     */
 		    int slen = strlen(ctx.seek);
-		    for (; template[i]; i++) {
-			for (line = template[i]; line[j]; j++) {
+
+		    for (; ctemplate[i]; i++) {
+			for (line = ctemplate[i]; line[j]; j++) {
 			    if (line[j] == '$')
 				if (0 == strncmp(ctx.seek, &line[j], slen)) {
 				    if (j == 0)
-					j = strlen(template[--i])-1;
+					j = strlen(ctemplate[--i]) - 1;
 				    else
 					--j;
-				    line = template[i];
+				    line = ctemplate[i];
 				    ctx.seek = (char *) 0;
 				    break;
 				}
@@ -1180,19 +1172,20 @@
 		    }
 		    if (ctx.seek) {
 			char *temp = 0;
+
 			HTSprintf0(&temp, GOPHER_CSO_SEEK_FAILED, ctx.seek);
-			(*Target->isa->put_block)(Target, temp, strlen(temp));
+			(*Target->isa->put_block) (Target, temp, strlen(temp));
 			FREE(temp);
 		    }
 		}
 	    } else {
 		/*
-		**  Non-command text, add to output buffer.
-		*/
+		 * Non-command text, add to output buffer.
+		 */
 		buf[out++] = line[j];
-		if (out > (sizeof(buf)-3)) {
+		if (out > (sizeof(buf) - 3)) {
 		    buf[out] = '\0';
-			(*Target->isa->put_block)(Target, buf, strlen(buf));
+		    (*Target->isa->put_block) (Target, buf, strlen(buf));
 		    out = 0;
 		}
 	    }
@@ -1201,16 +1194,15 @@
 	buf[out] = '\0';
     }
     if (out > 0)
-	(*Target->isa->put_block)(Target, buf, strlen(buf));
+	(*Target->isa->put_block) (Target, buf, strlen(buf));
 
     return 0;
 }
 
 /*	Generate a results report for CSO/PH form-based searches. - FM
-**	==============================================================
-*/
-PRIVATE int generate_cso_report ARGS1(
-	HTStream *,	Target)
+ *	==============================================================
+ */
+static int generate_cso_report(HTStream *Target)
 {
     int ich;
     char line[BIG];
@@ -1222,30 +1214,30 @@
     BOOL stop = FALSE;
 
     /*
-    **	Read lines until non-negative status.
-    */
+     * Read lines until non-negative status.
+     */
     prev_ndx = -100;
     /*
-    **	Start grabbing chars from the network.
-    */
+     * Start grabbing chars from the network.
+     */
     while (!stop && (ich = NEXT_CHAR) != EOF) {
 	if (interrupted_in_htgetcharacter) {
-	    CTRACE((tfp, "HTLoadCSO: Interrupted in HTGetCharacter, apparently.\n"));
-	    _HTProgress (CONNECTION_INTERRUPTED);
+	    CTRACE((tfp,
+		    "HTLoadCSO: Interrupted in HTGetCharacter, apparently.\n"));
+	    _HTProgress(CONNECTION_INTERRUPTED);
 	    goto end_CSOreport;
 	}
 
-	if ((char)ich != LF) {
-	    *p = (char) ich;    /* Put character in line */
-	    if (p < &line[BIG-1]) {
+	if ((char) ich != LF) {
+	    *p = (char) ich;	/* Put character in line */
+	    if (p < &line[BIG - 1]) {
 		p++;
 	    }
 	} else {
 	    *p = '\0';		/* Terminate line */
 	    /*
-	    **	OK we now have a line.
-	    **	Load it as 'p' and parse it.
-	    */
+	     * OK we now have a line.  Load it as 'p' and parse it.
+	     */
 	    p = line;
 	    if (p[0] != '-' && p[0] != '1') {
 		stop = TRUE;
@@ -1257,9 +1249,9 @@
 		if (p[i] == ':') {
 		    p[i] = '\0';
 		    if (!ndx_str) {
-			fname = ndx_str = &p[i+1];
+			fname = ndx_str = &p[i + 1];
 		    } else {
-			fname = &p[i+1];
+			fname = &p[i + 1];
 			break;
 		    }
 		}
@@ -1269,22 +1261,22 @@
 		if (prev_ndx != ndx) {
 		    if (prev_ndx != -100) {
 			HTSprintf0(&buf, "</DL></DL>\n");
-			(*Target->isa->put_block)(Target, buf, strlen(buf));
+			(*Target->isa->put_block) (Target, buf, strlen(buf));
 		    }
 		    if (ndx == 0) {
 			HTSprintf0(&buf,
-		  "<HR><DL><DT>Information/status<DD><DL><DT>\n");
-			(*Target->isa->put_block)(Target, buf, strlen(buf));
+				   "<HR><DL><DT>Information/status<DD><DL><DT>\n");
+			(*Target->isa->put_block) (Target, buf, strlen(buf));
 		    } else {
 			HTSprintf0(&buf,
-	      "<HR><DL><DT>Entry %d:<DD><DL COMPACT><DT>\n", ndx);
-			(*Target->isa->put_block)(Target, buf, strlen(buf));
+				   "<HR><DL><DT>Entry %d:<DD><DL COMPACT><DT>\n", ndx);
+			(*Target->isa->put_block) (Target, buf, strlen(buf));
 		    }
 		    prev_ndx = ndx;
 		}
 	    } else {
 		HTSprintf0(&buf, "<DD>%s\n", rcode);
-		(*Target->isa->put_block)(Target, buf, strlen(buf));
+		(*Target->isa->put_block) (Target, buf, strlen(buf));
 		continue;
 	    }
 	    if ((*rcode >= '2') && (*rcode <= '5') && (fname != ndx_str)) {
@@ -1296,7 +1288,7 @@
 			*fvalue++ = '\0';
 			i = strlen(fname) - 1;
 			while (i >= 0 && fname[i] == ' ') {
-			    fname[i--] = '\0'; /* trim trailing */
+			    fname[i--] = '\0';	/* trim trailing */
 			}
 			break;
 		    }
@@ -1317,12 +1309,12 @@
 		    }
 		    if (fld && fld->url) {
 			HTSprintf0(&buf,
-				"<DT><I>%s</I><DD><A HREF=\"%s\">%s</A>\n",
-				fname, fvalue, fvalue);
-			(*Target->isa->put_block)(Target, buf, strlen(buf));
+				   "<DT><I>%s</I><DD><A HREF=\"%s\">%s</A>\n",
+				   fname, fvalue, fvalue);
+			(*Target->isa->put_block) (Target, buf, strlen(buf));
 		    } else {
 			HTSprintf0(&buf, "<DT><I>%s</I><DD>", fname);
-			(*Target->isa->put_block)(Target, buf, strlen(buf));
+			(*Target->isa->put_block) (Target, buf, strlen(buf));
 			buf[0] = '\0';
 			l = fvalue;
 			while (*l) {
@@ -1345,7 +1337,8 @@
 				       strncmp(l, "http://", 7) &&
 				       strncmp(l, "https://", 8) &&
 				       strncmp(l, "wais://", 7) &&
-				       strncmp(l, STR_MAILTO_URL, LEN_MAILTO_URL) &&
+				       strncmp(l, STR_MAILTO_URL,
+					       LEN_MAILTO_URL) &&
 				       strncmp(l, "cso://", 6) &&
 				       strncmp(l, "gopher://", 9)) {
 				HTSprintf(&buf, "%c", *l++);
@@ -1362,11 +1355,11 @@
 			    }
 			}
 			StrAllocCat(buf, "\n");
-			(*Target->isa->put_block)(Target, buf, strlen(buf));
+			(*Target->isa->put_block) (Target, buf, strlen(buf));
 		    }
 		} else {
 		    HTSprintf0(&buf, "<DD>");
-		    (*Target->isa->put_block)(Target, buf, strlen(buf));
+		    (*Target->isa->put_block) (Target, buf, strlen(buf));
 		    buf[0] = '\0';
 		    l = fvalue;
 		    while (*l) {
@@ -1406,36 +1399,35 @@
 			}
 		    }
 		    StrAllocCat(buf, "\n");
-		    (*Target->isa->put_block)(Target, buf, strlen(buf));
+		    (*Target->isa->put_block) (Target, buf, strlen(buf));
 		}
 	    } else {
-		HTSprintf0(&buf, "<DD>%s\n", fname ? fname : rcode );
-		(*Target->isa->put_block)(Target, buf, strlen(buf));
+		HTSprintf0(&buf, "<DD>%s\n", fname ? fname : rcode);
+		(*Target->isa->put_block) (Target, buf, strlen(buf));
 	    }
 	}
     }
-end_CSOreport:
+  end_CSOreport:
     if (prev_ndx != -100) {
 	HTSprintf0(&buf, "</DL></DL>\n");
-	(*Target->isa->put_block)(Target, buf, strlen(buf));
+	(*Target->isa->put_block) (Target, buf, strlen(buf));
     }
     FREE(buf);
     return 0;
 }
 
 /*	CSO/PH form-based search gateway - FM			HTLoadCSO
-**	=====================================
-*/
-PRIVATE int HTLoadCSO ARGS4(
-	CONST char *,		arg,
-	HTParentAnchor *,	anAnchor,
-	HTFormat,		format_out,
-	HTStream*,		sink)
+ *	=====================================
+ */
+static int HTLoadCSO(const char *arg,
+		     HTParentAnchor *anAnchor,
+		     HTFormat format_out,
+		     HTStream *sink)
 {
-    static CONST char end_form[] = "</BODY>\n</HTML>\n";
+    static const char end_form[] = "</BODY>\n</HTML>\n";
     char *host, *cp, *data;
     int port = CSO_PORT;
-    int status;				/* tcp return */
+    int status;			/* tcp return */
     bstring *command = NULL;
     bstring *content = NULL;
     int len, i, j, start, finish, flen, ndx;
@@ -1446,29 +1438,30 @@
     HTStream *Target = NULL;
 
     if (!acceptable_inited)
-	 init_acceptable();
+	init_acceptable();
 
     if (!arg)
-	return -3;		/* Bad if no name sepcified	*/
+	return -3;		/* Bad if no name sepcified     */
     if (!*arg)
-	return -2;		/* Bad if name had zero length	*/
+	return -2;		/* Bad if name had zero length  */
     CTRACE((tfp, "HTLoadCSO: Looking for %s\n", arg));
 
     /*
-    **	Set up a socket to the server for the data.
-    */
-    status = HTDoConnect (arg, "cso", CSO_PORT, &s);
+     * Set up a socket to the server for the data.
+     */
+    status = HTDoConnect(arg, "cso", CSO_PORT, &s);
     if (status == HT_INTERRUPTED) {
 	/*
-	**  Interrupt cleanly.
-	*/
-	CTRACE((tfp, "HTLoadCSO: Interrupted on connect; recovering cleanly.\n"));
-	_HTProgress (CONNECTION_INTERRUPTED);
+	 * Interrupt cleanly.
+	 */
+	CTRACE((tfp,
+		"HTLoadCSO: Interrupted on connect; recovering cleanly.\n"));
+	_HTProgress(CONNECTION_INTERRUPTED);
 	return HT_NOT_LOADED;
     }
     if (status < 0) {
 	CTRACE((tfp, "HTLoadCSO: Unable to connect to remote host for `%s'.\n",
-		    arg));
+		arg));
 	return HTInetStatus("connect");
     }
 
@@ -1480,23 +1473,23 @@
 	trace_bstring(command);
 	CTRACE((tfp, "' to socket %d\n", s));
     }
-    _HTProgress (GOPHER_SENDING_CSO_REQUEST);
+    _HTProgress(GOPHER_SENDING_CSO_REQUEST);
     status = NETWRITE(s, BStrData(command), BStrLen(command));
     BStrFree(command);
     if (status < 0) {
 	CTRACE((tfp, "HTLoadCSO: Unable to send command.\n"));
 	return HTInetStatus("send");
     }
-    _HTProgress (GOPHER_SENT_CSO_REQUEST);
+    _HTProgress(GOPHER_SENT_CSO_REQUEST);
 
     /*
-    **	Now read the data from the socket.
-    */
+     * Now read the data from the socket.
+     */
     status = parse_cso_fields(buf, sizeof(buf));
     if (status) {
 	NETCLOSE(s);
 	if (status == HT_INTERRUPTED) {
-	    _HTProgress (CONNECTION_INTERRUPTED);
+	    _HTProgress(CONNECTION_INTERRUPTED);
 	} else if (buf[0] != '\0') {
 	    HTAlert(buf);
 	} else {
@@ -1509,6 +1502,7 @@
 			   sink, anAnchor);
     if (!Target || Target == NULL) {
 	char *temp = 0;
+
 	HTSprintf0(&temp, CANNOT_CONVERT_I_TO_O,
 		   HTAtom_name(format_in), HTAtom_name(format_out));
 	HTAlert(temp);
@@ -1519,7 +1513,7 @@
     host = HTParse(arg, "", PARSE_HOST);
     if ((cp = strchr(host, ':')) != NULL) {
 	if (cp[1] >= '0' && cp[1] <= '9') {
-	    port = atoi((cp+1));
+	    port = atoi((cp + 1));
 	    if (port == CSO_PORT) {
 		*cp = '\0';
 	    }
@@ -1528,7 +1522,7 @@
     anAnchor->safe = TRUE;
     if (isBEmpty(anAnchor->post_data)) {
 	generate_cso_form(host, port, buf, Target);
-	(*Target->isa->_free)(Target);
+	(*Target->isa->_free) (Target);
 	FREE(host);
 	NETCLOSE(s);
 	free_CSOfields();
@@ -1536,15 +1530,15 @@
     }
 
     HTBprintf(&command,
-     "<HTML>\n<HEAD>\n<TITLE>CSO/PH Results on %s</TITLE>\n</HEAD>\n<BODY>\n",
-	    host);
-    (*Target->isa->put_block)(Target, BStrData(command), BStrLen(command));
+	      "<HTML>\n<HEAD>\n<TITLE>CSO/PH Results on %s</TITLE>\n</HEAD>\n<BODY>\n",
+	      host);
+    (*Target->isa->put_block) (Target, BStrData(command), BStrLen(command));
     BStrFree(command);
     FREE(host);
 
     BStrCopy(content, anAnchor->post_data);
 
-    if (BStrData(content)[BStrLen(content)-1] != '&')
+    if (BStrData(content)[BStrLen(content) - 1] != '&')
 	BStrCat0(content, "&");
 
     data = BStrData(content);
@@ -1565,27 +1559,27 @@
     for (i = 0; i < len; i++) {
 	if (!data[i] || data[i] == '&') {
 	    /*
-	    **	Value parsed.  Unescape characters and look for first '='
-	    **	to delimit field name from value.
-	    */
+	     * Value parsed.  Unescape characters and look for first '=' to
+	     * delimit field name from value.
+	     */
 	    flen = i - start;
 	    finish = start + flen;
 	    data[finish] = '\0';
 	    for (j = start; j < finish; j++) {
 		if (data[j] == '=') {
 		    /*
-		    **	data[start..j-1] is field name,
-		    **	[j+1..finish-1] is value.
-		    */
-		    if ((data[start+1] == '_') &&
+		     * data[start..j-1] is field name,
+		     * [j+1..finish-1] is value.
+		     */
+		    if ((data[start + 1] == '_') &&
 			((data[start] == 'r') || (data[start] == 'q'))) {
 			/*
-			**  Decode fields number and lookup field info.
-			*/
-			sscanf (&data[start+2], "%d=", &ndx);
+			 * Decode fields number and lookup field info.
+			 */
+			sscanf(&data[start + 2], "%d=", &ndx);
 			for (fld = CSOfields; fld; fld = fld->next) {
-			    if (ndx==fld->id) {
-				if ((j+1) >= finish)
+			    if (ndx == fld->id) {
+				if ((j + 1) >= finish)
 				    break;	/* ignore nulls */
 				if (data[start] == 'q') {
 				    /*
@@ -1600,13 +1594,13 @@
 					    BStrCat0(command, " ");
 					}
 					HTBprintf(&command, "%s=\"%s\"",
-						  fld->name, &data[j+1]);
+						  fld->name, &data[j + 1]);
 				    } else {
 					strcpy(buf,
-				"Warning: non-lookup field ignored<BR>\n");
-					(*Target->isa->put_block)(Target,
-								  buf,
-								  strlen(buf));
+					       "Warning: non-lookup field ignored<BR>\n");
+					(*Target->isa->put_block) (Target,
+								   buf,
+								   strlen(buf));
 				    }
 				} else if (data[start] == 'r') {
 				    fld->explicit_return = 1;
@@ -1615,9 +1609,9 @@
 			    }
 			}
 		    } else if (!strncmp(&data[start], "return=", 7)) {
-			if (!strcmp(&data[start+7], "all")) {
+			if (!strcmp(&data[start + 7], "all")) {
 			    return_type = 1;
-			} else if (!strcmp(&data[start+7], "selected")) {
+			} else if (!strcmp(&data[start + 7], "selected")) {
 			    return_type = 2;
 			}
 		    }
@@ -1630,17 +1624,17 @@
     if (isBEmpty(command) || !has_indexed) {
 	NETCLOSE(s);
 	strcpy(buf,
-  "<EM>Error:</EM> At least one indexed field value must be specified!\n");
-	(*Target->isa->put_block)(Target, buf, strlen(buf));
+	       "<EM>Error:</EM> At least one indexed field value must be specified!\n");
+	(*Target->isa->put_block) (Target, buf, strlen(buf));
 	strcpy(buf, "</BODY>\n</HTML>\n");
-	(*Target->isa->put_block)(Target, buf, strlen(buf));
-	(*Target->isa->_free)(Target);
+	(*Target->isa->put_block) (Target, buf, strlen(buf));
+	(*Target->isa->_free) (Target);
 	free_CSOfields();
 	return HT_LOADED;
     }
     /*
-    **	Append return fields.
-    */
+     * Append return fields.
+     */
     if (return_type == 1) {
 	BStrCat0(command, " return all");
     } else if (return_type == 2) {
@@ -1653,12 +1647,12 @@
     }
     HTBprintf(&command, "%c%c", CR, LF);
     strcpy(buf, "<H2>\n<EM>CSO/PH command:</EM> ");
-    (*Target->isa->put_block)(Target, buf, strlen(buf));
-    (*Target->isa->put_block)(Target, BStrData(command), BStrLen(command));
+    (*Target->isa->put_block) (Target, buf, strlen(buf));
+    (*Target->isa->put_block) (Target, BStrData(command), BStrLen(command));
     strcpy(buf, "</H2>\n");
-    (*Target->isa->put_block)(Target, buf, strlen(buf));
+    (*Target->isa->put_block) (Target, buf, strlen(buf));
     if (TRACE) {
-	CTRACE((tfp, "HTLoadCSO: Writing command `"));  
+	CTRACE((tfp, "HTLoadCSO: Writing command `"));
 	trace_bstring(command);
 	CTRACE((tfp, "' to socket %d\n", s));
     }
@@ -1671,49 +1665,48 @@
     }
     generate_cso_report(Target);
     NETCLOSE(s);
-    (*Target->isa->put_block)(Target, end_form, sizeof(end_form)-1);
-    (*Target->isa->_free)(Target);
+    (*Target->isa->put_block) (Target, end_form, sizeof(end_form) - 1);
+    (*Target->isa->_free) (Target);
     FREE(host);
     free_CSOfields();
     return HT_LOADED;
 }
 
 /*	Load by name.						HTLoadGopher
-**	=============
-**
-**  Bug:  No decoding of strange data types as yet.
-**
-*/
-PRIVATE int HTLoadGopher ARGS4(
-	CONST char *,		arg,
-	HTParentAnchor *,	anAnchor,
-	HTFormat,		format_out,
-	HTStream*,		sink)
+ *	=============
+ *
+ *  Bug:  No decoding of strange data types as yet.
+ *
+ */
+static int HTLoadGopher(const char *arg,
+			HTParentAnchor *anAnchor,
+			HTFormat format_out,
+			HTStream *sink)
 {
-    char *command;			/* The whole command */
-    int status;				/* tcp return */
-    char gtype;				/* Gopher Node type */
-    char * selector;			/* Selector string */
+    char *command;		/* The whole command */
+    int status;			/* tcp return */
+    char gtype;			/* Gopher Node type */
+    char *selector;		/* Selector string */
 
     if (!acceptable_inited)
-	 init_acceptable();
+	init_acceptable();
 
     if (!arg)
-	return -3;		/* Bad if no name sepcified	*/
+	return -3;		/* Bad if no name sepcified     */
     if (!*arg)
-	return -2;		/* Bad if name had zero length	*/
+	return -2;		/* Bad if name had zero length  */
     CTRACE((tfp, "HTGopher: Looking for %s\n", arg));
 
     /*
-    **	If it's a port 105 GOPHER_CSO gtype with no ISINDEX token ('?'),
-    **	use the form-based CSO gateway (otherwise, return an ISINDEX
-    **	cover page or do the ISINDEX search). - FM
-    */
+     * If it's a port 105 GOPHER_CSO gtype with no ISINDEX token ('?'), use the
+     * form-based CSO gateway (otherwise, return an ISINDEX cover page or do
+     * the ISINDEX search).  - FM
+     */
     {
 	int len;
 
 	if ((len = strlen(arg)) > 5) {
-	    if (0 == strcmp((CONST char *)&arg[len-6], ":105/2")) {
+	    if (0 == strcmp((const char *) &arg[len - 6], ":105/2")) {
 		/* Use CSO gateway. */
 		CTRACE((tfp, "HTGopher: Passing to CSO/PH gateway.\n"));
 		return HTLoadCSO(arg, anAnchor, format_out, sink);
@@ -1722,8 +1715,8 @@
     }
 
     /*
-    **	If it's a port 79/0[/...] URL, use the finger gateway. - FM
-    */
+     * If it's a port 79/0[/...] URL, use the finger gateway.  - FM
+     */
     if (strstr(arg, ":79/0") != NULL) {
 #ifndef DISABLE_FINGER
 	CTRACE((tfp, "HTGopher: Passing to finger gateway.\n"));
@@ -1735,78 +1728,86 @@
     }
 
     /*
-    **	Get entity type, and selector string.
-    */
+     * Get entity type, and selector string.
+     */
     {
-	char * p1 = HTParse(arg, "", PARSE_PATH|PARSE_PUNCTUATION);
+	char *p1 = HTParse(arg, "", PARSE_PATH | PARSE_PUNCTUATION);
+
 	gtype = '1';		/* Default = menu */
 	selector = p1;
-	if ((*selector++=='/') && (*selector)) {	/* Skip first slash */
-	    gtype = *selector++;			/* Pick up gtype */
+	if ((*selector++ == '/') && (*selector)) {	/* Skip first slash */
+	    gtype = *selector++;	/* Pick up gtype */
 	}
 	if (gtype == GOPHER_INDEX) {
-	    char * query;
+	    char *query;
+
 	    /*
-	    **	Search is allowed.
-	    */
+	     * Search is allowed.
+	     */
 	    HTAnchor_setIndex(anAnchor, anAnchor->address);
 	    query = strchr(selector, '?');	/* Look for search string */
-	    if (!query || !query[1]) {		/* No search required */
+	    if (!query || !query[1]) {	/* No search required */
 		target = HTML_new(anAnchor, format_out, sink);
 		targetClass = *target->isa;
 		display_index(arg, anAnchor);	/* Display "cover page" */
-		return HT_LOADED;		/* Local function only */
+		return HT_LOADED;	/* Local function only */
 	    }
-	    *query++ = '\0';			/* Skip '?'	*/
+	    *query++ = '\0';	/* Skip '?'     */
 	    command =
-		    (char *)malloc(strlen(selector)+ 1 + strlen(query)+ 2 + 1);
-	      if (command == NULL)
-		  outofmem(__FILE__, "HTLoadGopher");
+		(char *) malloc(strlen(selector) + 1 + strlen(query) + 2 + 1);
+	    if (command == NULL)
+		outofmem(__FILE__, "HTLoadGopher");
 
 	    de_escape(command, selector);	/* Bug fix TBL 921208 */
 
 	    strcat(command, "\t");
 
-	    {					/* Remove plus signs 921006 */
+	    {			/* Remove plus signs 921006 */
 		char *p;
-		for (p=query; *p; p++) {
-		    if (*p == '+') *p = ' ';
+
+		for (p = query; *p; p++) {
+		    if (*p == '+')
+			*p = ' ';
 		}
 	    }
 
-	    de_escape(&command[strlen(command)], query);/* bug fix LJM 940415 */
+	    de_escape(&command[strlen(command)], query);	/* bug fix LJM 940415 */
 	} else if (gtype == GOPHER_CSO) {
-	    char * query;
+	    char *query;
+
 	    /*
-	    **	Search is allowed.
-	    */
+	     * Search is allowed.
+	     */
 	    query = strchr(selector, '?');	/* Look for search string */
-	    if (!query || !query[1]) {		/* No search required */
+	    if (!query || !query[1]) {	/* No search required */
 		target = HTML_new(anAnchor, format_out, sink);
 		targetClass = *target->isa;
 		display_cso(arg, anAnchor);	/* Display "cover page" */
-		return HT_LOADED;		/* Local function only */
+		return HT_LOADED;	/* Local function only */
 	    }
 	    HTAnchor_setIndex(anAnchor, anAnchor->address);
-	    *query++ = '\0';			/* Skip '?'	*/
-	    command = (char *)malloc(strlen("query")+1 + strlen(query)+2+1);
-	      if (command == NULL)
-		  outofmem(__FILE__, "HTLoadGopher");
+	    *query++ = '\0';	/* Skip '?'     */
+	    command = (char *) malloc(strlen("query") + 1 +
+				      strlen(query) + 2 + 1);
+	    if (command == NULL)
+		outofmem(__FILE__, "HTLoadGopher");
 
 	    de_escape(command, selector);	/* Bug fix TBL 921208 */
 
 	    strcpy(command, "query ");
 
-	    {					/* Remove plus signs 921006 */
+	    {			/* Remove plus signs 921006 */
 		char *p;
-		for (p=query; *p; p++) {
-		    if (*p == '+') *p = ' ';
+
+		for (p = query; *p; p++) {
+		    if (*p == '+')
+			*p = ' ';
 		}
 	    }
-	    de_escape(&command[strlen(command)], query);/* bug fix LJM 940415 */
+	    de_escape(&command[strlen(command)], query);	/* bug fix LJM 940415 */
 
-	} else {				/* Not index */
-	    command = (char *)malloc(strlen(selector)+2+1);
+	} else {		/* Not index */
+	    command = (char *) malloc(strlen(selector) + 2 + 1);
 	    if (command == NULL)
 		outofmem(__FILE__, "HTLoadGopher");
 	    de_escape(command, selector);
@@ -1815,28 +1816,29 @@
     }
 
     {
-	char * p = command + strlen(command);
+	char *p = command + strlen(command);
+
 	*p++ = CR;		/* Macros to be correct on Mac */
 	*p++ = LF;
 	*p++ = '\0';
     }
 
     /*
-    **	Set up a socket to the server for the data.
-    */
-    status = HTDoConnect (arg, "gopher", GOPHER_PORT, &s);
+     * Set up a socket to the server for the data.
+     */
+    status = HTDoConnect(arg, "gopher", GOPHER_PORT, &s);
     if (status == HT_INTERRUPTED) {
 	/*
-	**  Interrupt cleanly.
-	*/
+	 * Interrupt cleanly.
+	 */
 	CTRACE((tfp, "HTGopher: Interrupted on connect; recovering cleanly.\n"));
-	_HTProgress (CONNECTION_INTERRUPTED);
+	_HTProgress(CONNECTION_INTERRUPTED);
 	FREE(command);
 	return HT_NOT_LOADED;
     }
     if (status < 0) {
 	CTRACE((tfp, "HTGopher: Unable to connect to remote host for `%s'.\n",
-		    arg));
+		arg));
 	FREE(command);
 	return HTInetStatus("connect");
     }
@@ -1844,39 +1846,40 @@
     HTInitInput(s);		/* Set up input buffering */
 
     CTRACE((tfp, "HTGopher: Connected, writing command `%s' to socket %d\n",
-		command, s));
+	    command, s));
 
 #ifdef NOT_ASCII
     {
-	char * p;
+	char *p;
+
 	for (p = command; *p; p++) {
 	    *p = TOASCII(*p);
 	}
     }
 #endif
 
-    _HTProgress (GOPHER_SENDING_REQUEST);
+    _HTProgress(GOPHER_SENDING_REQUEST);
 
-    status = NETWRITE(s, command, (int)strlen(command));
+    status = NETWRITE(s, command, (int) strlen(command));
     FREE(command);
     if (status < 0) {
 	CTRACE((tfp, "HTGopher: Unable to send command.\n"));
 	return HTInetStatus("send");
     }
 
-    _HTProgress (GOPHER_SENT_REQUEST);
+    _HTProgress(GOPHER_SENT_REQUEST);
 
     /*
-    **	Now read the data from the socket.
-    */
+     * Now read the data from the socket.
+     */
     switch (gtype) {
 
-    case GOPHER_TEXT :
+    case GOPHER_TEXT:
 	HTParseSocket(WWW_PLAINTEXT, format_out, anAnchor, s, sink);
 	break;
 
-    case GOPHER_HTML :
-    case GOPHER_CHTML :
+    case GOPHER_HTML:
+    case GOPHER_CHTML:
 	HTParseSocket(WWW_HTML, format_out, anAnchor, s, sink);
 	break;
 
@@ -1884,11 +1887,11 @@
     case GOPHER_IMAGE:
     case GOPHER_PLUS_IMAGE:
 	HTParseSocket(HTAtom_for("image/gif"),
-			   format_out, anAnchor, s, sink);
+		      format_out, anAnchor, s, sink);
 	break;
 
-    case GOPHER_MENU :
-    case GOPHER_INDEX :
+    case GOPHER_MENU:
+    case GOPHER_INDEX:
 	target = HTML_new(anAnchor, format_out, sink);
 	targetClass = *target->isa;
 	parse_menu(arg, anAnchor);
@@ -1900,8 +1903,8 @@
 	parse_cso(arg, anAnchor);
 	break;
 
-    case GOPHER_SOUND :
-    case GOPHER_PLUS_SOUND :
+    case GOPHER_SOUND:
+    case GOPHER_PLUS_SOUND:
 	HTParseSocket(WWW_AUDIO, format_out, anAnchor, s, sink);
 	break;
 
@@ -1911,7 +1914,7 @@
 
     case GOPHER_PLUS_PDF:
 	HTParseSocket(HTAtom_for("application/pdf"), format_out, anAnchor,
-				  s, sink);
+		      s, sink);
 	break;
 
     case GOPHER_MACBINHEX:
@@ -1920,12 +1923,12 @@
     case GOPHER_BINARY:
     default:
 	/*
-	**  Specifying WWW_UNKNOWN forces dump to local disk.
-	*/
-	HTParseSocket (WWW_UNKNOWN, format_out, anAnchor, s, sink);
+	 * Specifying WWW_UNKNOWN forces dump to local disk.
+	 */
+	HTParseSocket(WWW_UNKNOWN, format_out, anAnchor, s, sink);
 	break;
 
-    } /* switch(gtype) */
+    }				/* switch(gtype) */
 
     NETCLOSE(s);
     return HT_LOADED;
@@ -1933,12 +1936,14 @@
 
 #ifdef GLOBALDEF_IS_MACRO
 #define _HTGOPHER_C_1_INIT { "gopher", HTLoadGopher, NULL }
-GLOBALDEF (HTProtocol, HTGopher, _HTGOPHER_C_1_INIT);
+GLOBALDEF(HTProtocol, HTGopher, _HTGOPHER_C_1_INIT);
 #define _HTCSO_C_1_INIT { "cso", HTLoadCSO, NULL }
-GLOBALDEF (HTProtocol, HTCSO, _HTCSO_C_1_INIT);
+GLOBALDEF(HTProtocol, HTCSO, _HTCSO_C_1_INIT);
 #else
-GLOBALDEF PUBLIC HTProtocol HTGopher = { "gopher", HTLoadGopher, NULL };
-GLOBALDEF PUBLIC HTProtocol HTCSO = { "cso", HTLoadCSO, NULL };
+GLOBALDEF HTProtocol HTGopher =
+{"gopher", HTLoadGopher, NULL};
+GLOBALDEF HTProtocol HTCSO =
+{"cso", HTLoadCSO, NULL};
 #endif /* GLOBALDEF_IS_MACRO */
 
 #endif /* not DISABLE_GOPHER */
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/HTMIME.c
+++ lynx-cur-2.8.6/WWW/Library/Implementation/HTMIME.c
@@ -1,20 +1,21 @@
 /*			MIME Message Parse			HTMIME.c
-**			==================
-**
-**	This is RFC 1341-specific code.
-**	The input stream pushed into this parser is assumed to be
-**	stripped on CRs, ie lines end with LF, not CR LF.
-**	(It is easy to change this except for the body part where
-**	conversion can be slow.)
-**
-** History:
-**	   Feb 92	Written Tim Berners-Lee, CERN
-**
-*/
+ *			==================
+ *
+ *	This is RFC 1341-specific code.
+ *	The input stream pushed into this parser is assumed to be
+ *	stripped on CRs, ie lines end with LF, not CR LF.
+ *	(It is easy to change this except for the body part where
+ *	conversion can be slow.)
+ *
+ * History:
+ *	   Feb 92	Written Tim Berners-Lee, CERN
+ *
+ */
 #include <HTUtils.h>
 #include <HTMIME.h>		/* Implemented here */
 #include <HTTP.h>		/* for redirecting_url */
 #include <HTAlert.h>
+#include <HTFile.h>
 #include <HTCJK.h>
 #include <UCMap.h>
 #include <UCDefs.h>
@@ -28,174 +29,176 @@
 #include <LYLeaks.h>
 
 /*		MIME Object
-**		-----------
-*/
+ *		-----------
+ */
 
 typedef enum {
-	MIME_TRANSPARENT,	/* put straight through to target ASAP! */
-	miBEGINNING_OF_LINE,	/* first character and not a continuation */
-	miA,
-	miACCEPT_RANGES,
-	miAGE,
-	miAL,
-	miALLOW,
-	miALTERNATES,
-	miC,
-	miCACHE_CONTROL,
-	miCO,
-	miCOOKIE,
-	miCON,
-	miCONNECTION,
-	miCONTENT_,
-	miCONTENT_BASE,
-	miCONTENT_DISPOSITION,
-	miCONTENT_ENCODING,
-	miCONTENT_FEATURES,
-	miCONTENT_L,
-	miCONTENT_LANGUAGE,
-	miCONTENT_LENGTH,
-	miCONTENT_LOCATION,
-	miCONTENT_MD5,
-	miCONTENT_RANGE,
-	miCONTENT_T,
-	miCONTENT_TRANSFER_ENCODING,
-	miCONTENT_TYPE,
-	miDATE,
-	miE,
-	miETAG,
-	miEXPIRES,
-	miKEEP_ALIVE,
-	miL,
-	miLAST_MODIFIED,
-	miLINK,
-	miLOCATION,
-	miP,
-	miPR,
-	miPRAGMA,
-	miPROXY_AUTHENTICATE,
-	miPUBLIC,
-	miR,
-	miRE,
-	miREFRESH,
-	miRETRY_AFTER,
-	miS,
-	miSAFE,
-	miSE,
-	miSERVER,
-	miSET_COOKIE,
-	miSET_COOKIE1,
-	miSET_COOKIE2,
-	miT,
-	miTITLE,
-	miTRANSFER_ENCODING,
-	miU,
-	miUPGRADE,
-	miURI,
-	miV,
-	miVARY,
-	miVIA,
-	miW,
-	miWARNING,
-	miWWW_AUTHENTICATE,
-	miSKIP_GET_VALUE,	/* Skip space then get value */
-	miGET_VALUE,		/* Get value till white space */
-	miJUNK_LINE,		/* Ignore the rest of this folded line */
-	miNEWLINE,		/* Just found a LF .. maybe continuation */
-	miCHECK,		/* check against check_pointer */
-	MIME_NET_ASCII,		/* Translate from net ascii */
-	MIME_IGNORE		/* Ignore entire file */
-	/* TRANSPARENT and IGNORE are defined as stg else in _WINDOWS */
+    MIME_TRANSPARENT,		/* put straight through to target ASAP! */
+    miBEGINNING_OF_LINE,	/* first character and not a continuation */
+    miA,
+    miACCEPT_RANGES,
+    miAGE,
+    miAL,
+    miALLOW,
+    miALTERNATES,
+    miC,
+    miCACHE_CONTROL,
+    miCO,
+    miCOOKIE,
+    miCON,
+    miCONNECTION,
+    miCONTENT_,
+    miCONTENT_BASE,
+    miCONTENT_DISPOSITION,
+    miCONTENT_ENCODING,
+    miCONTENT_FEATURES,
+    miCONTENT_L,
+    miCONTENT_LANGUAGE,
+    miCONTENT_LENGTH,
+    miCONTENT_LOCATION,
+    miCONTENT_MD5,
+    miCONTENT_RANGE,
+    miCONTENT_T,
+    miCONTENT_TRANSFER_ENCODING,
+    miCONTENT_TYPE,
+    miDATE,
+    miE,
+    miETAG,
+    miEXPIRES,
+    miKEEP_ALIVE,
+    miL,
+    miLAST_MODIFIED,
+    miLINK,
+    miLOCATION,
+    miP,
+    miPR,
+    miPRAGMA,
+    miPROXY_AUTHENTICATE,
+    miPUBLIC,
+    miR,
+    miRE,
+    miREFRESH,
+    miRETRY_AFTER,
+    miS,
+    miSAFE,
+    miSE,
+    miSERVER,
+    miSET_COOKIE,
+    miSET_COOKIE1,
+    miSET_COOKIE2,
+    miT,
+    miTITLE,
+    miTRANSFER_ENCODING,
+    miU,
+    miUPGRADE,
+    miURI,
+    miV,
+    miVARY,
+    miVIA,
+    miW,
+    miWARNING,
+    miWWW_AUTHENTICATE,
+    miSKIP_GET_VALUE,		/* Skip space then get value */
+    miGET_VALUE,		/* Get value till white space */
+    miJUNK_LINE,		/* Ignore the rest of this folded line */
+    miNEWLINE,			/* Just found a LF .. maybe continuation */
+    miCHECK,			/* check against check_pointer */
+    MIME_NET_ASCII,		/* Translate from net ascii */
+    MIME_IGNORE			/* Ignore entire file */
+    /* TRANSPARENT and IGNORE are defined as stg else in _WINDOWS */
 } MIME_state;
 
 #define VALUE_SIZE 5120		/* @@@@@@@ Arbitrary? */
 struct _HTStream {
-	CONST HTStreamClass *	isa;
+    const HTStreamClass *isa;
 
-	BOOL			net_ascii;	/* Is input net ascii? */
-	MIME_state		state;		/* current state */
-	MIME_state		if_ok;		/* got this state if match */
-	MIME_state		field;		/* remember which field */
-	MIME_state		fold_state;	/* state on a fold */
-	BOOL			head_only;	/* only parsing header */
-	BOOL			pickup_redirection; /* parsing for location */
-	BOOL			no_streamstack; /* use sink directly */
-	CONST char *		check_pointer;	/* checking input */
-
-	char *			value_pointer;	/* storing values */
-	char			value[VALUE_SIZE];
-
-	HTParentAnchor *	anchor;		/* Given on creation */
-	HTStream *		sink;		/* Given on creation */
-
-	char *			boundary;	/* For multipart */
-	char *			set_cookie;	/* Set-Cookie */
-	char *			set_cookie2;	/* Set-Cookie2 */
-	char *			location;	/* Location */
-
-	char *			refresh_url;	/* "Refresh:" URL */
-
-	HTFormat		encoding;	/* Content-Transfer-Encoding */
-	char *			compression_encoding;
-	HTFormat		format;		/* Content-Type */
-	HTStream *		target;		/* While writing out */
-	HTStreamClass		targetClass;
+    BOOL net_ascii;		/* Is input net ascii? */
+    MIME_state state;		/* current state */
+    MIME_state if_ok;		/* got this state if match */
+    MIME_state field;		/* remember which field */
+    MIME_state fold_state;	/* state on a fold */
+    BOOL head_only;		/* only parsing header */
+    BOOL pickup_redirection;	/* parsing for location */
+    BOOL no_streamstack;	/* use sink directly */
+    const char *check_pointer;	/* checking input */
+
+    char *value_pointer;	/* storing values */
+    char value[VALUE_SIZE];
+
+    HTParentAnchor *anchor;	/* Given on creation */
+    HTStream *sink;		/* Given on creation */
+
+    char *boundary;		/* For multipart */
+    char *set_cookie;		/* Set-Cookie */
+    char *set_cookie2;		/* Set-Cookie2 */
+    char *location;		/* Location */
+
+    char *refresh_url;		/* "Refresh:" URL */
+
+    HTFormat encoding;		/* Content-Transfer-Encoding */
+    char *compression_encoding;
+    HTFormat format;		/* Content-Type */
+    HTStream *target;		/* While writing out */
+    HTStreamClass targetClass;
 
-	HTAtom *		targetRep;	/* Converting into? */
+    HTAtom *targetRep;		/* Converting into? */
 };
 
 /*
-**  This function is for trimming off any paired
-**  open- and close-double quotes from header values.
-**  It does not parse the string for embedded quotes,
-**  and will not modify the string unless both the
-**  first and last characters are double-quotes. - FM
-*/
-PUBLIC void HTMIME_TrimDoubleQuotes ARGS1(
-	char *,		value)
+ *  This function is for trimming off any paired
+ *  open- and close-double quotes from header values.
+ *  It does not parse the string for embedded quotes,
+ *  and will not modify the string unless both the
+ *  first and last characters are double-quotes. - FM
+ */
+void HTMIME_TrimDoubleQuotes(char *value)
 {
     int i;
     char *cp = value;
 
-    if (!(cp && *cp) || *cp != '\"')
+    if (!(cp && *cp) || *cp != '"')
 	return;
 
     i = strlen(cp);
-    if (cp[(i - 1)] != '\"')
+    if (cp[(i - 1)] != '"')
 	return;
     else
 	cp[(i - 1)] = '\0';
 
     for (i = 0; value[i]; i++)
-	value[i] = cp[(i +1)];
+	value[i] = cp[(i + 1)];
 }
 
-PRIVATE BOOL content_is_compressed ARGS1(HTStream *, me)
+/*
+ * Check if the token from "Content-Encoding" corresponds to a compression
+ * type.
+ */
+static BOOL content_is_compressed(HTStream *me)
 {
     char *encoding = me->anchor->content_encoding;
+    BOOL result = (HTEncodingToCompressType(encoding) != cftNone);
 
-    return encoding != 0
-        && strcmp(encoding, "8bit") != 0
-	&& strcmp(encoding, "7bit") != 0
-	&& strcmp(encoding, "binary") != 0;
+    CTRACE((tfp, "content is%s compressed\n", result ? "" : " NOT"));
+    return result;
 }
 
 /*
  * Strip quotes from a refresh-URL.
  */
-PRIVATE void dequote ARGS1(char *, url)
+static void dequote(char *url)
 {
     int len;
 
     len = strlen(url);
-    if (*url == '\'' && len > 1 && url[len-1] == url[0]) {
-	url[len-1] = '\0';
+    if (*url == '\'' && len > 1 && url[len - 1] == url[0]) {
+	url[len - 1] = '\0';
 	while ((url[0] = url[1]) != '\0') {
 	    ++url;
 	}
     }
 }
 
-PRIVATE int pumpData ARGS1(HTStream *, me)
+static int pumpData(HTStream *me)
 {
     if (strchr(HTAtom_name(me->format), ';') != NULL) {
 	char *cp = NULL, *cp1, *cp2, *cp3 = NULL, *cp4;
@@ -204,28 +207,28 @@
 		HTAtom_name(me->format)));
 	StrAllocCopy(cp, HTAtom_name(me->format));
 	/*
-	** Note that the Content-Type value was converted
-	** to lower case when we loaded into me->format,
-	** but there may have been a mixed or upper-case
-	** atom, so we'll force lower-casing again.  We
-	** also stripped spaces and double-quotes, but
-	** we'll make sure they're still gone from any
-	** charset parameter we check.  - FM
-	*/
+	 * Note that the Content-Type value was converted
+	 * to lower case when we loaded into me->format,
+	 * but there may have been a mixed or upper-case
+	 * atom, so we'll force lower-casing again.  We
+	 * also stripped spaces and double-quotes, but
+	 * we'll make sure they're still gone from any
+	 * charset parameter we check.  - FM
+	 */
 	LYLowerCase(cp);
 	if ((cp1 = strchr(cp, ';')) != NULL) {
 	    BOOL chartrans_ok = NO;
+
 	    if ((cp2 = strstr(cp1, "charset")) != NULL) {
 		int chndl;
 
 		cp2 += 7;
-		while (*cp2 == ' ' || *cp2 == '=' || *cp2 == '\"')
+		while (*cp2 == ' ' || *cp2 == '=' || *cp2 == '"')
 		    cp2++;
-		StrAllocCopy(cp3, cp2); /* copy to mutilate more */
-		for (cp4 = cp3; (*cp4 != '\0' && *cp4 != '\"' &&
-				 *cp4 != ';'  && *cp4 != ':' &&
-				 !WHITE(*cp4));	cp4++)
-		    ; /* do nothing */
+		StrAllocCopy(cp3, cp2);		/* copy to mutilate more */
+		for (cp4 = cp3; (*cp4 != '\0' && *cp4 != '"' &&
+				 *cp4 != ';' && *cp4 != ':' &&
+				 !WHITE(*cp4)); cp4++) ;	/* do nothing */
 		*cp4 = '\0';
 		cp4 = cp3;
 		chndl = UCGetLYhndl_byMIME(cp3);
@@ -238,17 +241,15 @@
 		    HTAnchor_setUCInfoStage(me->anchor, chndl,
 					    UCT_STAGE_MIME,
 					    UCT_SETBY_MIME);
-		}
-		else if (chndl < 0) {/* got something but we don't
-					recognize it */
+		} else if (chndl < 0) {		/* got something but we don't
+						   recognize it */
 		    chndl = UCLYhndl_for_unrec;
 		    if (chndl < 0)
 			/*
-			**  UCLYhndl_for_unrec not defined :-(
-			**  fallback to UCLYhndl_for_unspec
-			**  which always valid.
-			*/
-			chndl = UCLYhndl_for_unspec;  /* always >= 0 */
+			 * UCLYhndl_for_unrec not defined :-( fallback to
+			 * UCLYhndl_for_unspec which always valid.
+			 */
+			chndl = UCLYhndl_for_unspec;	/* always >= 0 */
 		    if (UCCanTranslateFromTo(chndl,
 					     current_char_set)) {
 			chartrans_ok = YES;
@@ -258,20 +259,32 @@
 						UCT_STAGE_MIME,
 						UCT_SETBY_DEFAULT);
 		    }
+		} else {
+		    /*
+		     * Something like 'big5' - we cannot translate it, but
+		     * the user may still be able to navigate the links.
+		     */
+		    *cp1 = '\0';
+		    me->format = HTAtom_for(cp);
+		    StrAllocCopy(me->anchor->charset, cp4);
+		    HTAnchor_setUCInfoStage(me->anchor, chndl,
+					    UCT_STAGE_MIME,
+					    UCT_SETBY_MIME);
 		}
 		if (chartrans_ok) {
-		    LYUCcharset * p_in =
-			HTAnchor_getUCInfoStage(me->anchor,
-						UCT_STAGE_MIME);
-		    LYUCcharset * p_out =
-			HTAnchor_setUCInfoStage(me->anchor,
-						current_char_set,
-						UCT_STAGE_HTEXT,
-						UCT_SETBY_DEFAULT);
+		    LYUCcharset *p_in =
+		    HTAnchor_getUCInfoStage(me->anchor,
+					    UCT_STAGE_MIME);
+		    LYUCcharset *p_out =
+		    HTAnchor_setUCInfoStage(me->anchor,
+					    current_char_set,
+					    UCT_STAGE_HTEXT,
+					    UCT_SETBY_DEFAULT);
+
 		    if (!p_out)
 			/*
-			**	Try again.
-			*/
+			 * Try again.
+			 */
 			p_out =
 			    HTAnchor_getUCInfoStage(me->anchor,
 						    UCT_STAGE_HTEXT);
@@ -294,7 +307,12 @@
 						UCT_STAGE_HTEXT,
 						UCT_SETBY_DEFAULT);
 		    }
-		    if (p_in->enc != UCT_ENC_CJK) {
+		    if ((p_in->enc != UCT_ENC_CJK)
+#ifndef EXP_JAPANESEUTF8_SUPPORT
+			&& ((p_in->enc != UCT_ENC_UTF8)
+			    || (p_out->enc != UCT_ENC_CJK))
+#endif
+			) {
 			HTCJK = NOCJK;
 			if (!(p_in->codepoints &
 			      UCT_CP_SUBSETOF_LAT1) &&
@@ -306,27 +324,25 @@
 		    }
 		} else {
 		    /*
-		    **  Cannot translate.
-		    **  If according to some heuristic the given
-		    **  charset and the current display character
-		    **  both are likely to be like ISO-8859 in
-		    **  structure, pretend we have some kind
-		    **  of match.
-		    */
-		    BOOL given_is_8859
-			= (BOOL) (!strncmp(cp4, "iso-8859-", 9) &&
-				  isdigit(UCH(cp4[9])));
-		    BOOL given_is_8859like
-			= (BOOL) (given_is_8859 ||
-				  !strncmp(cp4, "windows-", 8) ||
-				  !strncmp(cp4, "cp12", 4) ||
-				  !strncmp(cp4, "cp-12", 5));
-		    BOOL given_and_display_8859like
-			= (BOOL) (given_is_8859like &&
-				  (strstr(LYchar_set_names[current_char_set],
-					  "ISO-8859") ||
-				   strstr(LYchar_set_names[current_char_set],
-					  "windows-")));
+		     * Cannot translate.  If according to some heuristic the
+		     * given charset and the current display character both are
+		     * likely to be like ISO-8859 in structure, pretend we have
+		     * some kind of match.
+		     */
+		    BOOL given_is_8859 =
+		    (BOOL) (!strncmp(cp4, "iso-8859-", 9) &&
+			    isdigit(UCH(cp4[9])));
+		    BOOL given_is_8859like =
+		    (BOOL) (given_is_8859 ||
+			    !strncmp(cp4, "windows-", 8) ||
+			    !strncmp(cp4, "cp12", 4) ||
+			    !strncmp(cp4, "cp-12", 5));
+		    BOOL given_and_display_8859like =
+		    (BOOL) (given_is_8859like &&
+			    (strstr(LYchar_set_names[current_char_set],
+				    "ISO-8859") ||
+			     strstr(LYchar_set_names[current_char_set],
+				    "windows-")));
 
 		    if (given_and_display_8859like) {
 			*cp1 = '\0';
@@ -348,10 +364,9 @@
 		FREE(cp3);
 	    } else {
 		/*
-		**	No charset parameter is present.
-		**	Ignore all other parameters, as
-		**	we do when charset is present. - FM
-		*/
+		 * No charset parameter is present.  Ignore all other
+		 * parameters, as we do when charset is present.  - FM
+		 */
 		*cp1 = '\0';
 		me->format = HTAtom_for(cp);
 	    }
@@ -359,34 +374,32 @@
 	FREE(cp);
     }
     /*
-    **  If we have an Expires header and haven't
-    **  already set the no_cache element for the
-    **  anchor, check if we should set it based
-    **  on that header. - FM
-    */
+     * If we have an Expires header and haven't already set the no_cache
+     * element for the anchor, check if we should set it based on that header. 
+     * - FM
+     */
     if (me->anchor->no_cache == FALSE &&
 	me->anchor->expires != NULL) {
 	if (!strcmp(me->anchor->expires, "0")) {
 	    /*
-	     *  The value is zero, which we treat as
-	     *  an absolute no-cache directive. - FM
+	     * The value is zero, which we treat as an absolute no-cache
+	     * directive.  - FM
 	     */
 	    me->anchor->no_cache = TRUE;
 	} else if (me->anchor->date != NULL) {
 	    /*
-	    **  We have a Date header, so check if
-	    **  the value is less than or equal to
-	    **  that. - FM
-	    */
+	     * We have a Date header, so check if the value is less than or
+	     * equal to that.  - FM
+	     */
 	    if (LYmktime(me->anchor->expires, TRUE) <=
 		LYmktime(me->anchor->date, TRUE)) {
 		me->anchor->no_cache = TRUE;
 	    }
 	} else if (LYmktime(me->anchor->expires, FALSE) == 0) {
 	    /*
-	    **  We don't have a Date header, and
-	    **  the value is in past for us. - FM
-	    */
+	     * We don't have a Date header, and the value is in past for us.  -
+	     * FM
+	     */
 	    me->anchor->no_cache = TRUE;
 	}
     }
@@ -431,13 +444,14 @@
 	me->target = me->sink;
     } else {
 	if (!me->compression_encoding) {
-	    CTRACE((tfp, "HTMIME: MIME Content-Type is '%s', converting to '%s'\n",
+	    CTRACE((tfp,
+		    "HTMIME: MIME Content-Type is '%s', converting to '%s'\n",
 		    HTAtom_name(me->format), HTAtom_name(me->targetRep)));
 	} else {
 	    /*
-	    **	Change the format to that for "www/compressed"
-	    **	and set up a stream to deal with it. - FM
-	    */
+	     * Change the format to that for "www/compressed" and set up a
+	     * stream to deal with it.  - FM
+	     */
 	    CTRACE((tfp, "HTMIME: MIME Content-Type is '%s',\n", HTAtom_name(me->format)));
 	    me->format = HTAtom_for("www/compressed");
 	    CTRACE((tfp, "        Treating as '%s'.  Converting to '%s'\n",
@@ -445,7 +459,7 @@
 	    FREE(me->compression_encoding);
 	}
 	me->target = HTStreamStack(me->format, me->targetRep,
-				   me->sink , me->anchor);
+				   me->sink, me->anchor);
 	if (!me->target) {
 	    CTRACE((tfp, "HTMIME: Can't translate! ** \n"));
 	    me->target = me->sink;	/* Cheat */
@@ -454,10 +468,9 @@
     if (me->target) {
 	me->targetClass = *me->target->isa;
 	/*
-	**	Check for encoding and select state from there,
-	**	someday, but until we have the relevant code,
-	**	from now push straight through. - FM
-	*/
+	 * Check for encoding and select state from there, someday, but until
+	 * we have the relevant code, from now push straight through.  - FM
+	 */
 	me->state = MIME_TRANSPARENT;	/* Pump rest of data right through */
     } else {
 	me->state = MIME_IGNORE;	/* What else to do? */
@@ -466,7 +479,7 @@
 	char *url = NULL;
 	char *num = NULL;
 	char *txt = NULL;
-	char *base = "";	/* FIXME: refresh_url may be relative to doc */
+	const char *base = "";	/* FIXME: refresh_url may be relative to doc */
 
 	LYParseRefreshURL(me->refresh_url, &num, &url);
 	if (url != NULL && me->format == WWW_HTML) {
@@ -476,7 +489,7 @@
 	    dequote(url);
 	    HTSprintf(&txt, "<a href=\"%s%s\">%s</a><br>", base, url, url);
 	    CTRACE((tfp, "URL %s%s\n", base, url));
-	    (me->isa->put_string)(me, txt);
+	    (me->isa->put_string) (me, txt);
 	    free(txt);
 	}
 	FREE(num);
@@ -485,17 +498,18 @@
     return HT_OK;
 }
 
-PRIVATE int dispatchField ARGS1(HTStream *, me)
+static int dispatchField(HTStream *me)
 {
     int i, j;
     char *cp;
 
     *me->value_pointer = '\0';
+
     cp = me->value_pointer;
-    while ((cp > me->value) && *(--cp) == ' ')  /* S/390 -- gil -- 0146 */
+    while ((cp > me->value) && *(--cp) == ' ')	/* S/390 -- gil -- 0146 */
 	/*
-	**  Trim trailing spaces.
-	*/
+	 * Trim trailing spaces.
+	 */
 	*cp = '\0';
 
     switch (me->field) {
@@ -526,13 +540,13 @@
 	if (!(me->value && *me->value))
 	    break;
 	/*
-	**  Convert to lowercase and indicate in anchor. - FM
-	*/
+	 * Convert to lowercase and indicate in anchor.  - FM
+	 */
 	LYLowerCase(me->value);
 	StrAllocCopy(me->anchor->cache_control, me->value);
 	/*
-	**  Check whether to set no_cache for the anchor. - FM
-	*/
+	 * Check whether to set no_cache for the anchor.  - FM
+	 */
 	{
 	    char *cp1, *cp0 = me->value;
 
@@ -588,8 +602,8 @@
 	if (!(me->value && *me->value))
 	    break;
 	/*
-	**  Indicate in anchor. - FM
-	*/
+	 * Indicate in anchor.  - FM
+	 */
 	StrAllocCopy(me->anchor->content_base, me->value);
 	break;
     case miCONTENT_DISPOSITION:
@@ -599,17 +613,16 @@
 	if (!(me->value && *me->value))
 	    break;
 	/*
-	**  Indicate in anchor. - FM
-	*/
+	 * Indicate in anchor.  - FM
+	 */
 	StrAllocCopy(me->anchor->content_disposition, me->value);
 	/*
-	**  It's not clear yet from existing RFCs and IDs
-	**  whether we should be looking for file;, attachment;,
-	**  and/or inline; before the filename=value, so we'll
-	**  just search for "filename" followed by '=' and just
-	**  hope we get the intended value.  It is purely a
-	**  suggested name, anyway. - FM
-	*/
+	 * It's not clear yet from existing RFCs and IDs whether we should be
+	 * looking for file;, attachment;, and/or inline; before the
+	 * filename=value, so we'll just search for "filename" followed by '='
+	 * and just hope we get the intended value.  It is purely a suggested
+	 * name, anyway.  - FM
+	 */
 	cp = me->anchor->content_disposition;
 	while (*cp != '\0' && strncasecomp(cp, "filename", 8))
 	    cp++;
@@ -625,9 +638,9 @@
 	if (*cp == '\0')
 	    break;
 	StrAllocCopy(me->anchor->SugFname, cp);
-	if (*me->anchor->SugFname == '\"') {
+	if (*me->anchor->SugFname == '"') {
 	    if ((cp = strchr((me->anchor->SugFname + 1),
-			     '\"')) != NULL) {
+			     '"')) != NULL) {
 		*(cp + 1) = '\0';
 		HTMIME_TrimDoubleQuotes(me->anchor->SugFname);
 	    } else {
@@ -650,22 +663,22 @@
 	    !strcasecomp(me->value, "identity"))
 	    break;
 	/*
-	**  Convert to lowercase and indicate in anchor. - FM
-	*/
+	 * Convert to lowercase and indicate in anchor.  - FM
+	 */
 	LYLowerCase(me->value);
 	StrAllocCopy(me->anchor->content_encoding, me->value);
 	FREE(me->compression_encoding);
 	if (content_is_compressed(me)) {
 	    /*
-	    **	Save it to use as a flag for setting
-	    **	up a "www/compressed" target. - FM
-	    */
+	     * Save it to use as a flag for setting up a "www/compressed"
+	     * target.  - FM
+	     */
 	    StrAllocCopy(me->compression_encoding, me->value);
 	} else {
 	    /*
-	    **	Some server indicated "8bit", "7bit" or "binary"
-	    **	inappropriately.  We'll ignore it. - FM
-	    */
+	     * Some server indicated "8bit", "7bit" or "binary"
+	     * inappropriately.  We'll ignore it.  - FM
+	     */
 	    CTRACE((tfp, "                Ignoring it!\n"));
 	}
 	break;
@@ -681,8 +694,8 @@
 	if (!(me->value && *me->value))
 	    break;
 	/*
-	**  Convert to lowercase and indicate in anchor. - FM
-	*/
+	 * Convert to lowercase and indicate in anchor.  - FM
+	 */
 	LYLowerCase(me->value);
 	StrAllocCopy(me->anchor->content_language, me->value);
 	break;
@@ -693,8 +706,8 @@
 	if (!(me->value && *me->value))
 	    break;
 	/*
-	**  Convert to integer and indicate in anchor. - FM
-	*/
+	 * Convert to integer and indicate in anchor.  - FM
+	 */
 	me->anchor->content_length = atoi(me->value);
 	if (me->anchor->content_length < 0)
 	    me->anchor->content_length = 0;
@@ -708,8 +721,8 @@
 	if (!(me->value && *me->value))
 	    break;
 	/*
-	**  Indicate in anchor. - FM
-	*/
+	 * Indicate in anchor.  - FM
+	 */
 	StrAllocCopy(me->anchor->content_location, me->value);
 	break;
     case miCONTENT_MD5:
@@ -719,8 +732,8 @@
 	if (!(me->value && *me->value))
 	    break;
 	/*
-	**  Indicate in anchor. - FM
-	*/
+	 * Indicate in anchor.  - FM
+	 */
 	StrAllocCopy(me->anchor->content_md5, me->value);
 	break;
     case miCONTENT_RANGE:
@@ -735,9 +748,8 @@
 	if (!(me->value && *me->value))
 	    break;
 	/*
-	**  Force the Content-Transfer-Encoding value
-	**  to all lower case. - FM
-	*/
+	 * Force the Content-Transfer-Encoding value to all lower case.  - FM
+	 */
 	LYLowerCase(me->value);
 	me->encoding = HTAtom_for(me->value);
 	break;
@@ -748,16 +760,17 @@
 	if (!(me->value && *me->value))
 	    break;
 	/*
-	**  Force the Content-Type value to all lower case
-	**  and strip spaces and double-quotes. - FM
-	*/
+	 * Force the Content-Type value to all lower case and strip spaces and
+	 * double-quotes.  - FM
+	 */
 	for (i = 0, j = 0; me->value[i]; i++) {
-	    if (me->value[i] != ' ' && me->value[i] != '\"') {
+	    if (me->value[i] != ' ' && me->value[i] != '"') {
 		me->value[j++] = (char) TOLOWER(me->value[i]);
 	    }
 	}
 	me->value[j] = '\0';
 	me->format = HTAtom_for(me->value);
+	StrAllocCopy(me->anchor->content_type_params, me->value);
 	break;
     case miDATE:
 	HTMIME_TrimDoubleQuotes(me->value);
@@ -766,22 +779,21 @@
 	if (!(me->value && *me->value))
 	    break;
 	/*
-	**  Indicate in anchor. - FM
-	*/
+	 * Indicate in anchor.  - FM
+	 */
 	StrAllocCopy(me->anchor->date, me->value);
 	break;
     case miETAG:
-	/*  Do not trim double quotes:
-	 *  an entity tag consists of an opaque quoted string,
-	 *  possibly prefixed by a weakness indicator.
+	/* Do not trim double quotes:  an entity tag consists of an opaque
+	 * quoted string, possibly prefixed by a weakness indicator.
 	 */
 	CTRACE((tfp, "HTMIME: PICKED UP ETag: %s\n",
 		me->value));
 	if (!(me->value && *me->value))
 	    break;
 	/*
-	**  Indicate in anchor. - FM
-	*/
+	 * Indicate in anchor.  - FM
+	 */
 	StrAllocCopy(me->anchor->ETag, me->value);
 	break;
     case miEXPIRES:
@@ -791,8 +803,8 @@
 	if (!(me->value && *me->value))
 	    break;
 	/*
-	**  Indicate in anchor. - FM
-	*/
+	 * Indicate in anchor.  - FM
+	 */
 	StrAllocCopy(me->anchor->expires, me->value);
 	break;
     case miKEEP_ALIVE:
@@ -807,8 +819,8 @@
 	if (!(me->value && *me->value))
 	    break;
 	/*
-	**  Indicate in anchor. - FM
-	*/
+	 * Indicate in anchor.  - FM
+	 */
 	StrAllocCopy(me->anchor->last_modified, me->value);
 	break;
     case miLINK:
@@ -833,8 +845,8 @@
 	if (!(me->value && *me->value))
 	    break;
 	/*
-	**  Check whether to set no_cache for the anchor. - FM
-	*/
+	 * Check whether to set no_cache for the anchor.  - FM
+	 */
 	if (!strcmp(me->value, "no-cache"))
 	    me->anchor->no_cache = TRUE;
 	break;
@@ -866,17 +878,17 @@
 	if (!(me->value && *me->value))
 	    break;
 	/*
-	**  Indicate in anchor if "YES" or "TRUE". - FM
-	*/
+	 * Indicate in anchor if "YES" or "TRUE".  - FM
+	 */
 	if (!strcasecomp(me->value, "YES") ||
 	    !strcasecomp(me->value, "TRUE")) {
 	    me->anchor->safe = TRUE;
 	} else if (!strcasecomp(me->value, "NO") ||
 		   !strcasecomp(me->value, "FALSE")) {
 	    /*
-	    **  If server explicitly tells us that it has changed
-	    **  its mind, reset flag in anchor. - kw
-	    */
+	     * If server explicitly tells us that it has changed its mind,
+	     * reset flag in anchor.  - kw
+	     */
 	    me->anchor->safe = FALSE;
 	}
 	break;
@@ -887,8 +899,8 @@
 	if (!(me->value && *me->value))
 	    break;
 	/*
-	**  Indicate in anchor. - FM
-	*/
+	 * Indicate in anchor.  - FM
+	 */
 	StrAllocCopy(me->anchor->server, me->value);
 	break;
     case miSET_COOKIE1:
@@ -953,49 +965,48 @@
 	CTRACE((tfp, "HTMIME: PICKED UP WWW-Authenticate: '%s'\n",
 		me->value));
 	break;
-    default:		/* Should never get here */
+    default:			/* Should never get here */
 	return HT_ERROR;
     }
     return HT_OK;
 }
 
-
 /*_________________________________________________________________________
-**
-**			A C T I O N	R O U T I N E S
-*/
+ *
+ *			A C T I O N	R O U T I N E S
+ */
 
 /*	Character handling
-**	------------------
-**
-**	This is a FSM parser. It ignores field names it does not understand.
-**	Folded header fields are recognized.  Lines without a fieldname at
-**	the beginning (that are not folded continuation lines) are ignored
-**	as unknown field names.  Fields with empty values are not picked up.
-*/
-PRIVATE void HTMIME_put_character ARGS2(
-	HTStream *,	me,
-	char,		c)
+ *	------------------
+ *
+ *	This is a FSM parser. It ignores field names it does not understand.
+ *	Folded header fields are recognized.  Lines without a fieldname at
+ *	the beginning (that are not folded continuation lines) are ignored
+ *	as unknown field names.  Fields with empty values are not picked up.
+ */
+static void HTMIME_put_character(HTStream *me,
+				 char c)
 {
     if (me->state == MIME_TRANSPARENT) {
-	(*me->targetClass.put_character)(me->target, c);/* MUST BE FAST */
+	(*me->targetClass.put_character) (me->target, c);	/* MUST BE FAST */
 	return;
     }
 
     /*
-    **	This slightly simple conversion just strips CR and turns LF to
-    **	newline.  On unix LF is \n but on Mac \n is CR for example.
-    **	See NetToText for an implementation which preserves single CR or LF.
-    */
+     * This slightly simple conversion just strips CR and turns LF to newline. 
+     * On unix LF is \n but on Mac \n is CR for example.  See NetToText for an
+     * implementation which preserves single CR or LF.
+     */
     if (me->net_ascii) {
 	/*
-	** <sigh> This is evidence that at one time, this code supported
-	** local character sets other than ASCII.  But there is so much
-	** code in HTTP.c that depends on line_buffer's having been
-	** translated to local character set that I needed to put the
-	** FROMASCII translation there, leaving this translation purely
-	** destructive.  -- gil
-	*/  /* S/390 -- gil -- 0118 */
+	 * <sigh> This is evidence that at one time, this code supported
+	 * local character sets other than ASCII.  But there is so much
+	 * code in HTTP.c that depends on line_buffer's having been
+	 * translated to local character set that I needed to put the
+	 * FROMASCII translation there, leaving this translation purely
+	 * destructive.  -- gil
+	 */
+	/* S/390 -- gil -- 0118 */
 #ifndef   NOT_ASCII
 	c = FROMASCII(c);
 #endif /* NOT_ASCII */
@@ -1005,25 +1016,25 @@
 	    c = '\n';
     }
 
-    switch(me->state) {
+    switch (me->state) {
 
     case MIME_IGNORE:
 	return;
 
-    case MIME_TRANSPARENT:		/* Not reached see above */
-	(*me->targetClass.put_character)(me->target, c);
+    case MIME_TRANSPARENT:	/* Not reached see above */
+	(*me->targetClass.put_character) (me->target, c);
 	return;
 
     case MIME_NET_ASCII:
-	(*me->targetClass.put_character)(me->target, c); /* MUST BE FAST */
+	(*me->targetClass.put_character) (me->target, c);	/* MUST BE FAST */
 	return;
 
     case miNEWLINE:
-	if (c != '\n' && WHITE(c)) {		/* Folded line */
-	    me->state = me->fold_state; /* pop state before newline */
+	if (c != '\n' && WHITE(c)) {	/* Folded line */
+	    me->state = me->fold_state;		/* pop state before newline */
 	    if (me->state == miGET_VALUE &&
 		me->value_pointer && me->value_pointer != me->value &&
-		!WHITE(*(me->value_pointer-1))) {
+		!WHITE(*(me->value_pointer - 1))) {
 		c = ' ';
 		goto GET_VALUE;	/* will add space to value if it fits - kw */
 	    }
@@ -1055,7 +1066,8 @@
 	    me->check_pointer = "ate:";
 	    me->if_ok = miDATE;
 	    me->state = miCHECK;
-	    CTRACE((tfp, "HTMIME: Got 'D' at beginning of line, checking for 'ate:'\n"));
+	    CTRACE((tfp,
+		    "HTMIME: Got 'D' at beginning of line, checking for 'ate:'\n"));
 	    break;
 
 	case 'e':
@@ -1069,7 +1081,8 @@
 	    me->check_pointer = "eep-alive:";
 	    me->if_ok = miKEEP_ALIVE;
 	    me->state = miCHECK;
-	    CTRACE((tfp, "HTMIME: Got 'K' at beginning of line, checking for 'eep-alive:'\n"));
+	    CTRACE((tfp,
+		    "HTMIME: Got 'K' at beginning of line, checking for 'eep-alive:'\n"));
 	    break;
 
 	case 'l':
@@ -1120,7 +1133,7 @@
 	    CTRACE((tfp, "HTMIME: Got 'W' at beginning of line, state now W\n"));
 	    break;
 
-	case '\n':			/* Blank line: End of Header! */
+	case '\n':		/* Blank line: End of Header! */
 	    {
 		me->net_ascii = NO;
 		pumpData(me);
@@ -1128,19 +1141,20 @@
 	    break;
 
 	default:
-	   goto bad_field_name;
+	    goto bad_field_name;
 
-	} /* switch on character */
+	}			/* switch on character */
 	break;
 
-    case miA:				/* Check for 'c','g' or 'l' */
+    case miA:			/* Check for 'c','g' or 'l' */
 	switch (c) {
 	case 'c':
 	case 'C':
 	    me->check_pointer = "cept-ranges:";
 	    me->if_ok = miACCEPT_RANGES;
 	    me->state = miCHECK;
-	    CTRACE((tfp, "HTMIME: Was A, found C, checking for 'cept-ranges:'\n"));
+	    CTRACE((tfp,
+		    "HTMIME: Was A, found C, checking for 'cept-ranges:'\n"));
 	    break;
 
 	case 'g':
@@ -1158,14 +1172,15 @@
 	    break;
 
 	default:
-	    CTRACE((tfp, "HTMIME: Bad character `%c' found where `%s' expected\n",
-			c, "'g' or 'l'"));
+	    CTRACE((tfp,
+		    "HTMIME: Bad character `%c' found where `%s' expected\n",
+		    c, "'g' or 'l'"));
 	    goto bad_field_name;
 
-	} /* switch on character */
+	}			/* switch on character */
 	break;
 
-    case miAL:				/* Check for 'l' or 't' */
+    case miAL:			/* Check for 'l' or 't' */
 	switch (c) {
 	case 'l':
 	case 'L':
@@ -1184,21 +1199,23 @@
 	    break;
 
 	default:
-	    CTRACE((tfp, "HTMIME: Bad character `%c' found where `%s' expected\n",
-			c, "'l' or 't'"));
+	    CTRACE((tfp,
+		    "HTMIME: Bad character `%c' found where `%s' expected\n",
+		    c, "'l' or 't'"));
 	    goto bad_field_name;
 
-	} /* switch on character */
+	}			/* switch on character */
 	break;
 
-    case miC:				/* Check for 'a' or 'o' */
+    case miC:			/* Check for 'a' or 'o' */
 	switch (c) {
 	case 'a':
 	case 'A':
 	    me->check_pointer = "che-control:";
 	    me->if_ok = miCACHE_CONTROL;
 	    me->state = miCHECK;
-	    CTRACE((tfp, "HTMIME: Was C, found A, checking for 'che-control:'\n"));
+	    CTRACE((tfp,
+		    "HTMIME: Was C, found A, checking for 'che-control:'\n"));
 	    break;
 
 	case 'o':
@@ -1208,14 +1225,15 @@
 	    break;
 
 	default:
-	    CTRACE((tfp, "HTMIME: Bad character `%c' found where `%s' expected\n",
-			c, "'a' or 'o'"));
+	    CTRACE((tfp,
+		    "HTMIME: Bad character `%c' found where `%s' expected\n",
+		    c, "'a' or 'o'"));
 	    goto bad_field_name;
 
-	} /* switch on character */
+	}			/* switch on character */
 	break;
 
-    case miCO:				/* Check for 'n' or 'o' */
+    case miCO:			/* Check for 'n' or 'o' */
 	switch (c) {
 	case 'n':
 	case 'N':
@@ -1232,14 +1250,15 @@
 	    break;
 
 	default:
-	    CTRACE((tfp, "HTMIME: Bad character `%c' found where `%s' expected\n",
-			c, "'n' or 'o'"));
+	    CTRACE((tfp,
+		    "HTMIME: Bad character `%c' found where `%s' expected\n",
+		    c, "'n' or 'o'"));
 	    goto bad_field_name;
 
-	} /* switch on character */
+	}			/* switch on character */
 	break;
 
-    case miCON:				/* Check for 'n' or 't' */
+    case miCON:		/* Check for 'n' or 't' */
 	switch (c) {
 	case 'n':
 	case 'N':
@@ -1258,14 +1277,15 @@
 	    break;
 
 	default:
-	    CTRACE((tfp, "HTMIME: Bad character `%c' found where `%s' expected\n",
-			c, "'n' or 't'"));
+	    CTRACE((tfp,
+		    "HTMIME: Bad character `%c' found where `%s' expected\n",
+		    c, "'n' or 't'"));
 	    goto bad_field_name;
 
-	} /* switch on character */
+	}			/* switch on character */
 	break;
 
-    case miE:				/* Check for 't' or 'x' */
+    case miE:			/* Check for 't' or 'x' */
 	switch (c) {
 	case 't':
 	case 'T':
@@ -1284,21 +1304,23 @@
 	    break;
 
 	default:
-	    CTRACE((tfp, "HTMIME: Bad character `%c' found where `%s' expected\n",
-			c, "'t' or 'x'"));
+	    CTRACE((tfp,
+		    "HTMIME: Bad character `%c' found where `%s' expected\n",
+		    c, "'t' or 'x'"));
 	    goto bad_field_name;
 
-	} /* switch on character */
+	}			/* switch on character */
 	break;
 
-    case miL:				/* Check for 'a', 'i' or 'o' */
+    case miL:			/* Check for 'a', 'i' or 'o' */
 	switch (c) {
 	case 'a':
 	case 'A':
 	    me->check_pointer = "st-modified:";
 	    me->if_ok = miLAST_MODIFIED;
 	    me->state = miCHECK;
-	    CTRACE((tfp, "HTMIME: Was L, found A, checking for 'st-modified:'\n"));
+	    CTRACE((tfp,
+		    "HTMIME: Was L, found A, checking for 'st-modified:'\n"));
 	    break;
 
 	case 'i':
@@ -1318,14 +1340,15 @@
 	    break;
 
 	default:
-	    CTRACE((tfp, "HTMIME: Bad character `%c' found where `%s' expected\n",
-			c, "'a', 'i' or 'o'"));
+	    CTRACE((tfp,
+		    "HTMIME: Bad character `%c' found where `%s' expected\n",
+		    c, "'a', 'i' or 'o'"));
 	    goto bad_field_name;
 
-	} /* switch on character */
+	}			/* switch on character */
 	break;
 
-    case miP:				/* Check for 'r' or 'u' */
+    case miP:			/* Check for 'r' or 'u' */
 	switch (c) {
 	case 'r':
 	case 'R':
@@ -1342,14 +1365,15 @@
 	    break;
 
 	default:
-	    CTRACE((tfp, "HTMIME: Bad character `%c' found where `%s' expected\n",
-			c, "'r' or 'u'"));
+	    CTRACE((tfp,
+		    "HTMIME: Bad character `%c' found where `%s' expected\n",
+		    c, "'r' or 'u'"));
 	    goto bad_field_name;
 
-	} /* switch on character */
+	}			/* switch on character */
 	break;
 
-    case miPR:				/* Check for 'a' or 'o' */
+    case miPR:			/* Check for 'a' or 'o' */
 	switch (c) {
 	case 'a':
 	case 'A':
@@ -1364,18 +1388,20 @@
 	    me->check_pointer = "xy-authenticate:";
 	    me->if_ok = miPROXY_AUTHENTICATE;
 	    me->state = miCHECK;
-	    CTRACE((tfp, "HTMIME: Was PR, found O, checking for 'xy-authenticate'\n"));
+	    CTRACE((tfp,
+		    "HTMIME: Was PR, found O, checking for 'xy-authenticate'\n"));
 	    break;
 
 	default:
-	    CTRACE((tfp, "HTMIME: Bad character `%c' found where `%s' expected\n",
-			c, "'a' or 'o'"));
+	    CTRACE((tfp,
+		    "HTMIME: Bad character `%c' found where `%s' expected\n",
+		    c, "'a' or 'o'"));
 	    goto bad_field_name;
 
-	} /* switch on character */
+	}			/* switch on character */
 	break;
 
-    case miR:				/* Check for 'e' */
+    case miR:			/* Check for 'e' */
 	switch (c) {
 	case 'e':
 	case 'E':
@@ -1383,17 +1409,18 @@
 	    CTRACE((tfp, "HTMIME: Was R, found E\n"));
 	    break;
 	default:
-	    CTRACE((tfp, "HTMIME: Bad character `%c' found where `%s' expected\n",
-			c, "'e'"));
+	    CTRACE((tfp,
+		    "HTMIME: Bad character `%c' found where `%s' expected\n",
+		    c, "'e'"));
 	    goto bad_field_name;
 
-	} /* switch on character */
+	}			/* switch on character */
 	break;
 
-    case miRE:				/* Check for 'a' or 'o' */
+    case miRE:			/* Check for 'a' or 'o' */
 	switch (c) {
 	case 'f':
-	case 'F':			/* nonstandard: Netscape */
+	case 'F':		/* nonstandard: Netscape */
 	    me->check_pointer = "resh:";
 	    me->if_ok = miREFRESH;
 	    me->state = miCHECK;
@@ -1409,14 +1436,15 @@
 	    break;
 
 	default:
-	    CTRACE((tfp, "HTMIME: Bad character `%c' found where `%s' expected\n",
-			c, "'f' or 't'"));
+	    CTRACE((tfp,
+		    "HTMIME: Bad character `%c' found where `%s' expected\n",
+		    c, "'f' or 't'"));
 	    goto bad_field_name;
 
-	} /* switch on character */
+	}			/* switch on character */
 	break;
 
-    case miS:				/* Check for 'a' or 'e' */
+    case miS:			/* Check for 'a' or 'e' */
 	switch (c) {
 	case 'a':
 	case 'A':
@@ -1433,14 +1461,15 @@
 	    break;
 
 	default:
-	    CTRACE((tfp, "HTMIME: Bad character `%c' found where `%s' expected\n",
-			c, "'a' or 'e'"));
+	    CTRACE((tfp,
+		    "HTMIME: Bad character `%c' found where `%s' expected\n",
+		    c, "'a' or 'e'"));
 	    goto bad_field_name;
 
-	} /* switch on character */
+	}			/* switch on character */
 	break;
 
-    case miSE:				/* Check for 'r' or 't' */
+    case miSE:			/* Check for 'r' or 't' */
 	switch (c) {
 	case 'r':
 	case 'R':
@@ -1459,17 +1488,18 @@
 	    break;
 
 	default:
-	    CTRACE((tfp, "HTMIME: Bad character `%c' found where `%s' expected\n",
-			c, "'r' or 't'"));
+	    CTRACE((tfp,
+		    "HTMIME: Bad character `%c' found where `%s' expected\n",
+		    c, "'r' or 't'"));
 	    goto bad_field_name;
 
-	} /* switch on character */
+	}			/* switch on character */
 	break;
 
-    case miSET_COOKIE:			/* Check for ':' or '2' */
+    case miSET_COOKIE:		/* Check for ':' or '2' */
 	switch (c) {
 	case ':':
-	    me->field = miSET_COOKIE1;		/* remember it */
+	    me->field = miSET_COOKIE1;	/* remember it */
 	    me->state = miSKIP_GET_VALUE;
 	    CTRACE((tfp, "HTMIME: Was SET_COOKIE, found :, processing\n"));
 	    break;
@@ -1482,14 +1512,15 @@
 	    break;
 
 	default:
-	    CTRACE((tfp, "HTMIME: Bad character `%c' found where `%s' expected\n",
-			c, "':' or '2'"));
+	    CTRACE((tfp,
+		    "HTMIME: Bad character `%c' found where `%s' expected\n",
+		    c, "':' or '2'"));
 	    goto bad_field_name;
 
-	} /* switch on character */
+	}			/* switch on character */
 	break;
 
-    case miT:				/* Check for 'i' or 'r' */
+    case miT:			/* Check for 'i' or 'r' */
 	switch (c) {
 	case 'i':
 	case 'I':
@@ -1504,18 +1535,20 @@
 	    me->check_pointer = "ansfer-encoding:";
 	    me->if_ok = miTRANSFER_ENCODING;
 	    me->state = miCHECK;
-	    CTRACE((tfp, "HTMIME: Was T, found R, checking for 'ansfer-encoding'\n"));
+	    CTRACE((tfp,
+		    "HTMIME: Was T, found R, checking for 'ansfer-encoding'\n"));
 	    break;
 
 	default:
-	    CTRACE((tfp, "HTMIME: Bad character `%c' found where `%s' expected\n",
-			c, "'i' or 'r'"));
+	    CTRACE((tfp,
+		    "HTMIME: Bad character `%c' found where `%s' expected\n",
+		    c, "'i' or 'r'"));
 	    goto bad_field_name;
 
-	} /* switch on character */
+	}			/* switch on character */
 	break;
 
-    case miU:				/* Check for 'p' or 'r' */
+    case miU:			/* Check for 'p' or 'r' */
 	switch (c) {
 	case 'p':
 	case 'P':
@@ -1534,14 +1567,15 @@
 	    break;
 
 	default:
-	    CTRACE((tfp, "HTMIME: Bad character `%c' found where `%s' expected\n",
-			c, "'p' or 'r'"));
+	    CTRACE((tfp,
+		    "HTMIME: Bad character `%c' found where `%s' expected\n",
+		    c, "'p' or 'r'"));
 	    goto bad_field_name;
 
-	} /* switch on character */
+	}			/* switch on character */
 	break;
 
-    case miV:				/* Check for 'a' or 'i' */
+    case miV:			/* Check for 'a' or 'i' */
 	switch (c) {
 	case 'a':
 	case 'A':
@@ -1560,14 +1594,15 @@
 	    break;
 
 	default:
-	    CTRACE((tfp, "HTMIME: Bad character `%c' found where `%s' expected\n",
-			c, "'a' or 'i'"));
+	    CTRACE((tfp,
+		    "HTMIME: Bad character `%c' found where `%s' expected\n",
+		    c, "'a' or 'i'"));
 	    goto bad_field_name;
 
-	} /* switch on character */
+	}			/* switch on character */
 	break;
 
-    case miW:				/* Check for 'a' or 'w' */
+    case miW:			/* Check for 'a' or 'w' */
 	switch (c) {
 	case 'a':
 	case 'A':
@@ -1582,24 +1617,27 @@
 	    me->check_pointer = "w-authenticate:";
 	    me->if_ok = miWWW_AUTHENTICATE;
 	    me->state = miCHECK;
-	    CTRACE((tfp, "HTMIME: Was W, found W, checking for 'w-authenticate:'\n"));
+	    CTRACE((tfp,
+		    "HTMIME: Was W, found W, checking for 'w-authenticate:'\n"));
 	    break;
 
 	default:
-	    CTRACE((tfp, "HTMIME: Bad character `%c' found where `%s' expected\n",
-			c, "'a' or 'w'"));
+	    CTRACE((tfp,
+		    "HTMIME: Bad character `%c' found where `%s' expected\n",
+		    c, "'a' or 'w'"));
 	    goto bad_field_name;
 
-	} /* switch on character */
+	}			/* switch on character */
 	break;
 
-    case miCHECK:			/* Check against string */
+    case miCHECK:		/* Check against string */
 	if (TOLOWER(c) == *(me->check_pointer)++) {
 	    if (!*me->check_pointer)
 		me->state = me->if_ok;
 	} else {		/* Error */
-	    CTRACE((tfp, "HTMIME: Bad character `%c' found where `%s' expected\n",
-			c, me->check_pointer - 1));
+	    CTRACE((tfp,
+		    "HTMIME: Bad character `%c' found where `%s' expected\n",
+		    c, me->check_pointer - 1));
 	    goto bad_field_name;
 	}
 	break;
@@ -1607,13 +1645,14 @@
     case miCONTENT_:
 	CTRACE((tfp, "HTMIME: in case CONTENT_\n"));
 
-	switch(c) {
+	switch (c) {
 	case 'b':
 	case 'B':
 	    me->check_pointer = "ase:";
 	    me->if_ok = miCONTENT_BASE;
 	    me->state = miCHECK;
-	    CTRACE((tfp, "HTMIME: Was CONTENT_, found B, checking for 'ase:'\n"));
+	    CTRACE((tfp,
+		    "HTMIME: Was CONTENT_, found B, checking for 'ase:'\n"));
 	    break;
 
 	case 'd':
@@ -1621,7 +1660,8 @@
 	    me->check_pointer = "isposition:";
 	    me->if_ok = miCONTENT_DISPOSITION;
 	    me->state = miCHECK;
-	    CTRACE((tfp, "HTMIME: Was CONTENT_, found D, checking for 'isposition:'\n"));
+	    CTRACE((tfp,
+		    "HTMIME: Was CONTENT_, found D, checking for 'isposition:'\n"));
 	    break;
 
 	case 'e':
@@ -1629,7 +1669,8 @@
 	    me->check_pointer = "ncoding:";
 	    me->if_ok = miCONTENT_ENCODING;
 	    me->state = miCHECK;
-	    CTRACE((tfp, "HTMIME: Was CONTENT_, found E, checking for 'ncoding:'\n"));
+	    CTRACE((tfp,
+		    "HTMIME: Was CONTENT_, found E, checking for 'ncoding:'\n"));
 	    break;
 
 	case 'f':
@@ -1637,13 +1678,15 @@
 	    me->check_pointer = "eatures:";
 	    me->if_ok = miCONTENT_FEATURES;
 	    me->state = miCHECK;
-	    CTRACE((tfp, "HTMIME: Was CONTENT_, found F, checking for 'eatures:'\n"));
+	    CTRACE((tfp,
+		    "HTMIME: Was CONTENT_, found F, checking for 'eatures:'\n"));
 	    break;
 
 	case 'l':
 	case 'L':
 	    me->state = miCONTENT_L;
-	    CTRACE((tfp, "HTMIME: Was CONTENT_, found L, state now CONTENT_L\n"));
+	    CTRACE((tfp,
+		    "HTMIME: Was CONTENT_, found L, state now CONTENT_L\n"));
 	    break;
 
 	case 'm':
@@ -1659,32 +1702,35 @@
 	    me->check_pointer = "ange:";
 	    me->if_ok = miCONTENT_RANGE;
 	    me->state = miCHECK;
-	    CTRACE((tfp, "HTMIME: Was CONTENT_, found R, checking for 'ange:'\n"));
+	    CTRACE((tfp,
+		    "HTMIME: Was CONTENT_, found R, checking for 'ange:'\n"));
 	    break;
 
 	case 't':
 	case 'T':
 	    me->state = miCONTENT_T;
-	    CTRACE((tfp, "HTMIME: Was CONTENT_, found T, state now CONTENT_T\n"));
+	    CTRACE((tfp,
+		    "HTMIME: Was CONTENT_, found T, state now CONTENT_T\n"));
 	    break;
 
 	default:
 	    CTRACE((tfp, "HTMIME: Was CONTENT_, found nothing; bleah\n"));
 	    goto bad_field_name;
 
-	} /* switch on character */
+	}			/* switch on character */
 	break;
 
     case miCONTENT_L:
 	CTRACE((tfp, "HTMIME: in case CONTENT_L\n"));
 
-      switch(c) {
+	switch (c) {
 	case 'a':
 	case 'A':
 	    me->check_pointer = "nguage:";
 	    me->if_ok = miCONTENT_LANGUAGE;
 	    me->state = miCHECK;
-	    CTRACE((tfp, "HTMIME: Was CONTENT_L, found A, checking for 'nguage:'\n"));
+	    CTRACE((tfp,
+		    "HTMIME: Was CONTENT_L, found A, checking for 'nguage:'\n"));
 	    break;
 
 	case 'e':
@@ -1692,7 +1738,8 @@
 	    me->check_pointer = "ngth:";
 	    me->if_ok = miCONTENT_LENGTH;
 	    me->state = miCHECK;
-	    CTRACE((tfp, "HTMIME: Was CONTENT_L, found E, checking for 'ngth:'\n"));
+	    CTRACE((tfp,
+		    "HTMIME: Was CONTENT_L, found E, checking for 'ngth:'\n"));
 	    break;
 
 	case 'o':
@@ -1700,26 +1747,28 @@
 	    me->check_pointer = "cation:";
 	    me->if_ok = miCONTENT_LOCATION;
 	    me->state = miCHECK;
-	    CTRACE((tfp, "HTMIME: Was CONTENT_L, found O, checking for 'cation:'\n"));
+	    CTRACE((tfp,
+		    "HTMIME: Was CONTENT_L, found O, checking for 'cation:'\n"));
 	    break;
 
 	default:
 	    CTRACE((tfp, "HTMIME: Was CONTENT_L, found nothing; bleah\n"));
 	    goto bad_field_name;
 
-	} /* switch on character */
+	}			/* switch on character */
 	break;
 
     case miCONTENT_T:
 	CTRACE((tfp, "HTMIME: in case CONTENT_T\n"));
 
-      switch(c) {
+	switch (c) {
 	case 'r':
 	case 'R':
 	    me->check_pointer = "ansfer-encoding:";
 	    me->if_ok = miCONTENT_TRANSFER_ENCODING;
 	    me->state = miCHECK;
-	    CTRACE((tfp, "HTMIME: Was CONTENT_T, found R, checking for 'ansfer-encoding:'\n"));
+	    CTRACE((tfp,
+		    "HTMIME: Was CONTENT_T, found R, checking for 'ansfer-encoding:'\n"));
 	    break;
 
 	case 'y':
@@ -1727,14 +1776,15 @@
 	    me->check_pointer = "pe:";
 	    me->if_ok = miCONTENT_TYPE;
 	    me->state = miCHECK;
-	    CTRACE((tfp, "HTMIME: Was CONTENT_T, found Y, checking for 'pe:'\n"));
+	    CTRACE((tfp,
+		    "HTMIME: Was CONTENT_T, found Y, checking for 'pe:'\n"));
 	    break;
 
 	default:
 	    CTRACE((tfp, "HTMIME: Was CONTENT_T, found nothing; bleah\n"));
 	    goto bad_field_name;
 
-	} /* switch on character */
+	}			/* switch on character */
 	break;
 
     case miACCEPT_RANGES:
@@ -1779,7 +1829,7 @@
     case miVIA:
     case miWARNING:
     case miWWW_AUTHENTICATE:
-	me->field = me->state;		/* remember it */
+	me->field = me->state;	/* remember it */
 	me->state = miSKIP_GET_VALUE;
 	/* Fall through! */
 
@@ -1791,8 +1841,8 @@
 	}
 	if (WHITE(c))
 	    /*
-	    **	Skip white space.
-	    */
+	     * Skip white space.
+	     */
 	    break;
 
 	me->value_pointer = me->value;
@@ -1800,8 +1850,8 @@
 	/* Fall through to store first character */
 
     case miGET_VALUE:
-    GET_VALUE:
-	if (c != '\n') {			/* Not end of line */
+      GET_VALUE:
+	if (c != '\n') {	/* Not end of line */
 	    if (me->value_pointer < me->value + VALUE_SIZE - 1) {
 		*me->value_pointer++ = c;
 		break;
@@ -1818,134 +1868,144 @@
 	}
 	break;
 
+    }				/* switch on state */
 
-    } /* switch on state*/
-
+#ifdef EXP_HTTP_HEADERS
+    HTChunkPutc(&me->anchor->http_headers, c);
+    if (me->state == MIME_TRANSPARENT) {
+	HTChunkTerminate(&me->anchor->http_headers);
+	CTRACE((tfp, "Server Headers:\n%.*s\n",
+		me->anchor->http_headers.size,
+		me->anchor->http_headers.data));
+	CTRACE((tfp, "Server Content-Type:%s\n",
+		me->anchor->content_type_params));
+    }
+#endif
     return;
 
-value_too_long:
+  value_too_long:
     CTRACE((tfp, "HTMIME: *** Syntax error. (string too long)\n"));
 
-bad_field_name:				/* Ignore it */
+  bad_field_name:		/* Ignore it */
     me->state = miJUNK_LINE;
-    return;
 
-}
+#ifdef EXP_HTTP_HEADERS
+    HTChunkPutc(&me->anchor->http_headers, c);
+#endif
 
+    return;
 
+}
 
 /*	String handling
-**	---------------
-**
-**	Strings must be smaller than this buffer size.
-*/
-PRIVATE void HTMIME_put_string ARGS2(
-	HTStream *,	me,
-	CONST char *,	s)
+ *	---------------
+ *
+ *	Strings must be smaller than this buffer size.
+ */
+static void HTMIME_put_string(HTStream *me,
+			      const char *s)
 {
-    CONST char * p;
+    const char *p;
 
     if (me->state == MIME_TRANSPARENT) {	/* Optimisation */
-	(*me->targetClass.put_string)(me->target,s);
+	(*me->targetClass.put_string) (me->target, s);
 
     } else if (me->state != MIME_IGNORE) {
 	CTRACE((tfp, "HTMIME:  %s\n", s));
 
-	for (p=s; *p; p++)
+	for (p = s; *p; p++)
 	    HTMIME_put_character(me, *p);
     }
 }
 
-
 /*	Buffer write.  Buffers can (and should!) be big.
-**	------------
-*/
-PRIVATE void HTMIME_write ARGS3(
-	HTStream *,	me,
-	CONST char *,	s,
-	int,		l)
+ *	------------
+ */
+static void HTMIME_write(HTStream *me,
+			 const char *s,
+			 int l)
 {
-    CONST char * p;
+    const char *p;
 
     if (me->state == MIME_TRANSPARENT) {	/* Optimisation */
-	(*me->targetClass.put_block)(me->target, s, l);
+	(*me->targetClass.put_block) (me->target, s, l);
 
     } else {
 	CTRACE((tfp, "HTMIME:  %.*s\n", l, s));
 
-	for (p = s; p < s+l; p++)
+	for (p = s; p < s + l; p++)
 	    HTMIME_put_character(me, *p);
     }
 }
 
-
 /*	Free an HTML object
-**	-------------------
-**
-*/
-PRIVATE void HTMIME_free ARGS1(
-	HTStream *,	me)
+ *	-------------------
+ *
+ */
+static void HTMIME_free(HTStream *me)
 {
     if (me) {
 	FREE(me->location);
 	FREE(me->compression_encoding);
 	if (me->target)
-	    (*me->targetClass._free)(me->target);
+	    (*me->targetClass._free) (me->target);
 	FREE(me);
     }
 }
 
 /*	End writing
 */
-PRIVATE void HTMIME_abort ARGS2(
-	HTStream *,	me,
-	HTError,	e)
+static void HTMIME_abort(HTStream *me,
+			 HTError e)
 {
     if (me) {
 	FREE(me->location);
 	FREE(me->compression_encoding);
 	if (me->target)
-	    (*me->targetClass._abort)(me->target, e);
+	    (*me->targetClass._abort) (me->target, e);
 	FREE(me);
     }
 }
 
-
 /*	Structured Object Class
-**	-----------------------
-*/
-PRIVATE CONST HTStreamClass HTMIME =
+ *	-----------------------
+ */
+static const HTStreamClass HTMIME =
 {
-	"MIMEParser",
-	HTMIME_free,
-	HTMIME_abort,
-	HTMIME_put_character,
-	HTMIME_put_string,
-	HTMIME_write
+    "MIMEParser",
+    HTMIME_free,
+    HTMIME_abort,
+    HTMIME_put_character,
+    HTMIME_put_string,
+    HTMIME_write
 };
 
-
 /*	Subclass-specific Methods
-**	-------------------------
-*/
-PUBLIC HTStream* HTMIMEConvert ARGS3(
-	HTPresentation *,	pres,
-	HTParentAnchor *,	anchor,
-	HTStream *,		sink)
+ *	-------------------------
+ */
+HTStream *HTMIMEConvert(HTPresentation *pres,
+			HTParentAnchor *anchor,
+			HTStream *sink)
 {
-    HTStream* me;
+    HTStream *me;
 
     me = typecalloc(HTStream);
+
     if (me == NULL)
 	outofmem(__FILE__, "HTMIMEConvert");
-    me->isa	=	&HTMIME;
-    me->sink	=	sink;
-    me->anchor	=	anchor;
+    me->isa = &HTMIME;
+    me->sink = sink;
+    me->anchor = anchor;
     me->anchor->safe = FALSE;
     me->anchor->no_cache = FALSE;
     FREE(me->anchor->cache_control);
     FREE(me->anchor->SugFname);
     FREE(me->anchor->charset);
+#ifdef EXP_HTTP_HEADERS
+    HTChunkClear(&me->anchor->http_headers);
+    HTChunkInit(&me->anchor->http_headers, 128);
+#endif
+    FREE(me->anchor->content_type_params);
     FREE(me->anchor->content_language);
     FREE(me->anchor->content_encoding);
     FREE(me->anchor->content_base);
@@ -1958,37 +2018,37 @@
     FREE(me->anchor->last_modified);
     FREE(me->anchor->ETag);
     FREE(me->anchor->server);
-    me->target	=	NULL;
-    me->state	=	miBEGINNING_OF_LINE;
+    me->target = NULL;
+    me->state = miBEGINNING_OF_LINE;
     /*
-     *	Sadly enough, change this to always default to WWW_HTML
-     *	to parse all text as HTML for the users.
-     *	GAB 06-30-94
-     *	Thanks to Robert Rowland robert@cyclops.pei.edu
+     * Sadly enough, change this to always default to WWW_HTML to parse all
+     * text as HTML for the users.
+     * GAB 06-30-94
+     * Thanks to Robert Rowland robert@cyclops.pei.edu
      *
-     *	After discussion of the correct handline, should be application/octet-
-     *		stream or unknown; causing servers to send a correct content
-     *		type.
+     * After discussion of the correct handline, should be application/octet-
+     * stream or unknown; causing servers to send a correct content type.
      *
-     *	The consequence of using WWW_UNKNOWN is that you end up downloading
-     *	as a binary file what 99.9% of the time is an HTML file, which should
-     *	have been rendered or displayed.  So sadly enough, I'm changing it
-     *	back to WWW_HTML, and it will handle the situation like Mosaic does,
-     *	and as Robert Rowland suggested, because being functionally correct
-     *	99.9% of the time is better than being technically correct but
-     *	functionally nonsensical. - FM
-     *//***
+     * The consequence of using WWW_UNKNOWN is that you end up downloading as a
+     * binary file what 99.9% of the time is an HTML file, which should have
+     * been rendered or displayed.  So sadly enough, I'm changing it back to
+     * WWW_HTML, and it will handle the situation like Mosaic does, and as
+     * Robert Rowland suggested, because being functionally correct 99.9% of
+     * the time is better than being technically correct but functionally
+     * nonsensical.  - FM
+     */
+    /***
     me->format	  =	WWW_UNKNOWN;
-	***/
-    me->format	  =	WWW_HTML;
-    me->targetRep =	pres->rep_out;
-    me->boundary  =	NULL;		/* Not set yet */
-    me->set_cookie =	NULL;		/* Not set yet */
-    me->set_cookie2 =	NULL;		/* Not set yet */
-    me->refresh_url =	NULL;		/* Not set yet */
-    me->encoding  =	0;		/* Not set yet */
+    ***/
+    me->format = WWW_HTML;
+    me->targetRep = pres->rep_out;
+    me->boundary = NULL;	/* Not set yet */
+    me->set_cookie = NULL;	/* Not set yet */
+    me->set_cookie2 = NULL;	/* Not set yet */
+    me->refresh_url = NULL;	/* Not set yet */
+    me->encoding = 0;		/* Not set yet */
     me->compression_encoding = NULL;	/* Not set yet */
-    me->net_ascii =	NO;		/* Local character set */
+    me->net_ascii = NO;		/* Local character set */
     HTAnchor_setUCInfoStage(me->anchor, current_char_set,
 			    UCT_STAGE_STRUCTURED,
 			    UCT_SETBY_DEFAULT);
@@ -1998,12 +2058,12 @@
     return me;
 }
 
-PUBLIC HTStream* HTNetMIME ARGS3(
-	HTPresentation *,	pres,
-	HTParentAnchor *,	anchor,
-	HTStream *,		sink)
+HTStream *HTNetMIME(HTPresentation *pres,
+		    HTParentAnchor *anchor,
+		    HTStream *sink)
 {
-    HTStream* me = HTMIMEConvert(pres,anchor, sink);
+    HTStream *me = HTMIMEConvert(pres, anchor, sink);
+
     if (!me)
 	return NULL;
 
@@ -2011,12 +2071,12 @@
     return me;
 }
 
-PUBLIC HTStream* HTMIMERedirect ARGS3(
-	HTPresentation *,	pres,
-	HTParentAnchor *,	anchor,
-	HTStream *,		sink)
+HTStream *HTMIMERedirect(HTPresentation *pres,
+			 HTParentAnchor *anchor,
+			 HTStream *sink)
 {
-    HTStream* me = HTMIMEConvert(pres,anchor, sink);
+    HTStream *me = HTMIMEConvert(pres, anchor, sink);
+
     if (!me)
 	return NULL;
 
@@ -2027,62 +2087,61 @@
 }
 
 /*		Japanese header handling functions
-**		==================================
-**
-**	K&Rized and added 07-Jun-96 by FM, based on:
-**
+ *		==================================
+ *
+ *	K&Rized and added 07-Jun-96 by FM, based on:
+ *
 ////////////////////////////////////////////////////////////////////////
-**
-**	ISO-2022-JP handling routines
-**			&
-**	MIME decode routines (quick hack just for ISO-2022-JP)
-**
-**		Thu Jan 25 10:11:42 JST 1996
-**
-**  Copyright (C) 1994, 1995, 1996
-**  Shuichi Ichikawa (ichikawa@nuee.nagoya-u.ac.jp)
-**
-**  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 versions 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 SKK, see the file COPYING.  If not, write to the Free
-**  Software Foundation Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
+ *
+ *	ISO-2022-JP handling routines
+ *			&
+ *	MIME decode routines (quick hack just for ISO-2022-JP)
+ *
+ *		Thu Jan 25 10:11:42 JST 1996
+ *
+ *  Copyright (C) 1994, 1995, 1996
+ *  Shuichi Ichikawa (ichikawa@nuee.nagoya-u.ac.jp)
+ *
+ *  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 versions 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 SKK, see the file COPYING.  If not, write to the Free
+ *  Software Foundation Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
 
 /*
-**  MIME decoding routines
-**
-**	Written by S. Ichikawa,
-**	partially inspired by encdec.c of <jh@efd.lth.se>.
-**	Assume caller's buffer is LINE_LENGTH bytes, these decode to
-**	no longer than the input strings.
-*/
+ *  MIME decoding routines
+ *
+ *	Written by S. Ichikawa,
+ *	partially inspired by encdec.c of <jh@efd.lth.se>.
+ *	Assume caller's buffer is LINE_LENGTH bytes, these decode to
+ *	no longer than the input strings.
+ */
 #define LINE_LENGTH 512		/* Maximum length of line of ARTICLE etc */
 #ifdef ESC
 #undef ESC
 #endif /* ESC */
-#include <LYCharVals.h>  /* S/390 -- gil -- 0163 */
+#include <LYCharVals.h>		/* S/390 -- gil -- 0163 */
 #define ESC	CH_ESC
 
-PRIVATE char HTmm64[] =
-    "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=" ;
-PRIVATE char HTmmquote[] = "0123456789ABCDEF";
-PRIVATE int HTmmcont = 0;
-
-PUBLIC void HTmmdec_base64 ARGS2(
-	char *,		t,
-	char *,		s)
+static char HTmm64[] =
+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
+static char HTmmquote[] = "0123456789ABCDEF";
+static int HTmmcont = 0;
+
+void HTmmdec_base64(char *t,
+		    char *s)
 {
-    int   d, count, j, val;
-    char  buf[LINE_LENGTH], *bp, nw[4], *p;
+    int d, count, j, val;
+    char buf[LINE_LENGTH], *bp, nw[4], *p;
 
     for (bp = buf; *s; s += 4) {
 	val = 0;
@@ -2094,16 +2153,16 @@
 	    count = 3;
 
 	for (j = 0; j <= count; j++) {
-		if (!(p = strchr(HTmm64, s[j]))) {
-			return;
-		}
-		d = p - HTmm64;
-		d <<= (3-j)*6;
-		val += d;
+	    if (!(p = strchr(HTmm64, s[j]))) {
+		return;
+	    }
+	    d = p - HTmm64;
+	    d <<= (3 - j) * 6;
+	    val += d;
 	}
 	for (j = 2; j >= 0; j--) {
-		nw[j] = (char) (val & 255);
-		val >>= 8;
+	    nw[j] = (char) (val & 255);
+	    val >>= 8;
 	}
 	if (count--)
 	    *bp++ = nw[0];
@@ -2116,13 +2175,12 @@
     strcpy(t, buf);
 }
 
-PUBLIC void HTmmdec_quote ARGS2(
-	char *,		t,
-	char *,		s)
+void HTmmdec_quote(char *t,
+		   char *s)
 {
-    char  buf[LINE_LENGTH], cval, *bp, *p;
+    char buf[LINE_LENGTH], cval, *bp, *p;
 
-    for (bp = buf; *s; ) {
+    for (bp = buf; *s;) {
 	if (*s == '=') {
 	    cval = 0;
 	    if (s[1] && (p = strchr(HTmmquote, s[1]))) {
@@ -2151,19 +2209,18 @@
 }
 
 /*
-**	HTmmdecode for ISO-2022-JP - FM
-*/
-PUBLIC void HTmmdecode ARGS2(
-	char *,		trg,
-	char *,		str)
+ *	HTmmdecode for ISO-2022-JP - FM
+ */
+void HTmmdecode(char *trg,
+		char *str)
 {
     char buf[LINE_LENGTH], mmbuf[LINE_LENGTH];
     char *s, *t, *u;
-    int  base64, quote;
+    int base64, quote;
 
     buf[0] = '\0';
 
-    for (s = str, u = buf; *s; ) {
+    for (s = str, u = buf; *s;) {
 	if (!strncasecomp(s, "=?ISO-2022-JP?B?", 16)) {
 	    base64 = 1;
 	} else {
@@ -2177,11 +2234,11 @@
 	if (base64 || quote) {
 	    if (HTmmcont) {
 		for (t = s - 1;
-		    t >= str && (*t == ' ' || *t == '\t'); t--) {
-			u--;
+		     t >= str && (*t == ' ' || *t == '\t'); t--) {
+		    u--;
 		}
 	    }
-	    for (s += 16, t = mmbuf; *s; ) {
+	    for (s += 16, t = mmbuf; *s;) {
 		if (s[0] == '?' && s[1] == '=') {
 		    break;
 		} else {
@@ -2198,7 +2255,7 @@
 		HTmmdec_base64(mmbuf, mmbuf);
 	    if (quote)
 		HTmmdec_quote(mmbuf, mmbuf);
-	    for (t = mmbuf; *t; )
+	    for (t = mmbuf; *t;)
 		*u++ = *t++;
 	    HTmmcont = 1;
 	    /* if (*s == ' ' || *s == '\t') *u++ = *s; */
@@ -2210,17 +2267,16 @@
 	}
     }
     *u = '\0';
-end:
+  end:
     strcpy(trg, buf);
 }
 
 /*
-**  Insert ESC where it seems lost.
-**  (The author of this function "rjis" is S. Ichikawa.)
-*/
-PUBLIC int HTrjis ARGS2(
-	char *,		t,
-	char *,		s)
+ *  Insert ESC where it seems lost.
+ *  (The author of this function "rjis" is S. Ichikawa.)
+ */
+int HTrjis(char *t,
+	   char *s)
 {
     char *p, buf[LINE_LENGTH];
     int kanji = 0;
@@ -2230,9 +2286,9 @@
 	    strcpy(t, s);
 	return 1;
     }
-    for (p = buf; *s; ) {
+    for (p = buf; *s;) {
 	if (!kanji && s[0] == '$' && (s[1] == '@' || s[1] == 'B')) {
-	    if (HTmaybekanji((int)s[2], (int)s[3])) {
+	    if (HTmaybekanji((int) s[2], (int) s[3])) {
 		kanji = 1;
 		*p++ = ESC;
 		*p++ = *s++;
@@ -2253,18 +2309,18 @@
 	}
 	*p++ = *s++;
     }
-    *p = *s;	/* terminate string */
+    *p = *s;			/* terminate string */
 
     strcpy(t, buf);
     return 0;
 }
 
 /*
-**  The following function "maybekanji" is derived from
-**  RJIS-1.0 by Mr. Hironobu Takahashi.
-**  Maybekanji() is included here under the courtesy of the author.
-**  The original comment of rjis.c is also included here.
-*/
+ *  The following function "maybekanji" is derived from
+ *  RJIS-1.0 by Mr. Hironobu Takahashi.
+ *  Maybekanji() is included here under the courtesy of the author.
+ *  The original comment of rjis.c is also included here.
+ */
 /*
  * RJIS ( Recover JIS code from broken file )
  * $Header: rjis.c,v 0.2 92/09/04 takahasi Exp $
@@ -2286,9 +2342,8 @@
  * Software Foundation Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
-PUBLIC int HTmaybekanji ARGS2(
-	int,		c1,
-	int,		c2)
+int HTmaybekanji(int c1,
+		 int c2)
 {
 
     if ((c2 < 33) || (c2 > 126))
@@ -2296,58 +2351,58 @@
     if ((c1 < 33) || ((40 < c1) && (c1 < 48)) || (116 < c1))
 	return 0;
     c2 -= 32;
-    switch(c1-32) {
-      case 2:
-	if ((14 < c2) && ( c2 < 26))
+    switch (c1 - 32) {
+    case 2:
+	if ((14 < c2) && (c2 < 26))
 	    return 0;
-	if ((33 < c2) && ( c2 < 42))
+	if ((33 < c2) && (c2 < 42))
 	    return 0;
-	if ((48 < c2) && ( c2 < 60))
+	if ((48 < c2) && (c2 < 60))
 	    return 0;
-	if ((74 < c2) && ( c2 < 82))
+	if ((74 < c2) && (c2 < 82))
 	    return 0;
-	if ((89 < c2) && ( c2 < 94))
+	if ((89 < c2) && (c2 < 94))
 	    return 0;
 	break;
-      case 3:
+    case 3:
 	if (c2 < 16)
 	    return 0;
-	if ((25 < c2) && ( c2 < 33))
+	if ((25 < c2) && (c2 < 33))
 	    return 0;
-	if ((58 < c2) && ( c2 < 65))
+	if ((58 < c2) && (c2 < 65))
 	    return 0;
 	if (90 < c2)
 	    return 0;
 	break;
-      case 4:
+    case 4:
 	if (83 < c2)
 	    return 0;
 	break;
-      case 5:
+    case 5:
 	if (86 < c2)
 	    return 0;
 	break;
-      case 6:
-	if ((24 < c2) && ( c2 < 33))
+    case 6:
+	if ((24 < c2) && (c2 < 33))
 	    return 0;
 	if (56 < c2)
 	    return 0;
 	break;
-      case 7:
-	if ((33 < c2) && ( c2 < 49))
+    case 7:
+	if ((33 < c2) && (c2 < 49))
 	    return 0;
 	if (81 < c2)
 	    return 0;
 	break;
-      case 8:
+    case 8:
 	if (32 < c2)
 	    return 0;
 	break;
-      case 47:
+    case 47:
 	if (51 < c2)
 	    return 0;
 	break;
-      case 84:
+    case 84:
 	if (6 < c2)
 	    return 0;
 	break;
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/HTFormat.c
+++ lynx-cur-2.8.6/WWW/Library/Implementation/HTFormat.c
@@ -1,14 +1,14 @@
 /*		Manage different file formats			HTFormat.c
-**		=============================
-**
-** Bugs:
-**	Not reentrant.
-**
-**	Assumes the incoming stream is ASCII, rather than a local file
-**	format, and so ALWAYS converts from ASCII on non-ASCII machines.
-**	Therefore, non-ASCII machines can't read local files.
-**
-*/
+ *		=============================
+ *
+ * Bugs:
+ *	Not reentrant.
+ *
+ *	Assumes the incoming stream is ASCII, rather than a local file
+ *	format, and so ALWAYS converts from ASCII on non-ASCII machines.
+ *	Therefore, non-ASCII machines can't read local files.
+ *
+ */
 
 #include <HTUtils.h>
 
@@ -16,9 +16,7 @@
 */
 #include <HTFormat.h>
 
-PUBLIC float HTMaxSecs = 1e10;		/* No effective limit */
-PUBLIC float HTMaxLength = 1e10;	/* No effective limit */
-PUBLIC long int HTMaxBytes  = 0;	/* No effective limit */
+static float HTMaxSecs = 1e10;	/* No effective limit */
 
 #ifdef UNIX
 #ifdef NeXT
@@ -54,72 +52,80 @@
 #include <LYMainLoop.h>
 #endif
 
-PUBLIC	BOOL HTOutputSource = NO;	/* Flag: shortcut parser to stdout */
+BOOL HTOutputSource = NO;	/* Flag: shortcut parser to stdout */
 
 #ifdef ORIGINAL
 struct _HTStream {
-      CONST HTStreamClass*	isa;
-      /* ... */
+    const HTStreamClass *isa;
+    /* ... */
 };
 #endif /* ORIGINAL */
 
 /* this version used by the NetToText stream */
 struct _HTStream {
-	CONST HTStreamClass *	isa;
-	BOOL			had_cr;
-	HTStream *		sink;
+    const HTStreamClass *isa;
+    BOOL had_cr;
+    HTStream *sink;
 };
 
 /*	Presentation methods
-**	--------------------
-*/
-PUBLIC	HTList * HTPresentations = NULL;
-PUBLIC	HTPresentation * default_presentation = NULL;
+ *	--------------------
+ */
+HTList *HTPresentations = NULL;
+HTPresentation *default_presentation = NULL;
 
 /*
  *	To free off the presentation list.
  */
 #ifdef LY_FIND_LEAKS
-PRIVATE void HTFreePresentations NOPARAMS;
+static void HTFreePresentations(void);
 #endif
 
 /*	Define a presentation system command for a content-type
-**	-------------------------------------------------------
-*/
-PUBLIC void HTSetPresentation ARGS6(
-	CONST char *,	representation,
-	CONST char *,	command,
-	double,		quality,
-	double,		secs,
-	double,		secs_per_byte,
-	long int,	maxbytes)
+ *	-------------------------------------------------------
+ */
+void HTSetPresentation(const char *representation,
+		       const char *command,
+		       const char *testcommand,
+		       double quality,
+		       double secs,
+		       double secs_per_byte,
+		       long int maxbytes,
+		       AcceptMedia media)
 {
-    HTPresentation * pres = typecalloc(HTPresentation);
+    HTPresentation *pres = typecalloc(HTPresentation);
+
     if (pres == NULL)
 	outofmem(__FILE__, "HTSetPresentation");
 
     pres->rep = HTAtom_for(representation);
-    pres->rep_out = WWW_PRESENT;		/* Fixed for now ... :-) */
-    pres->converter = HTSaveAndExecute;		/* Fixed for now ...	 */
+    pres->rep_out = WWW_PRESENT;	/* Fixed for now ... :-) */
+    pres->converter = HTSaveAndExecute;		/* Fixed for now ...     */
     pres->quality = (float) quality;
     pres->secs = (float) secs;
     pres->secs_per_byte = (float) secs_per_byte;
     pres->maxbytes = maxbytes;
+    pres->get_accept = 0;
+    pres->accept_opt = media;
+
     pres->command = NULL;
     StrAllocCopy(pres->command, command);
 
+    pres->testcommand = NULL;
+    StrAllocCopy(pres->testcommand, testcommand);
+
     /*
-     *	Memory leak fixed.
-     *	05-28-94 Lynx 2-3-1 Garrett Arch Blythe
+     * Memory leak fixed.
+     * 05-28-94 Lynx 2-3-1 Garrett Arch Blythe
      */
-    if (!HTPresentations)	{
+    if (!HTPresentations) {
 	HTPresentations = HTList_new();
 #ifdef LY_FIND_LEAKS
 	atexit(HTFreePresentations);
 #endif
     }
 
-    if (strcmp(representation, "*")==0) {
+    if (strcmp(representation, "*") == 0) {
 	FREE(default_presentation);
 	default_presentation = pres;
     } else {
@@ -128,36 +134,39 @@
 }
 
 /*	Define a built-in function for a content-type
-**	---------------------------------------------
-*/
-PUBLIC void HTSetConversion ARGS7(
-	CONST char *,	representation_in,
-	CONST char *,	representation_out,
-	HTConverter*,	converter,
-	float,		quality,
-	float,		secs,
-	float,		secs_per_byte,
-	long int,	maxbytes)
+ *	---------------------------------------------
+ */
+void HTSetConversion(const char *representation_in,
+		     const char *representation_out,
+		     HTConverter *converter,
+		     float quality,
+		     float secs,
+		     float secs_per_byte,
+		     long int maxbytes,
+		     AcceptMedia media)
 {
-    HTPresentation * pres = typecalloc(HTPresentation);
+    HTPresentation *pres = typecalloc(HTPresentation);
+
     if (pres == NULL)
 	outofmem(__FILE__, "HTSetConversion");
 
     pres->rep = HTAtom_for(representation_in);
     pres->rep_out = HTAtom_for(representation_out);
     pres->converter = converter;
-    pres->command = NULL;		/* Fixed */
+    pres->command = NULL;
+    pres->testcommand = NULL;
     pres->quality = quality;
     pres->secs = secs;
     pres->secs_per_byte = secs_per_byte;
     pres->maxbytes = maxbytes;
-    pres->command = NULL;
+    pres->get_accept = TRUE;
+    pres->accept_opt = media;
 
     /*
-     *	Memory Leak fixed.
-     *	05-28-94 Lynx 2-3-1 Garrett Arch Blythe
+     * Memory Leak fixed.
+     * 05-28-94 Lynx 2-3-1 Garrett Arch Blythe
      */
-    if (!HTPresentations)	{
+    if (!HTPresentations) {
 	HTPresentations = HTList_new();
 #ifdef LY_FIND_LEAKS
 	atexit(HTFreePresentations);
@@ -169,33 +178,33 @@
 
 #ifdef LY_FIND_LEAKS
 /*
-**	Purpose:	Free the presentation list.
-**	Arguments:	void
-**	Return Value:	void
-**	Remarks/Portability/Dependencies/Restrictions:
-**		Made to clean up Lynx's bad leakage.
-**	Revision History:
-**		05-28-94	created Lynx 2-3-1 Garrett Arch Blythe
-*/
-PRIVATE void HTFreePresentations NOARGS
+ *	Purpose:	Free the presentation list.
+ *	Arguments:	void
+ *	Return Value:	void
+ *	Remarks/Portability/Dependencies/Restrictions:
+ *		Made to clean up Lynx's bad leakage.
+ *	Revision History:
+ *		05-28-94	created Lynx 2-3-1 Garrett Arch Blythe
+ */
+static void HTFreePresentations(void)
 {
-    HTPresentation * pres = NULL;
+    HTPresentation *pres = NULL;
 
     /*
-     *	Loop through the list.
+     * Loop through the list.
      */
     while (!HTList_isEmpty(HTPresentations)) {
 	/*
-	 *  Free off each item.
-	 *  May also need to free off it's items, but not sure
-	 *  as of yet.
+	 * Free off each item.  May also need to free off it's items, but not
+	 * sure as of yet.
 	 */
-	pres = (HTPresentation *)HTList_removeLastObject(HTPresentations);
+	pres = (HTPresentation *) HTList_removeLastObject(HTPresentations);
 	FREE(pres->command);
+	FREE(pres->testcommand);
 	FREE(pres);
     }
     /*
-     *	Free the list itself.
+     * Free the list itself.
      */
     HTList_delete(HTPresentations);
     HTPresentations = NULL;
@@ -203,40 +212,42 @@
 #endif /* LY_FIND_LEAKS */
 
 /*	File buffering
-**	--------------
-**
-**	The input file is read using the macro which can read from
-**	a socket or a file.
-**	The input buffer size, if large will give greater efficiency and
-**	release the server faster, and if small will save space on PCs etc.
-*/
-#define INPUT_BUFFER_SIZE 4096		/* Tradeoff */
-PRIVATE char input_buffer[INPUT_BUFFER_SIZE];
-PRIVATE char * input_pointer;
-PRIVATE char * input_limit;
-PRIVATE int input_file_number;
+ *	--------------
+ *
+ *	The input file is read using the macro which can read from
+ *	a socket or a file.
+ *	The input buffer size, if large will give greater efficiency and
+ *	release the server faster, and if small will save space on PCs etc.
+ */
+#define INPUT_BUFFER_SIZE 4096	/* Tradeoff */
+static char input_buffer[INPUT_BUFFER_SIZE];
+static char *input_pointer;
+static char *input_limit;
+static int input_file_number;
 
 /*	Set up the buffering
-**
-**	These routines are public because they are in fact needed by
-**	many parsers, and on PCs and Macs we should not duplicate
-**	the static buffer area.
-*/
-PUBLIC void HTInitInput ARGS1 (int,file_number)
+ *
+ *	These routines are public because they are in fact needed by
+ *	many parsers, and on PCs and Macs we should not duplicate
+ *	the static buffer area.
+ */
+void HTInitInput(int file_number)
 {
     input_file_number = file_number;
     input_pointer = input_limit = input_buffer;
 }
 
-PUBLIC int interrupted_in_htgetcharacter = 0;
-PUBLIC int HTGetCharacter NOARGS
+int interrupted_in_htgetcharacter = 0;
+int HTGetCharacter(void)
 {
     char ch;
+
     interrupted_in_htgetcharacter = 0;
     do {
 	if (input_pointer >= input_limit) {
 	    int status = NETREAD(input_file_number,
 				 input_buffer, INPUT_BUFFER_SIZE);
+
 	    if (status <= 0) {
 		if (status == 0)
 		    return EOF;
@@ -246,217 +257,250 @@
 		    return EOF;
 		}
 		CTRACE((tfp, "HTFormat: File read error %d\n", status));
-		return EOF; /* -1 is returned by UCX
-			       at end of HTTP link */
+		return EOF;	/* -1 is returned by UCX
+				   at end of HTTP link */
 	    }
 	    input_pointer = input_buffer;
 	    input_limit = input_buffer + status;
 	}
 	ch = *input_pointer++;
-    } while (ch == (char) 13); /* Ignore ASCII carriage return */
+    } while (ch == (char) 13);	/* Ignore ASCII carriage return */
 
     return FROMASCII(UCH(ch));
 }
 
 #ifdef USE_SSL
-PUBLIC char HTGetSSLCharacter ARGS1(void *, handle)
+char HTGetSSLCharacter(void *handle)
 {
     char ch;
+
     interrupted_in_htgetcharacter = 0;
-    if(!handle)
-	return (char)EOF;
+    if (!handle)
+	return (char) EOF;
     do {
 	if (input_pointer >= input_limit) {
-	    int status = SSL_read((SSL *)handle,
-				 input_buffer, INPUT_BUFFER_SIZE);
+	    int status = SSL_read((SSL *) handle,
+				  input_buffer, INPUT_BUFFER_SIZE);
+
 	    if (status <= 0) {
 		if (status == 0)
-		    return (char)EOF;
+		    return (char) EOF;
 		if (status == HT_INTERRUPTED) {
-		    CTRACE((tfp, "HTFormat: Interrupted in HTGetSSLCharacter\n"));
+		    CTRACE((tfp,
+			    "HTFormat: Interrupted in HTGetSSLCharacter\n"));
 		    interrupted_in_htgetcharacter = 1;
-		    return (char)EOF;
+		    return (char) EOF;
 		}
 		CTRACE((tfp, "HTFormat: SSL_read error %d\n", status));
-		return (char)EOF; /* -1 is returned by UCX
-				     at end of HTTP link */
+		return (char) EOF;	/* -1 is returned by UCX
+					   at end of HTTP link */
 	    }
 	    input_pointer = input_buffer;
 	    input_limit = input_buffer + status;
 	}
 	ch = *input_pointer++;
-    } while (ch == (char) 13); /* Ignore ASCII carriage return */
+    } while (ch == (char) 13);	/* Ignore ASCII carriage return */
 
     return FROMASCII(ch);
 }
 #endif /* USE_SSL */
 
-/*  Match maintype to any MIME type starting with maintype,
- *  for example:  image/gif should match image
+/* Match maintype to any MIME type starting with maintype, for example: 
+ * image/gif should match image
  */
-PRIVATE int half_match ARGS2(char *,trial_type, char *,target)
+static int half_match(char *trial_type, char *target)
 {
     char *cp = strchr(trial_type, '/');
 
     /* if no '/' or no '*' */
-    if (!cp || *(cp+1) != '*')
+    if (!cp || *(cp + 1) != '*')
 	return 0;
 
     CTRACE((tfp, "HTFormat: comparing %s and %s for half match\n",
-		trial_type, target));
+	    trial_type, target));
 
-	/* main type matches */
-    if (!strncmp(trial_type, target, (cp-trial_type)-1))
+    /* main type matches */
+    if (!strncmp(trial_type, target, (cp - trial_type) - 1))
 	return 1;
 
     return 0;
 }
 
+/*
+ * Evaluate a deferred mailcap test command, i.e.,. one that substitutes the
+ * document's charset or other values in %{name} format.
+ */
+static BOOL failsMailcap(HTPresentation *pres, HTParentAnchor *anchor)
+{
+    if (pres->testcommand != 0) {
+	if (LYTestMailcapCommand(pres->testcommand,
+				 anchor->content_type_params) != 0)
+	    return TRUE;
+    }
+    return FALSE;
+}
+
 #define WWW_WILDCARD_REP_OUT HTAtom_for("*")
 
 /*		Look up a presentation
-**		----------------------
-**
-**	If fill_in is NULL, only look for an exact match.
-**	If a wildcard match is made, *fill_in is used to store
-**	a possibly modified presentation, and a pointer to it is
-**	returned.  For an exact match, a pointer to the presentation
-**	in the HTPresentations list is returned.  Returns NULL if
-**	nothing found. - kw
-**
-*/
-PRIVATE HTPresentation * HTFindPresentation ARGS3(
-	HTFormat,		rep_in,
-	HTFormat,		rep_out,
-	HTPresentation*,	fill_in)
-{
-    HTAtom * wildcard = NULL; /* = HTAtom_for("*"); lookup when needed - kw */
+ *		----------------------
+ *
+ *	If fill_in is NULL, only look for an exact match.
+ *	If a wildcard match is made, *fill_in is used to store
+ *	a possibly modified presentation, and a pointer to it is
+ *	returned.  For an exact match, a pointer to the presentation
+ *	in the HTPresentations list is returned.  Returns NULL if
+ *	nothing found. - kw
+ *
+ */
+static HTPresentation *HTFindPresentation(HTFormat rep_in,
+					  HTFormat rep_out,
+					  HTPresentation *fill_in,
+					  HTParentAnchor *anchor)
+{
+    HTAtom *wildcard = NULL;	/* = HTAtom_for("*"); lookup when needed - kw */
+    int n;
+    int i;
+    HTPresentation *pres;
+    HTPresentation *match;
+    HTPresentation *strong_wildcard_match = 0;
+    HTPresentation *weak_wildcard_match = 0;
+    HTPresentation *last_default_match = 0;
+    HTPresentation *strong_subtype_wildcard_match = 0;
 
     CTRACE((tfp, "HTFormat: Looking up presentation for %s to %s\n",
-		HTAtom_name(rep_in), HTAtom_name(rep_out)));
-
-    /* don't do anymore do it in the Lynx code at startup LJM */
-    /* if (!HTPresentations) HTFormatInit(); */ /* set up the list */
-
-    {
-	int n = HTList_count(HTPresentations);
-	int i;
-	HTPresentation * pres, *match,
-			*strong_wildcard_match=0,
-			*weak_wildcard_match=0,
-			*last_default_match=0,
-			*strong_subtype_wildcard_match=0;
+	    HTAtom_name(rep_in), HTAtom_name(rep_out)));
 
-	for (i = 0; i < n; i++) {
-	    pres = (HTPresentation *)HTList_objectAt(HTPresentations, i);
-	    if (pres->rep == rep_in) {
-		if (pres->rep_out == rep_out) {
-		    CTRACE((tfp, "FindPresentation: found exact match: %s\n",
-				HTAtom_name(pres->rep)));
-		    return pres;
-
-		} else if (!fill_in) {
+    n = HTList_count(HTPresentations);
+    for (i = 0; i < n; i++) {
+	pres = (HTPresentation *) HTList_objectAt(HTPresentations, i);
+	if (pres->rep == rep_in) {
+	    if (pres->rep_out == rep_out) {
+		if (failsMailcap(pres, anchor))
 		    continue;
-		} else {
-		    if (!wildcard) wildcard = WWW_WILDCARD_REP_OUT;
-		    if (pres->rep_out == wildcard) {
-			if (!strong_wildcard_match)
-			    strong_wildcard_match = pres;
-			/* otherwise use the first one */
-			CTRACE((tfp, "StreamStack: found strong wildcard match: %s\n",
-				    HTAtom_name(pres->rep)));
-		    }
-		}
+		CTRACE((tfp, "FindPresentation: found exact match: %s\n",
+			HTAtom_name(pres->rep)));
+		return pres;
 
 	    } else if (!fill_in) {
 		continue;
-
-	    } else if (half_match(HTAtom_name(pres->rep),
-					      HTAtom_name(rep_in))) {
-		if (pres->rep_out == rep_out) {
-		    if (!strong_subtype_wildcard_match)
-			strong_subtype_wildcard_match = pres;
+	    } else {
+		if (!wildcard)
+		    wildcard = WWW_WILDCARD_REP_OUT;
+		if (pres->rep_out == wildcard) {
+		    if (failsMailcap(pres, anchor))
+			continue;
+		    if (!strong_wildcard_match)
+			strong_wildcard_match = pres;
 		    /* otherwise use the first one */
-		    CTRACE((tfp, "StreamStack: found strong subtype wildcard match: %s\n",
-				HTAtom_name(pres->rep)));
+		    CTRACE((tfp,
+			    "StreamStack: found strong wildcard match: %s\n",
+			    HTAtom_name(pres->rep)));
 		}
 	    }
 
-	    if (pres->rep == WWW_SOURCE) {
-		if (pres->rep_out == rep_out) {
-		    if (!weak_wildcard_match)
-			weak_wildcard_match = pres;
-		    /* otherwise use the first one */
-		    CTRACE((tfp, "StreamStack: found weak wildcard match: %s\n",
-				HTAtom_name(pres->rep_out)));
+	} else if (!fill_in) {
+	    continue;
+
+	} else if (half_match(HTAtom_name(pres->rep),
+			      HTAtom_name(rep_in))) {
+	    if (pres->rep_out == rep_out) {
+		if (failsMailcap(pres, anchor))
+		    continue;
+		if (!strong_subtype_wildcard_match)
+		    strong_subtype_wildcard_match = pres;
+		/* otherwise use the first one */
+		CTRACE((tfp,
+			"StreamStack: found strong subtype wildcard match: %s\n",
+			HTAtom_name(pres->rep)));
+	    }
+	}
 
-		} else if (!last_default_match) {
-		    if (!wildcard) wildcard = WWW_WILDCARD_REP_OUT;
-		    if (pres->rep_out == wildcard)
-			 last_default_match = pres;
+	if (pres->rep == WWW_SOURCE) {
+	    if (pres->rep_out == rep_out) {
+		if (failsMailcap(pres, anchor))
+		    continue;
+		if (!weak_wildcard_match)
+		    weak_wildcard_match = pres;
+		/* otherwise use the first one */
+		CTRACE((tfp,
+			"StreamStack: found weak wildcard match: %s\n",
+			HTAtom_name(pres->rep_out)));
+
+	    } else if (!last_default_match) {
+		if (!wildcard)
+		    wildcard = WWW_WILDCARD_REP_OUT;
+		if (pres->rep_out == wildcard) {
+		    if (failsMailcap(pres, anchor))
+			continue;
+		    last_default_match = pres;
 		    /* otherwise use the first one */
 		}
 	    }
 	}
+    }
 
-	match = strong_subtype_wildcard_match ? strong_subtype_wildcard_match :
-		strong_wildcard_match ? strong_wildcard_match :
-		weak_wildcard_match ? weak_wildcard_match :
-		last_default_match;
-
-	if (match) {
-	    *fill_in = *match;		/* Specific instance */
-	    fill_in->rep = rep_in;		/* yuk */
-	    fill_in->rep_out = rep_out; /* yuk */
-	    return fill_in;
-	}
+    match = (strong_subtype_wildcard_match
+	     ? strong_subtype_wildcard_match
+	     : (strong_wildcard_match
+		? strong_wildcard_match
+		: (weak_wildcard_match
+		   ? weak_wildcard_match
+		   : last_default_match)));
+
+    if (match) {
+	*fill_in = *match;	/* Specific instance */
+	fill_in->rep = rep_in;	/* yuk */
+	fill_in->rep_out = rep_out;	/* yuk */
+	return fill_in;
     }
 
     return NULL;
 }
 
 /*		Create a filter stack
-**		---------------------
-**
-**	If a wildcard match is made, a temporary HTPresentation
-**	structure is made to hold the destination format while the
-**	new stack is generated. This is just to pass the out format to
-**	MIME so far.  Storing the format of a stream in the stream might
-**	be a lot neater.
-**
-*/
-PUBLIC HTStream * HTStreamStack ARGS4(
-	HTFormat,		rep_in,
-	HTFormat,		rep_out,
-	HTStream*,		sink,
-	HTParentAnchor*,	anchor)
+ *		---------------------
+ *
+ *	If a wildcard match is made, a temporary HTPresentation
+ *	structure is made to hold the destination format while the
+ *	new stack is generated. This is just to pass the out format to
+ *	MIME so far.  Storing the format of a stream in the stream might
+ *	be a lot neater.
+ *
+ */
+HTStream *HTStreamStack(HTFormat rep_in,
+			HTFormat rep_out,
+			HTStream *sink,
+			HTParentAnchor *anchor)
 {
     HTPresentation temp;
     HTPresentation *match;
     HTStream *result;
 
-    CTRACE((tfp, "HTFormat: Constructing stream stack for %s to %s\n",
-		HTAtom_name(rep_in), HTAtom_name(rep_out)));
+    CTRACE((tfp, "HTFormat: Constructing stream stack for %s to %s (%s)\n",
+	    HTAtom_name(rep_in),
+	    HTAtom_name(rep_out),
+	    NONNULL(anchor->content_type_params)));
 
     /* don't return on WWW_SOURCE some people might like
      * to make use of the source!!!!  LJM
      */
 #if 0
     if (rep_out == WWW_SOURCE || rep_out == rep_in)
-	return sink;	/*  LJM */
+	return sink;		/*  LJM */
 #endif
 
     if (rep_out == rep_in) {
 	result = sink;
 
-    } else if ((match = HTFindPresentation(rep_in, rep_out, &temp))) {
+    } else if ((match = HTFindPresentation(rep_in, rep_out, &temp, anchor))) {
 	if (match == &temp) {
 	    CTRACE((tfp, "StreamStack: Using %s\n", HTAtom_name(temp.rep_out)));
 	} else {
 	    CTRACE((tfp, "StreamStack: found exact match: %s\n",
-			HTAtom_name(match->rep)));
+		    HTAtom_name(match->rep)));
 	}
-	result = (*match->converter)(match, anchor, sink);
+	result = (*match->converter) (match, anchor, sink);
     } else {
 	result = NULL;
     }
@@ -474,17 +518,17 @@
 }
 
 /*		Put a presentation near start of list
-**		-------------------------------------
-**
-**	Look up a presentation (exact match only) and, if found, reorder
-**	it to the start of the HTPresentations list. - kw
-*/
-PUBLIC void HTReorderPresentation ARGS2(
-	HTFormat,		rep_in,
-	HTFormat,		rep_out)
+ *		-------------------------------------
+ *
+ *	Look up a presentation (exact match only) and, if found, reorder
+ *	it to the start of the HTPresentations list. - kw
+ */
+void HTReorderPresentation(HTFormat rep_in,
+			   HTFormat rep_out)
 {
     HTPresentation *match;
-    if ((match = HTFindPresentation(rep_in, rep_out, NULL))) {
+
+    if ((match = HTFindPresentation(rep_in, rep_out, NULL, NULL))) {
 	HTList_removeObject(HTPresentations, match);
 	HTList_addObject(HTPresentations, match);
     }
@@ -494,88 +538,77 @@
  * Setup 'get_accept' flag to denote presentations that are not redundant,
  * and will be listed in "Accept:" header.
  */
-PUBLIC void HTFilterPresentations NOARGS
+void HTFilterPresentations(void)
 {
     int i, j;
     int n = HTList_count(HTPresentations);
     HTPresentation *p, *q;
     BOOL matched;
-    char *s, *t, *x, *y;
+    char *s, *t;
 
+    CTRACE((tfp, "HTFilterPresentations (AcceptMedia %#x)\n", LYAcceptMedia));
     for (i = 0; i < n; i++) {
-	p = (HTPresentation *)HTList_objectAt(HTPresentations, i);
+	p = (HTPresentation *) HTList_objectAt(HTPresentations, i);
 	s = HTAtom_name(p->rep);
 
-	if (p->rep_out == WWW_PRESENT) {
-	    if (p->rep != WWW_SOURCE
-	     && strcasecomp(s, "www/mime")
-	     && strcasecomp(s, "www/compressed")
-	     && p->quality <= 1.0 && p->quality >= 0.0) {
-		for (j = 0, matched = FALSE; j < i; j++) {
-		    q = (HTPresentation *)HTList_objectAt(HTPresentations, j);
-		    t = HTAtom_name(q->rep);
-
-		    if (!strcasecomp(s, t)) {
-			matched = TRUE;
-			break;
-		    }
-		    if ((x = strchr(s, '/')) != 0
-		     && (y = strchr(t, '/')) != 0) {
-			int len1 = x++ - s;
-			int len2 = y++ - t;
-			int lens = (len1 > len2) ? len1 : len2;
-
-			if ((*t == '*' || !strncasecomp(s, t, lens))
-			 && (*y == '*' || !strcasecomp(x, y))) {
-			    matched = TRUE;
-			    break;
-			}
-		    }
+	p->get_accept = FALSE;
+	if ((LYAcceptMedia & p->accept_opt) != 0
+	    && p->rep_out == WWW_PRESENT
+	    && p->rep != WWW_SOURCE
+	    && strcasecomp(s, "www/mime")
+	    && strcasecomp(s, "www/compressed")
+	    && p->quality <= 1.0 && p->quality >= 0.0) {
+	    matched = TRUE;
+	    for (j = 0; j < i; j++) {
+		q = (HTPresentation *) HTList_objectAt(HTPresentations, j);
+		t = HTAtom_name(q->rep);
+
+		if (!strcasecomp(s, t)) {
+		    matched = FALSE;
+		    CTRACE((tfp, "  match %s %s\n", s, t));
+		    break;
 		}
-		if (!matched)
-		    p->get_accept = TRUE;
 	    }
+	    p->get_accept = matched;
 	}
     }
 }
 
 /*		Find the cost of a filter stack
-**		-------------------------------
-**
-**	Must return the cost of the same stack which StreamStack would set up.
-**
-** On entry,
-**	length	The size of the data to be converted
-*/
-PUBLIC float HTStackValue ARGS4(
-	HTFormat,		rep_in,
-	HTFormat,		rep_out,
-	float,			initial_value,
-	long int,		length)
+ *		-------------------------------
+ *
+ *	Must return the cost of the same stack which StreamStack would set up.
+ *
+ * On entry,
+ *	length	The size of the data to be converted
+ */
+float HTStackValue(HTFormat rep_in,
+		   HTFormat rep_out,
+		   float initial_value,
+		   long int length)
 {
-    HTAtom * wildcard = WWW_WILDCARD_REP_OUT;
+    HTAtom *wildcard = WWW_WILDCARD_REP_OUT;
 
     CTRACE((tfp, "HTFormat: Evaluating stream stack for %s worth %.3f to %s\n",
-		HTAtom_name(rep_in), initial_value, HTAtom_name(rep_out)));
+	    HTAtom_name(rep_in), initial_value, HTAtom_name(rep_out)));
 
     if (rep_out == WWW_SOURCE || rep_out == rep_in)
 	return 0.0;
 
-    /* don't do anymore do it in the Lynx code at startup LJM */
-    /* if (!HTPresentations) HTFormatInit(); */ /* set up the list */
-
     {
 	int n = HTList_count(HTPresentations);
 	int i;
-	HTPresentation * pres;
+	HTPresentation *pres;
+
 	for (i = 0; i < n; i++) {
-	    pres = (HTPresentation *)HTList_objectAt(HTPresentations, i);
+	    pres = (HTPresentation *) HTList_objectAt(HTPresentations, i);
 	    if (pres->rep == rep_in &&
 		(pres->rep_out == rep_out || pres->rep_out == wildcard)) {
 		float value = initial_value * pres->quality;
+
 		if (HTMaxSecs != 0.0)
-		    value = value - (length*pres->secs_per_byte + pres->secs)
-					 /HTMaxSecs;
+		    value = value - (length * pres->secs_per_byte + pres->secs)
+			/ HTMaxSecs;
 		return value;
 	    }
 	}
@@ -586,140 +619,140 @@
 }
 
 /*	Display the page while transfer in progress
-**	-------------------------------------------
-**
-**   Repaint the page only when necessary.
-**   This is a traverse call for HText_pageDisplay() - it works!.
-**
-*/
-PUBLIC void HTDisplayPartial NOARGS
+ *	-------------------------------------------
+ *
+ *   Repaint the page only when necessary.
+ *   This is a traverse call for HText_pageDisplay() - it works!.
+ *
+ */
+void HTDisplayPartial(void)
 {
 #ifdef DISP_PARTIAL
     if (display_partial) {
 	/*
-	**  HText_getNumOfLines() = "current" number of complete lines received
-	**  NumOfLines_partial = number of lines at the moment of last repaint.
-	**  (we update NumOfLines_partial only when we repaint the display.)
-	**
-	**  display_partial could only be enabled in HText_new()
-	**  so a new HTMainText object available - all HText_ functions use it,
-	**  lines counter HText_getNumOfLines() in particular.
-	**
-	**  Otherwise HTMainText holds info from the previous document
-	**  and we may repaint it instead of the new one:
-	**  prev doc scrolled to the first line (=Newline_partial)
-	**  is not good looking :-)	  23 Aug 1998 Leonid Pauzner
-	**
-	**  So repaint the page only when necessary:
-	*/
+	 * HText_getNumOfLines() = "current" number of complete lines received
+	 * NumOfLines_partial = number of lines at the moment of last repaint. 
+	 * (we update NumOfLines_partial only when we repaint the display.)
+	 *
+	 * display_partial could only be enabled in HText_new() so a new
+	 * HTMainText object available - all HText_ functions use it, lines
+	 * counter HText_getNumOfLines() in particular.
+	 *
+	 * Otherwise HTMainText holds info from the previous document and we
+	 * may repaint it instead of the new one:  prev doc scrolled to the
+	 * first line (=Newline_partial) is not good looking :-) 23 Aug 1998
+	 * Leonid Pauzner
+	 *
+	 * So repaint the page only when necessary:
+	 */
 	int Newline_partial = LYGetNewline();
 
 	if (((Newline_partial + display_lines) - 1 > NumOfLines_partial)
-		/* current page not complete... */
-	&& (partial_threshold > 0 ?
-		((Newline_partial + partial_threshold) -1 <= HText_getNumOfLines()) :
+	/* current page not complete... */
+	    && (partial_threshold > 0 ?
+		((Newline_partial + partial_threshold) - 1 <=
+		 HText_getNumOfLines()) :
 		((Newline_partial + display_lines) - 1 <= HText_getNumOfLines()))
-		/*
-		 * Originally we rendered by increments of 2 lines,
-		 * but that got annoying on slow network connections.
-		 * Then we switched to full-pages.  Now it's configurable.
-		 * If partial_threshold <= 0, then it's a full page
-		 */
-	) {
+	/*
+	 * Originally we rendered by increments of 2 lines,
+	 * but that got annoying on slow network connections.
+	 * Then we switched to full-pages.  Now it's configurable.
+	 * If partial_threshold <= 0, then it's a full page
+	 */
+	    ) {
 	    if (LYMainLoop_pageDisplay(Newline_partial))
 		NumOfLines_partial = HText_getNumOfLines();
 	}
     }
 #else /* nothing */
-#endif  /* DISP_PARTIAL */
+#endif /* DISP_PARTIAL */
 }
 
 /* Put this as early as possible, OK just after HTDisplayPartial() */
-PUBLIC void HTFinishDisplayPartial NOARGS
+void HTFinishDisplayPartial(void)
 {
 #ifdef DISP_PARTIAL
-		    /*
-		     *  End of incremental rendering stage here.
-		     */
-		    display_partial = FALSE;
+    /*
+     * End of incremental rendering stage here.
+     */
+    display_partial = FALSE;
 #endif /* DISP_PARTIAL */
 }
 
 /*	Push data from a socket down a stream
-**	-------------------------------------
-**
-**   This routine is responsible for creating and PRESENTING any
-**   graphic (or other) objects described by the file.
-**
-**   The file number given is assumed to be a TELNET stream, i.e., containing
-**   CRLF at the end of lines which need to be stripped to LF for unix
-**   when the format is textual.
-**
-**  State of socket and target stream on entry:
-**			socket (file_number) assumed open,
-**			target (sink) assumed valid.
-**
-**  Return values:
-**	HT_INTERRUPTED  Interruption or error after some data received.
-**	-2		Unexpected disconnect before any data received.
-**	-1		Interruption or error before any data received, or
-**			(UNIX) other read error before any data received, or
-**			download cancelled.
-**	HT_LOADED	Normal close of socket (end of file indication
-**			received), or
-**			unexpected disconnect after some data received, or
-**			other read error after some data received, or
-**			(not UNIX) other read error before any data received.
-**
-**  State of socket and target stream on return depends on return value:
-**	HT_INTERRUPTED	socket still open, target aborted.
-**	-2		socket still open, target stream still valid.
-**	-1		socket still open, target aborted.
-**	otherwise	socket closed,	target stream still valid.
-*/
-PUBLIC int HTCopy ARGS4(
-	HTParentAnchor *,	anchor,
-	int,			file_number,
-	void*,			handle GCC_UNUSED,
-	HTStream*,		sink)
+ *	-------------------------------------
+ *
+ *   This routine is responsible for creating and PRESENTING any
+ *   graphic (or other) objects described by the file.
+ *
+ *   The file number given is assumed to be a TELNET stream, i.e., containing
+ *   CRLF at the end of lines which need to be stripped to LF for unix
+ *   when the format is textual.
+ *
+ *  State of socket and target stream on entry:
+ *			socket (file_number) assumed open,
+ *			target (sink) assumed valid.
+ *
+ *  Return values:
+ *	HT_INTERRUPTED  Interruption or error after some data received.
+ *	-2		Unexpected disconnect before any data received.
+ *	-1		Interruption or error before any data received, or
+ *			(UNIX) other read error before any data received, or
+ *			download cancelled.
+ *	HT_LOADED	Normal close of socket (end of file indication
+ *			received), or
+ *			unexpected disconnect after some data received, or
+ *			other read error after some data received, or
+ *			(not UNIX) other read error before any data received.
+ *
+ *  State of socket and target stream on return depends on return value:
+ *	HT_INTERRUPTED	socket still open, target aborted.
+ *	-2		socket still open, target stream still valid.
+ *	-1		socket still open, target aborted.
+ *	otherwise	socket closed,	target stream still valid.
+ */
+int HTCopy(HTParentAnchor *anchor,
+	   int file_number,
+	   void *handle GCC_UNUSED,
+	   HTStream *sink)
 {
     HTStreamClass targetClass;
     BOOL suppress_readprogress = NO;
     int bytes;
     int rv = 0;
 
-    /*	Push the data down the stream
-    */
-    targetClass = *(sink->isa); /* Copy pointers to procedures */
-
-    /*	Push binary from socket down sink
-    **
-    **	This operation could be put into a main event loop
-    */
+    /*  Push the data down the stream
+     */
+    targetClass = *(sink->isa);	/* Copy pointers to procedures */
+
+    /*
+     * Push binary from socket down sink
+     *
+     * This operation could be put into a main event loop
+     */
     HTReadProgress(bytes = 0, 0);
     for (;;) {
 	int status;
 
 	if (LYCancelDownload) {
 	    LYCancelDownload = FALSE;
-	    (*targetClass._abort)(sink, NULL);
+	    (*targetClass._abort) (sink, NULL);
 	    rv = -1;
 	    goto finished;
 	}
 
 	if (HTCheckForInterrupt()) {
-	    _HTProgress (TRANSFER_INTERRUPTED);
-	    (*targetClass._abort)(sink, NULL);
+	    _HTProgress(TRANSFER_INTERRUPTED);
+	    (*targetClass._abort) (sink, NULL);
 	    if (bytes)
 		rv = HT_INTERRUPTED;
 	    else
 		rv = -1;
 	    goto finished;
 	}
-
 #ifdef USE_SSL
 	if (handle)
-	    status = SSL_read((SSL *)handle, input_buffer, INPUT_BUFFER_SIZE);
+	    status = SSL_read((SSL *) handle, input_buffer, INPUT_BUFFER_SIZE);
 	else
 	    status = NETREAD(file_number, input_buffer, INPUT_BUFFER_SIZE);
 #else
@@ -730,71 +763,69 @@
 	    if (status == 0) {
 		break;
 	    } else if (status == HT_INTERRUPTED) {
-		_HTProgress (TRANSFER_INTERRUPTED);
-		(*targetClass._abort)(sink, NULL);
+		_HTProgress(TRANSFER_INTERRUPTED);
+		(*targetClass._abort) (sink, NULL);
 		if (bytes)
 		    rv = HT_INTERRUPTED;
 		else
 		    rv = -1;
 		goto finished;
 	    } else if (SOCKET_ERRNO == ENOTCONN ||
-#ifdef _WINDOWS	/* 1997/11/10 (Mon) 16:57:18 */
+#ifdef _WINDOWS			/* 1997/11/10 (Mon) 16:57:18 */
 		       SOCKET_ERRNO == ETIMEDOUT ||
 #endif
 		       SOCKET_ERRNO == ECONNRESET ||
 		       SOCKET_ERRNO == EPIPE) {
 		/*
-		 *  Arrrrgh, HTTP 0/1 compatibility problem, maybe.
+		 * Arrrrgh, HTTP 0/1 compatibility problem, maybe.
 		 */
 		if (bytes <= 0) {
 		    /*
-		     *	Don't have any data, so let the calling
-		     *	function decide what to do about it. - FM
+		     * Don't have any data, so let the calling function decide
+		     * what to do about it.  - FM
 		     */
 		    rv = -2;
 		    goto finished;
 		} else {
 #ifdef UNIX
-		   /*
-		    *  Treat what we've received already as the complete
-		    *  transmission, but not without giving the user
-		    *  an alert.  I don't know about all the different
-		    *  TCP stacks for VMS etc., so this is currently
-		    *  only for UNIX. - kw
-		    */
-		   HTInetStatus("NETREAD");
-		   HTAlert("Unexpected server disconnect.");
-		   CTRACE((tfp,
-	    "HTCopy: Unexpected server disconnect. Treating as completed.\n"));
-		   status = 0;
-		   break;
-#else  /* !UNIX */
-		   /*
-		    *  Treat what we've gotten already
-		    *  as the complete transmission. - FM
-		    */
-		   CTRACE((tfp,
-	    "HTCopy: Unexpected server disconnect.  Treating as completed.\n"));
-		   status = 0;
-		   break;
+		    /*
+		     * Treat what we've received already as the complete
+		     * transmission, but not without giving the user an alert. 
+		     * I don't know about all the different TCP stacks for VMS
+		     * etc., so this is currently only for UNIX.  - kw
+		     */
+		    HTInetStatus("NETREAD");
+		    HTAlert("Unexpected server disconnect.");
+		    CTRACE((tfp,
+			    "HTCopy: Unexpected server disconnect. Treating as completed.\n"));
+		    status = 0;
+		    break;
+#else /* !UNIX */
+		    /*
+		     * Treat what we've gotten already as the complete
+		     * transmission.  - FM
+		     */
+		    CTRACE((tfp,
+			    "HTCopy: Unexpected server disconnect.  Treating as completed.\n"));
+		    status = 0;
+		    break;
 #endif /* UNIX */
 		}
 #ifdef UNIX
 	    } else {		/* status < 0 and other errno */
 		/*
-		 *  Treat what we've received already as the complete
-		 *  transmission, but not without giving the user
-		 *  an alert.  I don't know about all the different
-		 *  TCP stacks for VMS etc., so this is currently
-		 *  only for UNIX. - kw
+		 * Treat what we've received already as the complete
+		 * transmission, but not without giving the user an alert.  I
+		 * don't know about all the different TCP stacks for VMS etc.,
+		 * so this is currently only for UNIX.  - kw
 		 */
 		HTInetStatus("NETREAD");
 		HTAlert("Unexpected read error.");
 		if (bytes) {
-		    (void)NETCLOSE(file_number);
+		    (void) NETCLOSE(file_number);
 		    rv = HT_LOADED;
 		} else {
-		    (*targetClass._abort)(sink, NULL);
+		    (*targetClass._abort) (sink, NULL);
 		    rv = -1;
 		}
 		goto finished;
@@ -804,85 +835,84 @@
 	}
 
 	/*
-	 *  Suppress ReadProgress messages when collecting a redirection
-	 *  message, at least initially (unless/until anchor->content_type
-	 *  gets changed, probably by the MIME message parser).  That way
-	 *  messages put up by the HTTP module or elsewhere can linger in
-	 *  the statusline for a while. - kw
+	 * Suppress ReadProgress messages when collecting a redirection
+	 * message, at least initially (unless/until anchor->content_type gets
+	 * changed, probably by the MIME message parser).  That way messages
+	 * put up by the HTTP module or elsewhere can linger in the statusline
+	 * for a while.  - kw
 	 */
 	suppress_readprogress = (anchor && anchor->content_type &&
 				 !strcmp(anchor->content_type,
 					 "message/x-http-redirection"));
 #ifdef NOT_ASCII
 	{
-	    char * p;
-	    for (p = input_buffer; p < input_buffer+status; p++) {
+	    char *p;
+
+	    for (p = input_buffer; p < input_buffer + status; p++) {
 		*p = FROMASCII(*p);
 	    }
 	}
 #endif /* NOT_ASCII */
 
-	(*targetClass.put_block)(sink, input_buffer, status);
+	(*targetClass.put_block) (sink, input_buffer, status);
 	bytes += status;
 	if (!suppress_readprogress)
 	    HTReadProgress(bytes, anchor ? anchor->content_length : 0);
 	HTDisplayPartial();
 
-    } /* next bufferload */
+    }				/* next bufferload */
 
     _HTProgress(TRANSFER_COMPLETE);
-    (void)NETCLOSE(file_number);
+    (void) NETCLOSE(file_number);
     rv = HT_LOADED;
 
-finished:
+  finished:
     HTFinishDisplayPartial();
-    return(rv);
+    return (rv);
 }
 
 /*	Push data from a file pointer down a stream
-**	-------------------------------------
-**
-**   This routine is responsible for creating and PRESENTING any
-**   graphic (or other) objects described by the file.
-**
-**
-**  State of file and target stream on entry:
-**			FILE* (fp) assumed open,
-**			target (sink) assumed valid.
-**
-**  Return values:
-**	HT_INTERRUPTED  Interruption after some data read.
-**	HT_PARTIAL_CONTENT	Error after some data read.
-**	-1		Error before any data read.
-**	HT_LOADED	Normal end of file indication on reading.
-**
-**  State of file and target stream on return:
-**	always		fp still open, target stream still valid.
-*/
-PUBLIC int HTFileCopy ARGS2(
-	FILE *,			fp,
-	HTStream*,		sink)
+ *	-------------------------------------
+ *
+ *   This routine is responsible for creating and PRESENTING any
+ *   graphic (or other) objects described by the file.
+ *
+ *
+ *  State of file and target stream on entry:
+ *			FILE* (fp) assumed open,
+ *			target (sink) assumed valid.
+ *
+ *  Return values:
+ *	HT_INTERRUPTED  Interruption after some data read.
+ *	HT_PARTIAL_CONTENT	Error after some data read.
+ *	-1		Error before any data read.
+ *	HT_LOADED	Normal end of file indication on reading.
+ *
+ *  State of file and target stream on return:
+ *	always		fp still open, target stream still valid.
+ */
+int HTFileCopy(FILE *fp, HTStream *sink)
 {
     HTStreamClass targetClass;
     int status, bytes;
     int rv = HT_OK;
 
-    /*	Push the data down the stream
-    */
-    targetClass = *(sink->isa); /* Copy pointers to procedures */
+    /*  Push the data down the stream
+     */
+    targetClass = *(sink->isa);	/* Copy pointers to procedures */
 
-    /*	Push binary from socket down sink
-    */
+    /*  Push binary from socket down sink
+     */
     HTReadProgress(bytes = 0, 0);
     for (;;) {
 	status = fread(input_buffer, 1, INPUT_BUFFER_SIZE, fp);
-	if (status == 0) { /* EOF or error */
+	if (status == 0) {	/* EOF or error */
 	    if (ferror(fp) == 0) {
 		rv = HT_LOADED;
 		break;
 	    }
 	    CTRACE((tfp, "HTFormat: Read error, read returns %d\n",
-			ferror(fp)));
+		    ferror(fp)));
 	    if (bytes) {
 		rv = HT_PARTIAL_CONTENT;
 	    } else {
@@ -891,11 +921,11 @@
 	    break;
 	}
 
-	(*targetClass.put_block)(sink, input_buffer, status);
+	(*targetClass.put_block) (sink, input_buffer, status);
 	bytes += status;
 	HTReadProgress(bytes, 0);
-	/*  Suppress last screen update in partial mode - a regular update
-	 *  under control of mainloop() should follow anyway. - kw
+	/* Suppress last screen update in partial mode - a regular update under
+	 * control of mainloop() should follow anyway.  - kw
 	 */
 #ifdef DISP_PARTIAL
 	if (display_partial && bytes != HTMainAnchor->content_length)
@@ -903,7 +933,7 @@
 #endif
 
 	if (HTCheckForInterrupt()) {
-	    _HTProgress (TRANSFER_INTERRUPTED);
+	    _HTProgress(TRANSFER_INTERRUPTED);
 	    if (bytes) {
 		rv = HT_INTERRUPTED;
 	    } else {
@@ -911,7 +941,7 @@
 	    }
 	    break;
 	}
-    } /* next bufferload */
+    }				/* next bufferload */
 
     HTFinishDisplayPartial();
     return rv;
@@ -919,49 +949,48 @@
 
 #ifdef USE_SOURCE_CACHE
 /*	Push data from an HTChunk down a stream
-**	---------------------------------------
-**
-**   This routine is responsible for creating and PRESENTING any
-**   graphic (or other) objects described by the file.
-**
-**  State of memory and target stream on entry:
-**			HTChunk* (chunk) and target (sink) assumed valid.
-**
-**  Return values:
-**	HT_LOADED	All data sent.
-**	HT_INTERRUPTED  Interruption after some data read.
-**
-**  State of memory and target stream on return:
-**	always		chunk unchanged, target stream still valid.
-*/
-PUBLIC int HTMemCopy ARGS2(
-	HTChunk *,		chunk,
-	HTStream *,		sink)
+ *	---------------------------------------
+ *
+ *   This routine is responsible for creating and PRESENTING any
+ *   graphic (or other) objects described by the file.
+ *
+ *  State of memory and target stream on entry:
+ *			HTChunk* (chunk) and target (sink) assumed valid.
+ *
+ *  Return values:
+ *	HT_LOADED	All data sent.
+ *	HT_INTERRUPTED  Interruption after some data read.
+ *
+ *  State of memory and target stream on return:
+ *	always		chunk unchanged, target stream still valid.
+ */
+int HTMemCopy(HTChunk *chunk, HTStream *sink)
 {
     HTStreamClass targetClass;
     int bytes = 0;
-    CONST char *data = chunk->data;
+    const char *data = chunk->data;
     int rv = HT_OK;
 
     targetClass = *(sink->isa);
     HTReadProgress(0, 0);
     for (;;) {
 	/* Push the data down the stream a piece at a time, in case we're
-	** running a large document on a slow machine.
-	*/
+	 * running a large document on a slow machine.
+	 */
 	int n = INPUT_BUFFER_SIZE;
+
 	if (n > chunk->size - bytes)
 	    n = chunk->size - bytes;
 	if (n == 0)
 	    break;
-	(*targetClass.put_block)(sink, data, n);
+	(*targetClass.put_block) (sink, data, n);
 	bytes += n;
 	data += n;
 	HTReadProgress(bytes, 0);
 	HTDisplayPartial();
 
 	if (HTCheckForInterrupt()) {
-	    _HTProgress (TRANSFER_INTERRUPTED);
+	    _HTProgress(TRANSFER_INTERRUPTED);
 	    if (bytes) {
 		rv = HT_INTERRUPTED;
 	    } else {
@@ -978,52 +1007,50 @@
 
 #ifdef USE_ZLIB
 /*	Push data from a gzip file pointer down a stream
-**	-------------------------------------
-**
-**   This routine is responsible for creating and PRESENTING any
-**   graphic (or other) objects described by the file.
-**
-**
-**  State of file and target stream on entry:
-**		      gzFile (gzfp) assumed open (should have gzipped content),
-**		      target (sink) assumed valid.
-**
-**  Return values:
-**	HT_INTERRUPTED  Interruption after some data read.
-**	HT_PARTIAL_CONTENT	Error after some data read.
-**	-1		Error before any data read.
-**	HT_LOADED	Normal end of file indication on reading.
-**
-**  State of file and target stream on return:
-**	always		gzfp still open, target stream still valid.
-*/
-PRIVATE int HTGzFileCopy ARGS2(
-	gzFile,			gzfp,
-	HTStream*,		sink)
+ *	-------------------------------------
+ *
+ *   This routine is responsible for creating and PRESENTING any
+ *   graphic (or other) objects described by the file.
+ *
+ *
+ *  State of file and target stream on entry:
+ *		      gzFile (gzfp) assumed open (should have gzipped content),
+ *		      target (sink) assumed valid.
+ *
+ *  Return values:
+ *	HT_INTERRUPTED  Interruption after some data read.
+ *	HT_PARTIAL_CONTENT	Error after some data read.
+ *	-1		Error before any data read.
+ *	HT_LOADED	Normal end of file indication on reading.
+ *
+ *  State of file and target stream on return:
+ *	always		gzfp still open, target stream still valid.
+ */
+static int HTGzFileCopy(gzFile gzfp, HTStream *sink)
 {
     HTStreamClass targetClass;
     int status, bytes;
     int gzerrnum;
     int rv = HT_OK;
 
-    /*	Push the data down the stream
-    */
-    targetClass = *(sink->isa); /* Copy pointers to procedures */
+    /*  Push the data down the stream
+     */
+    targetClass = *(sink->isa);	/* Copy pointers to procedures */
 
-    /*	read and inflate gzip'd file, and push binary down sink
-    */
+    /*  read and inflate gzip'd file, and push binary down sink
+     */
     HTReadProgress(bytes = 0, 0);
     for (;;) {
 	status = gzread(gzfp, input_buffer, INPUT_BUFFER_SIZE);
-	if (status <= 0) { /* EOF or error */
+	if (status <= 0) {	/* EOF or error */
 	    if (status == 0) {
 		rv = HT_LOADED;
 		break;
 	    }
 	    CTRACE((tfp, "HTGzFileCopy: Read error, gzread returns %d\n",
-			status));
+		    status));
 	    CTRACE((tfp, "gzerror   : %s\n",
-			gzerror(gzfp, &gzerrnum)));
+		    gzerror(gzfp, &gzerrnum)));
 	    if (TRACE) {
 		if (gzerrnum == Z_ERRNO)
 		    perror("gzerror   ");
@@ -1036,13 +1063,13 @@
 	    break;
 	}
 
-	(*targetClass.put_block)(sink, input_buffer, status);
+	(*targetClass.put_block) (sink, input_buffer, status);
 	bytes += status;
 	HTReadProgress(bytes, -1);
 	HTDisplayPartial();
 
 	if (HTCheckForInterrupt()) {
-	    _HTProgress (TRANSFER_INTERRUPTED);
+	    _HTProgress(TRANSFER_INTERRUPTED);
 	    if (bytes) {
 		rv = HT_INTERRUPTED;
 	    } else {
@@ -1050,8 +1077,124 @@
 	    }
 	    break;
 	}
-    } /* next bufferload */
+    }				/* next bufferload */
+
+    HTFinishDisplayPartial();
+    return rv;
+}
+
+/*	Push data from a deflate file pointer down a stream
+ *	-------------------------------------
+ *
+ *  This routine is responsible for creating and PRESENTING any
+ *  graphic (or other) objects described by the file.  The code is
+ *  loosely based on the inflate.c file from w3m.
+ *
+ *
+ *  State of file and target stream on entry:
+ *		      FILE (zzfp) assumed open (should have deflated content),
+ *		      target (sink) assumed valid.
+ *
+ *  Return values:
+ *	HT_INTERRUPTED  Interruption after some data read.
+ *	HT_PARTIAL_CONTENT	Error after some data read.
+ *	-1		Error before any data read.
+ *	HT_LOADED	Normal end of file indication on reading.
+ *
+ *  State of file and target stream on return:
+ *	always		zzfp still open, target stream still valid.
+ */
+static int HTZzFileCopy(FILE *zzfp, HTStream *sink)
+{
+    static char dummy_head[1 + 1] =
+    {
+	0x8 + 0x7 * 0x10,
+	(((0x8 + 0x7 * 0x10) * 0x100 + 30) / 31 * 31) & 0xFF,
+    };
+
+    z_stream s;
+    HTStreamClass targetClass;
+    int bytes;
+    int rv = HT_OK;
+    char output_buffer[INPUT_BUFFER_SIZE];
+    int status;
+    int flush;
+    int retry = 0;
+    int len = 0;
+
+    /*  Push the data down the stream
+     */
+    targetClass = *(sink->isa);	/* Copy pointers to procedures */
+
+    s.zalloc = Z_NULL;
+    s.zfree = Z_NULL;
+    s.opaque = Z_NULL;
+    status = inflateInit(&s);
+    if (status != Z_OK) {
+	CTRACE((tfp, "HTZzFileCopy inflateInit() %s\n", zError(status)));
+	exit_immediately(1);
+    }
+    s.avail_in = 0;
+    s.next_out = (Bytef *) output_buffer;
+    s.avail_out = sizeof(output_buffer);
+    flush = Z_NO_FLUSH;
+
+    /*  read and inflate deflate'd file, and push binary down sink
+     */
+    HTReadProgress(bytes = 0, 0);
+    for (;;) {
+	if (s.avail_in == 0) {
+	    s.next_in = (Bytef *) input_buffer;
+	    len = s.avail_in = fread(input_buffer, 1, INPUT_BUFFER_SIZE, zzfp);
+	}
+	status = inflate(&s, flush);
+	if (status == Z_STREAM_END || status == Z_BUF_ERROR) {
+	    len = sizeof(output_buffer) - s.avail_out;
+	    if (len > 0) {
+		(*targetClass.put_block) (sink, output_buffer, len);
+		bytes += len;
+		HTReadProgress(bytes, -1);
+		HTDisplayPartial();
+	    }
+	    rv = HT_LOADED;
+	    break;
+	} else if (status == Z_DATA_ERROR && !retry++) {
+	    status = inflateReset(&s);
+	    if (status != Z_OK) {
+		CTRACE((tfp, "HTZzFileCopy inflateReset() %s\n", zError(status)));
+		rv = bytes ? HT_PARTIAL_CONTENT : -1;
+		break;
+	    }
+	    s.next_in = (Bytef *) dummy_head;
+	    s.avail_in = sizeof(dummy_head);
+	    status = inflate(&s, flush);
+	    s.next_in = (Bytef *) input_buffer;
+	    s.avail_in = len;
+	    continue;
+	} else if (status != Z_OK) {
+	    CTRACE((tfp, "HTZzFileCopy inflate() %s\n", zError(status)));
+	    rv = bytes ? HT_PARTIAL_CONTENT : -1;
+	    break;
+	} else if (s.avail_out == 0) {
+	    len = sizeof(output_buffer);
+	    s.next_out = (Bytef *) output_buffer;
+	    s.avail_out = sizeof(output_buffer);
+
+	    (*targetClass.put_block) (sink, output_buffer, len);
+	    bytes += len;
+	    HTReadProgress(bytes, -1);
+	    HTDisplayPartial();
+
+	    if (HTCheckForInterrupt()) {
+		_HTProgress(TRANSFER_INTERRUPTED);
+		rv = bytes ? HT_INTERRUPTED : -1;
+		break;
+	    }
+	}
+	retry = 1;
+    }				/* next bufferload */
 
+    inflateEnd(&s);
     HTFinishDisplayPartial();
     return rv;
 }
@@ -1059,52 +1202,50 @@
 
 #ifdef USE_BZLIB
 /*	Push data from a bzip file pointer down a stream
-**	-------------------------------------
-**
-**   This routine is responsible for creating and PRESENTING any
-**   graphic (or other) objects described by the file.
-**
-**
-**  State of file and target stream on entry:
-**		      BZFILE (bzfp) assumed open (should have bzipped content),
-**		      target (sink) assumed valid.
-**
-**  Return values:
-**	HT_INTERRUPTED  Interruption after some data read.
-**	HT_PARTIAL_CONTENT	Error after some data read.
-**	-1		Error before any data read.
-**	HT_LOADED	Normal end of file indication on reading.
-**
-**  State of file and target stream on return:
-**	always		bzfp still open, target stream still valid.
-*/
-PRIVATE int HTBzFileCopy ARGS2(
-	BZFILE *,		bzfp,
-	HTStream*,		sink)
+ *	-------------------------------------
+ *
+ *   This routine is responsible for creating and PRESENTING any
+ *   graphic (or other) objects described by the file.
+ *
+ *
+ *  State of file and target stream on entry:
+ *		      BZFILE (bzfp) assumed open (should have bzipped content),
+ *		      target (sink) assumed valid.
+ *
+ *  Return values:
+ *	HT_INTERRUPTED  Interruption after some data read.
+ *	HT_PARTIAL_CONTENT	Error after some data read.
+ *	-1		Error before any data read.
+ *	HT_LOADED	Normal end of file indication on reading.
+ *
+ *  State of file and target stream on return:
+ *	always		bzfp still open, target stream still valid.
+ */
+static int HTBzFileCopy(BZFILE * bzfp, HTStream *sink)
 {
     HTStreamClass targetClass;
     int status, bytes;
     int bzerrnum;
     int rv = HT_OK;
 
-    /*	Push the data down the stream
-    */
-    targetClass = *(sink->isa); /* Copy pointers to procedures */
+    /*  Push the data down the stream
+     */
+    targetClass = *(sink->isa);	/* Copy pointers to procedures */
 
-    /*	read and inflate bzip'd file, and push binary down sink
-    */
+    /*  read and inflate bzip'd file, and push binary down sink
+     */
     HTReadProgress(bytes = 0, 0);
     for (;;) {
 	status = BZ2_bzread(bzfp, input_buffer, INPUT_BUFFER_SIZE);
-	if (status <= 0) { /* EOF or error */
+	if (status <= 0) {	/* EOF or error */
 	    if (status == 0) {
 		rv = HT_LOADED;
 		break;
 	    }
 	    CTRACE((tfp, "HTBzFileCopy: Read error, bzread returns %d\n",
-			status));
+		    status));
 	    CTRACE((tfp, "bzerror   : %s\n",
-			BZ2_bzerror(bzfp, &bzerrnum)));
+		    BZ2_bzerror(bzfp, &bzerrnum)));
 	    if (bytes) {
 		rv = HT_PARTIAL_CONTENT;
 	    } else {
@@ -1113,13 +1254,13 @@
 	    break;
 	}
 
-	(*targetClass.put_block)(sink, input_buffer, status);
+	(*targetClass.put_block) (sink, input_buffer, status);
 	bytes += status;
 	HTReadProgress(bytes, -1);
 	HTDisplayPartial();
 
 	if (HTCheckForInterrupt()) {
-	    _HTProgress (TRANSFER_INTERRUPTED);
+	    _HTProgress(TRANSFER_INTERRUPTED);
 	    if (bytes) {
 		rv = HT_INTERRUPTED;
 	    } else {
@@ -1127,7 +1268,7 @@
 	    }
 	    break;
 	}
-    } /* next bufferload */
+    }				/* next bufferload */
 
     HTFinishDisplayPartial();
     return rv;
@@ -1135,84 +1276,83 @@
 #endif /* USE_BZLIB */
 
 /*	Push data from a socket down a stream STRIPPING CR
-**	--------------------------------------------------
-**
-**   This routine is responsible for creating and PRESENTING any
-**   graphic (or other) objects described by the socket.
-**
-**   The file number given is assumed to be a TELNET stream ie containing
-**   CRLF at the end of lines which need to be stripped to LF for unix
-**   when the format is textual.
-**
-*/
-PUBLIC void HTCopyNoCR ARGS3(
-	HTParentAnchor *,	anchor GCC_UNUSED,
-	int,			file_number,
-	HTStream*,		sink)
+ *	--------------------------------------------------
+ *
+ *   This routine is responsible for creating and PRESENTING any
+ *   graphic (or other) objects described by the socket.
+ *
+ *   The file number given is assumed to be a TELNET stream ie containing
+ *   CRLF at the end of lines which need to be stripped to LF for unix
+ *   when the format is textual.
+ *
+ */
+void HTCopyNoCR(HTParentAnchor *anchor GCC_UNUSED,
+		int file_number,
+		HTStream *sink)
 {
     HTStreamClass targetClass;
     int character;
 
-    /*	Push the data, ignoring CRLF, down the stream
-    */
-    targetClass = *(sink->isa); /* Copy pointers to procedures */
-
-    /*	Push text from telnet socket down sink
-    **
-    **	@@@@@ To push strings could be faster? (especially is we
-    **	cheat and don't ignore CR! :-}
-    */
+    /*  Push the data, ignoring CRLF, down the stream
+     */
+    targetClass = *(sink->isa);	/* Copy pointers to procedures */
+
+    /*
+     * Push text from telnet socket down sink
+     *
+     * @@@@@ To push strings could be faster?  (especially is we cheat and
+     * don't ignore CR!  :-}
+     */
     HTInitInput(file_number);
     for (;;) {
 	character = HTGetCharacter();
 	if (character == EOF)
 	    break;
-	(*targetClass.put_character)(sink, UCH(character));
+	(*targetClass.put_character) (sink, UCH(character));
     }
 }
 
 /*	Parse a socket given format and file number
-**
-**   This routine is responsible for creating and PRESENTING any
-**   graphic (or other) objects described by the file.
-**
-**   The file number given is assumed to be a TELNET stream ie containing
-**   CRLF at the end of lines which need to be stripped to LF for unix
-**   when the format is textual.
-**
-**  State of socket and target stream on entry:
-**			socket (file_number) assumed open,
-**			target (sink) usually NULL (will call stream stack).
-**
-**  Return values:
-**	HT_INTERRUPTED  Interruption or error after some data received.
-**	-501		Stream stack failed (cannot present or convert).
-**	-2		Unexpected disconnect before any data received.
-**	-1		Stream stack failed (cannot present or convert), or
-**			Interruption or error before any data received, or
-**			(UNIX) other read error before any data received, or
-**			download cancelled.
-**	HT_LOADED	Normal close of socket (end of file indication
-**			received), or
-**			unexpected disconnect after some data received, or
-**			other read error after some data received, or
-**			(not UNIX) other read error before any data received.
-**
-**  State of socket and target stream on return depends on return value:
-**	HT_INTERRUPTED	socket still open, target aborted.
-**	-501		socket still open, target stream NULL.
-**	-2		socket still open, target freed.
-**	-1		socket still open, target stream aborted or NULL.
-**	otherwise	socket closed,	target stream freed.
-*/
-PUBLIC int HTParseSocket ARGS5(
-	HTFormat,		rep_in,
-	HTFormat,		format_out,
-	HTParentAnchor *,	anchor,
-	int,			file_number,
-	HTStream*,		sink)
+ *
+ *   This routine is responsible for creating and PRESENTING any
+ *   graphic (or other) objects described by the file.
+ *
+ *   The file number given is assumed to be a TELNET stream ie containing
+ *   CRLF at the end of lines which need to be stripped to LF for unix
+ *   when the format is textual.
+ *
+ *  State of socket and target stream on entry:
+ *			socket (file_number) assumed open,
+ *			target (sink) usually NULL (will call stream stack).
+ *
+ *  Return values:
+ *	HT_INTERRUPTED  Interruption or error after some data received.
+ *	-501		Stream stack failed (cannot present or convert).
+ *	-2		Unexpected disconnect before any data received.
+ *	-1		Stream stack failed (cannot present or convert), or
+ *			Interruption or error before any data received, or
+ *			(UNIX) other read error before any data received, or
+ *			download cancelled.
+ *	HT_LOADED	Normal close of socket (end of file indication
+ *			received), or
+ *			unexpected disconnect after some data received, or
+ *			other read error after some data received, or
+ *			(not UNIX) other read error before any data received.
+ *
+ *  State of socket and target stream on return depends on return value:
+ *	HT_INTERRUPTED	socket still open, target aborted.
+ *	-501		socket still open, target stream NULL.
+ *	-2		socket still open, target freed.
+ *	-1		socket still open, target stream aborted or NULL.
+ *	otherwise	socket closed,	target stream freed.
+ */
+int HTParseSocket(HTFormat rep_in,
+		  HTFormat format_out,
+		  HTParentAnchor *anchor,
+		  int file_number,
+		  HTStream *sink)
 {
-    HTStream * stream;
+    HTStream *stream;
     HTStreamClass targetClass;
     int rv;
 
@@ -1220,63 +1360,63 @@
 
     if (!stream) {
 	char *buffer = 0;
+
 	if (LYCancelDownload) {
 	    LYCancelDownload = FALSE;
 	    return -1;
 	}
 	HTSprintf0(&buffer, CANNOT_CONVERT_I_TO_O,
-		HTAtom_name(rep_in), HTAtom_name(format_out));
+		   HTAtom_name(rep_in), HTAtom_name(format_out));
 	CTRACE((tfp, "HTFormat: %s\n", buffer));
-	rv = HTLoadError(sink, 501, buffer); /* returns -501 */
+	rv = HTLoadError(sink, 501, buffer);	/* returns -501 */
 	FREE(buffer);
     } else {
 	/*
-	** Push the data, don't worry about CRLF we can strip them later.
-	*/
+	 * Push the data, don't worry about CRLF we can strip them later.
+	 */
 	targetClass = *(stream->isa);	/* Copy pointers to procedures */
 	rv = HTCopy(anchor, file_number, NULL, stream);
 	if (rv != -1 && rv != HT_INTERRUPTED)
-	    (*targetClass._free)(stream);
+	    (*targetClass._free) (stream);
     }
     return rv;
     /* Originally:  full: HT_LOADED;  partial: HT_INTERRUPTED;  no bytes: -1 */
 }
 
 /*	Parse a file given format and file pointer
-**
-**   This routine is responsible for creating and PRESENTING any
-**   graphic (or other) objects described by the file.
-**
-**   The file number given is assumed to be a TELNET stream ie containing
-**   CRLF at the end of lines which need to be stripped to \n for unix
-**   when the format is textual.
-**
-**  State of file and target stream on entry:
-**			FILE* (fp) assumed open,
-**			target (sink) usually NULL (will call stream stack).
-**
-**  Return values:
-**	-501		Stream stack failed (cannot present or convert).
-**	-1		Download cancelled.
-**	HT_NO_DATA	Error before any data read.
-**	HT_PARTIAL_CONTENT	Interruption or error after some data read.
-**	HT_LOADED	Normal end of file indication on reading.
-**
-**  State of file and target stream on return:
-**	always		fp still open; target freed, aborted, or NULL.
-*/
-PUBLIC int HTParseFile ARGS5(
-	HTFormat,		rep_in,
-	HTFormat,		format_out,
-	HTParentAnchor *,	anchor,
-	FILE *,			fp,
-	HTStream*,		sink)
+ *
+ *   This routine is responsible for creating and PRESENTING any
+ *   graphic (or other) objects described by the file.
+ *
+ *   The file number given is assumed to be a TELNET stream ie containing
+ *   CRLF at the end of lines which need to be stripped to \n for unix
+ *   when the format is textual.
+ *
+ *  State of file and target stream on entry:
+ *			FILE* (fp) assumed open,
+ *			target (sink) usually NULL (will call stream stack).
+ *
+ *  Return values:
+ *	-501		Stream stack failed (cannot present or convert).
+ *	-1		Download cancelled.
+ *	HT_NO_DATA	Error before any data read.
+ *	HT_PARTIAL_CONTENT	Interruption or error after some data read.
+ *	HT_LOADED	Normal end of file indication on reading.
+ *
+ *  State of file and target stream on return:
+ *	always		fp still open; target freed, aborted, or NULL.
+ */
+int HTParseFile(HTFormat rep_in,
+		HTFormat format_out,
+		HTParentAnchor *anchor,
+		FILE *fp,
+		HTStream *sink)
 {
-    HTStream * stream;
+    HTStream *stream;
     HTStreamClass targetClass;
     int rv;
 
-#ifdef SH_EX		/* 1998/01/04 (Sun) 16:04:09 */
+#ifdef SH_EX			/* 1998/01/04 (Sun) 16:04:09 */
     if (fp == NULL)
 	return HT_LOADED;
 #endif
@@ -1285,30 +1425,32 @@
 
     if (!stream) {
 	char *buffer = 0;
+
 	if (LYCancelDownload) {
 	    LYCancelDownload = FALSE;
 	    return -1;
 	}
 	HTSprintf0(&buffer, CANNOT_CONVERT_I_TO_O,
-		HTAtom_name(rep_in), HTAtom_name(format_out));
+		   HTAtom_name(rep_in), HTAtom_name(format_out));
 	CTRACE((tfp, "HTFormat(in HTParseFile): %s\n", buffer));
 	rv = HTLoadError(sink, 501, buffer);
 	FREE(buffer);
 	return rv;
     }
 
-    /*	Push the data down the stream
-    **
-    **	@@  Bug:  This decision ought to be made based on "encoding"
-    **	rather than on content-type.  @@@  When we handle encoding.
-    **	The current method smells anyway.
-    */
+    /*
+     * Push the data down the stream
+     *
+     * @@ Bug:  This decision ought to be made based on "encoding" rather than
+     * on content-type.  @@@ When we handle encoding.  The current method
+     * smells anyway.
+     */
     targetClass = *(stream->isa);	/* Copy pointers to procedures */
     rv = HTFileCopy(fp, stream);
     if (rv == -1 || rv == HT_INTERRUPTED) {
-	(*targetClass._abort)(stream, NULL);
+	(*targetClass._abort) (stream, NULL);
     } else {
-	(*targetClass._free)(stream);
+	(*targetClass._free) (stream);
     }
 
     if (rv == -1)
@@ -1321,35 +1463,35 @@
 
 #ifdef USE_SOURCE_CACHE
 /*	Parse a document in memory given format and memory block pointer
-**
-**   This routine is responsible for creating and PRESENTING any
-**   graphic (or other) objects described by the file.
-**
-**  State of memory and target stream on entry:
-**			HTChunk* (chunk) assumed valid,
-**			target (sink) usually NULL (will call stream stack).
-**
-**  Return values:
-**	-501		Stream stack failed (cannot present or convert).
-**	HT_LOADED	All data sent.
-**
-**  State of memory and target stream on return:
-**	always		chunk unchanged; target freed, aborted, or NULL.
-*/
-PUBLIC int HTParseMem ARGS5(
-	HTFormat,		rep_in,
-	HTFormat,		format_out,
-	HTParentAnchor *,	anchor,
-	HTChunk *,		chunk,
-	HTStream *,		sink)
+ *
+ *   This routine is responsible for creating and PRESENTING any
+ *   graphic (or other) objects described by the file.
+ *
+ *  State of memory and target stream on entry:
+ *			HTChunk* (chunk) assumed valid,
+ *			target (sink) usually NULL (will call stream stack).
+ *
+ *  Return values:
+ *	-501		Stream stack failed (cannot present or convert).
+ *	HT_LOADED	All data sent.
+ *
+ *  State of memory and target stream on return:
+ *	always		chunk unchanged; target freed, aborted, or NULL.
+ */
+int HTParseMem(HTFormat rep_in,
+	       HTFormat format_out,
+	       HTParentAnchor *anchor,
+	       HTChunk *chunk,
+	       HTStream *sink)
 {
-    HTStream * stream;
+    HTStream *stream;
     HTStreamClass targetClass;
     int rv;
 
     stream = HTStreamStack(rep_in, format_out, sink, anchor);
     if (!stream) {
 	char *buffer = 0;
+
 	HTSprintf0(&buffer, CANNOT_CONVERT_I_TO_O,
 		   HTAtom_name(rep_in), HTAtom_name(format_out));
 	CTRACE((tfp, "HTFormat(in HTParseMem): %s\n", buffer));
@@ -1359,19 +1501,19 @@
     }
 
     /* Push the data down the stream
-    */
+     */
     targetClass = *(stream->isa);
     rv = HTMemCopy(chunk, stream);
-    (*targetClass._free)(stream);
+    (*targetClass._free) (stream);
     return HT_LOADED;
 }
 #endif
 
 #ifdef USE_ZLIB
-PRIVATE int HTCloseGzFile ARGS1(
-	gzFile,			gzfp)
+static int HTCloseGzFile(gzFile gzfp)
 {
     int gzres;
+
     if (gzfp == NULL)
 	return 0;
     gzres = gzclose(gzfp);
@@ -1382,33 +1524,32 @@
 	    CTRACE((tfp, "gzclose   : error number %d\n", gzres));
 	}
     }
-    return(gzres);
+    return (gzres);
 }
 
 /*	HTParseGzFile
-**
-**  State of file and target stream on entry:
-**			gzFile (gzfp) assumed open,
-**			target (sink) usually NULL (will call stream stack).
-**
-**  Return values:
-**	-501		Stream stack failed (cannot present or convert).
-**	-1		Download cancelled.
-**	HT_NO_DATA	Error before any data read.
-**	HT_PARTIAL_CONTENT	Interruption or error after some data read.
-**	HT_LOADED	Normal end of file indication on reading.
-**
-**  State of file and target stream on return:
-**	always		gzfp closed; target freed, aborted, or NULL.
-*/
-PUBLIC int HTParseGzFile ARGS5(
-	HTFormat,		rep_in,
-	HTFormat,		format_out,
-	HTParentAnchor *,	anchor,
-	gzFile,			gzfp,
-	HTStream*,		sink)
+ *
+ *  State of file and target stream on entry:
+ *			gzFile (gzfp) assumed open,
+ *			target (sink) usually NULL (will call stream stack).
+ *
+ *  Return values:
+ *	-501		Stream stack failed (cannot present or convert).
+ *	-1		Download cancelled.
+ *	HT_NO_DATA	Error before any data read.
+ *	HT_PARTIAL_CONTENT	Interruption or error after some data read.
+ *	HT_LOADED	Normal end of file indication on reading.
+ *
+ *  State of file and target stream on return:
+ *	always		gzfp closed; target freed, aborted, or NULL.
+ */
+int HTParseGzFile(HTFormat rep_in,
+		  HTFormat format_out,
+		  HTParentAnchor *anchor,
+		  gzFile gzfp,
+		  HTStream *sink)
 {
-    HTStream * stream;
+    HTStream *stream;
     HTStreamClass targetClass;
     int rv;
 
@@ -1416,31 +1557,33 @@
 
     if (!stream) {
 	char *buffer = 0;
+
 	HTCloseGzFile(gzfp);
 	if (LYCancelDownload) {
 	    LYCancelDownload = FALSE;
 	    return -1;
 	}
 	HTSprintf0(&buffer, CANNOT_CONVERT_I_TO_O,
-		HTAtom_name(rep_in), HTAtom_name(format_out));
+		   HTAtom_name(rep_in), HTAtom_name(format_out));
 	CTRACE((tfp, "HTFormat(in HTParseGzFile): %s\n", buffer));
 	rv = HTLoadError(sink, 501, buffer);
 	FREE(buffer);
 	return rv;
     }
 
-    /*	Push the data down the stream
-    **
-    **	@@  Bug:  This decision ought to be made based on "encoding"
-    **	rather than on content-type.  @@@  When we handle encoding.
-    **	The current method smells anyway.
-    */
+    /*
+     * Push the data down the stream
+     *
+     * @@ Bug:  This decision ought to be made based on "encoding" rather than
+     * on content-type.  @@@ When we handle encoding.  The current method
+     * smells anyway.
+     */
     targetClass = *(stream->isa);	/* Copy pointers to procedures */
     rv = HTGzFileCopy(gzfp, stream);
     if (rv == -1 || rv == HT_INTERRUPTED) {
-	(*targetClass._abort)(stream, NULL);
+	(*targetClass._abort) (stream, NULL);
     } else {
-	(*targetClass._free)(stream);
+	(*targetClass._free) (stream);
     }
 
     HTCloseGzFile(gzfp);
@@ -1451,40 +1594,106 @@
     else
 	return HT_LOADED;
 }
+
+/*	HTParseZzFile
+ *
+ *  State of file and target stream on entry:
+ *			FILE (zzfp) assumed open,
+ *			target (sink) usually NULL (will call stream stack).
+ *
+ *  Return values:
+ *	-501		Stream stack failed (cannot present or convert).
+ *	-1		Download cancelled.
+ *	HT_NO_DATA	Error before any data read.
+ *	HT_PARTIAL_CONTENT	Interruption or error after some data read.
+ *	HT_LOADED	Normal end of file indication on reading.
+ *
+ *  State of file and target stream on return:
+ *	always		zzfp closed; target freed, aborted, or NULL.
+ */
+int HTParseZzFile(HTFormat rep_in,
+		  HTFormat format_out,
+		  HTParentAnchor *anchor,
+		  FILE *zzfp,
+		  HTStream *sink)
+{
+    HTStream *stream;
+    HTStreamClass targetClass;
+    int rv;
+
+    stream = HTStreamStack(rep_in, format_out, sink, anchor);
+
+    if (!stream) {
+	char *buffer = 0;
+
+	fclose(zzfp);
+	if (LYCancelDownload) {
+	    LYCancelDownload = FALSE;
+	    return -1;
+	}
+	HTSprintf0(&buffer, CANNOT_CONVERT_I_TO_O,
+		   HTAtom_name(rep_in), HTAtom_name(format_out));
+	CTRACE((tfp, "HTFormat(in HTParseGzFile): %s\n", buffer));
+	rv = HTLoadError(sink, 501, buffer);
+	FREE(buffer);
+	return rv;
+    }
+
+    /*
+     * Push the data down the stream
+     *
+     * @@ Bug:  This decision ought to be made based on "encoding" rather than
+     * on content-type.  @@@ When we handle encoding.  The current method
+     * smells anyway.
+     */
+    targetClass = *(stream->isa);	/* Copy pointers to procedures */
+    rv = HTZzFileCopy(zzfp, stream);
+    if (rv == -1 || rv == HT_INTERRUPTED) {
+	(*targetClass._abort) (stream, NULL);
+    } else {
+	(*targetClass._free) (stream);
+    }
+
+    fclose(zzfp);
+    if (rv == -1)
+	return HT_NO_DATA;
+    else if (rv == HT_INTERRUPTED || (rv > 0 && rv != HT_LOADED))
+	return HT_PARTIAL_CONTENT;
+    else
+	return HT_LOADED;
+}
 #endif /* USE_ZLIB */
 
 #ifdef USE_BZLIB
-PRIVATE void HTCloseBzFile ARGS1(
-	BZFILE *,		bzfp)
+static void HTCloseBzFile(BZFILE * bzfp)
 {
     if (bzfp)
 	BZ2_bzclose(bzfp);
 }
 
 /*	HTParseBzFile
-**
-**  State of file and target stream on entry:
-**			bzFile (bzfp) assumed open,
-**			target (sink) usually NULL (will call stream stack).
-**
-**  Return values:
-**	-501		Stream stack failed (cannot present or convert).
-**	-1		Download cancelled.
-**	HT_NO_DATA	Error before any data read.
-**	HT_PARTIAL_CONTENT	Interruption or error after some data read.
-**	HT_LOADED	Normal end of file indication on reading.
-**
-**  State of file and target stream on return:
-**	always		bzfp closed; target freed, aborted, or NULL.
-*/
-PUBLIC int HTParseBzFile ARGS5(
-	HTFormat,		rep_in,
-	HTFormat,		format_out,
-	HTParentAnchor *,	anchor,
-	BZFILE*,		bzfp,
-	HTStream*,		sink)
+ *
+ *  State of file and target stream on entry:
+ *			bzFile (bzfp) assumed open,
+ *			target (sink) usually NULL (will call stream stack).
+ *
+ *  Return values:
+ *	-501		Stream stack failed (cannot present or convert).
+ *	-1		Download cancelled.
+ *	HT_NO_DATA	Error before any data read.
+ *	HT_PARTIAL_CONTENT	Interruption or error after some data read.
+ *	HT_LOADED	Normal end of file indication on reading.
+ *
+ *  State of file and target stream on return:
+ *	always		bzfp closed; target freed, aborted, or NULL.
+ */
+int HTParseBzFile(HTFormat rep_in,
+		  HTFormat format_out,
+		  HTParentAnchor *anchor,
+		  BZFILE * bzfp,
+		  HTStream *sink)
 {
-    HTStream * stream;
+    HTStream *stream;
     HTStreamClass targetClass;
     int rv;
 
@@ -1492,31 +1701,33 @@
 
     if (!stream) {
 	char *buffer = 0;
+
 	HTCloseBzFile(bzfp);
 	if (LYCancelDownload) {
 	    LYCancelDownload = FALSE;
 	    return -1;
 	}
 	HTSprintf0(&buffer, CANNOT_CONVERT_I_TO_O,
-		HTAtom_name(rep_in), HTAtom_name(format_out));
+		   HTAtom_name(rep_in), HTAtom_name(format_out));
 	CTRACE((tfp, "HTFormat(in HTParseBzFile): %s\n", buffer));
 	rv = HTLoadError(sink, 501, buffer);
 	FREE(buffer);
 	return rv;
     }
 
-    /*	Push the data down the stream
-    **
-    **	@@  Bug:  This decision ought to be made based on "encoding"
-    **	rather than on content-type.  @@@  When we handle encoding.
-    **	The current method smells anyway.
-    */
+    /*
+     * Push the data down the stream
+     *
+     * @@ Bug:  This decision ought to be made based on "encoding" rather than
+     * on content-type.  @@@ When we handle encoding.  The current method
+     * smells anyway.
+     */
     targetClass = *(stream->isa);	/* Copy pointers to procedures */
     rv = HTBzFileCopy(bzfp, stream);
     if (rv == -1 || rv == HT_INTERRUPTED) {
-	(*targetClass._abort)(stream, NULL);
+	(*targetClass._abort) (stream, NULL);
     } else {
-	(*targetClass._free)(stream);
+	(*targetClass._free) (stream);
     }
 
     HTCloseBzFile(bzfp);
@@ -1530,63 +1741,65 @@
 #endif /* USE_BZLIB */
 
 /*	Converter stream: Network Telnet to internal character text
-**	-----------------------------------------------------------
-**
-**	The input is assumed to be in ASCII, with lines delimited
-**	by (13,10) pairs, These pairs are converted into (CR,LF)
-**	pairs in the local representation.  The (CR,LF) sequence
-**	when found is changed to a '\n' character, the internal
-**	C representation of a new line.
-*/
+ *	-----------------------------------------------------------
+ *
+ *	The input is assumed to be in ASCII, with lines delimited
+ *	by (13,10) pairs, These pairs are converted into (CR,LF)
+ *	pairs in the local representation.  The (CR,LF) sequence
+ *	when found is changed to a '\n' character, the internal
+ *	C representation of a new line.
+ */
 
-PRIVATE void NetToText_put_character ARGS2(HTStream *, me, char, net_char)
+static void NetToText_put_character(HTStream *me, char net_char)
 {
     char c = FROMASCII(net_char);
+
     if (me->had_cr) {
 	if (c == LF) {
 	    me->sink->isa->put_character(me->sink, '\n');	/* Newline */
 	    me->had_cr = NO;
 	    return;
 	} else {
-	    me->sink->isa->put_character(me->sink, CR); /* leftover */
+	    me->sink->isa->put_character(me->sink, CR);		/* leftover */
 	}
     }
     me->had_cr = (BOOL) (c == CR);
     if (!me->had_cr)
-	me->sink->isa->put_character(me->sink, c);		/* normal */
+	me->sink->isa->put_character(me->sink, c);	/* normal */
 }
 
-PRIVATE void NetToText_put_string ARGS2(HTStream *, me, CONST char *, s)
+static void NetToText_put_string(HTStream *me, const char *s)
 {
-    CONST char * p;
+    const char *p;
 
     for (p = s; *p; p++)
 	NetToText_put_character(me, *p);
 }
 
-PRIVATE void NetToText_put_block ARGS3(HTStream *, me, CONST char*, s, int, l)
+static void NetToText_put_block(HTStream *me, const char *s, int l)
 {
-    CONST char * p;
+    const char *p;
 
-    for (p = s; p < (s+l); p++)
+    for (p = s; p < (s + l); p++)
 	NetToText_put_character(me, *p);
 }
 
-PRIVATE void NetToText_free ARGS1(HTStream *, me)
+static void NetToText_free(HTStream *me)
 {
-    (me->sink->isa->_free)(me->sink);		/* Close rest of pipe */
+    (me->sink->isa->_free) (me->sink);	/* Close rest of pipe */
     FREE(me);
 }
 
-PRIVATE void NetToText_abort ARGS2(HTStream *, me, HTError, e)
+static void NetToText_abort(HTStream *me, HTError e)
 {
-    me->sink->isa->_abort(me->sink,e);		/* Abort rest of pipe */
+    me->sink->isa->_abort(me->sink, e);		/* Abort rest of pipe */
     FREE(me);
 }
 
 /*	The class structure
 */
-PRIVATE HTStreamClass NetToTextClass = {
+static HTStreamClass NetToTextClass =
+{
     "NetToText",
     NetToText_free,
     NetToText_abort,
@@ -1597,9 +1810,9 @@
 
 /*	The creation method
 */
-PUBLIC HTStream * HTNetToText ARGS1(HTStream *, sink)
+HTStream *HTNetToText(HTStream *sink)
 {
-    HTStream* me = typecalloc(HTStream);
+    HTStream *me = typecalloc(HTStream);
 
     if (me == NULL)
 	outofmem(__FILE__, "NetToText");
@@ -1610,41 +1823,42 @@
     return me;
 }
 
-PRIVATE HTStream	HTBaseStreamInstance;		      /* Made static */
+static HTStream HTBaseStreamInstance;	/* Made static */
+
 /*
-**	ERROR STREAM
-**	------------
-**	There is only one error stream shared by anyone who wants a
-**	generic error returned from all stream methods.
-*/
-PRIVATE void HTErrorStream_put_character ARGS2(HTStream *, me GCC_UNUSED, char, c GCC_UNUSED)
+ *	ERROR STREAM
+ *	------------
+ *	There is only one error stream shared by anyone who wants a
+ *	generic error returned from all stream methods.
+ */
+static void HTErrorStream_put_character(HTStream *me GCC_UNUSED, char c GCC_UNUSED)
 {
     LYCancelDownload = TRUE;
 }
 
-PRIVATE void HTErrorStream_put_string ARGS2(HTStream *, me GCC_UNUSED, CONST char *, s)
+static void HTErrorStream_put_string(HTStream *me GCC_UNUSED, const char *s)
 {
     if (s && *s)
 	LYCancelDownload = TRUE;
 }
 
-PRIVATE void HTErrorStream_write ARGS3(HTStream *, me GCC_UNUSED, CONST char *, s, int, l)
+static void HTErrorStream_write(HTStream *me GCC_UNUSED, const char *s, int l)
 {
     if (l && s)
 	LYCancelDownload = TRUE;
 }
 
-PRIVATE void HTErrorStream_free ARGS1(HTStream *, me GCC_UNUSED)
+static void HTErrorStream_free(HTStream *me GCC_UNUSED)
 {
     return;
 }
 
-PRIVATE void HTErrorStream_abort ARGS2(HTStream *, me GCC_UNUSED, HTError, e GCC_UNUSED)
+static void HTErrorStream_abort(HTStream *me GCC_UNUSED, HTError e GCC_UNUSED)
 {
     return;
 }
 
-PRIVATE CONST HTStreamClass HTErrorStreamClass =
+static const HTStreamClass HTErrorStreamClass =
 {
     "ErrorStream",
     HTErrorStream_free,
@@ -1654,9 +1868,9 @@
     HTErrorStream_write
 };
 
-PUBLIC HTStream * HTErrorStream NOARGS
+HTStream *HTErrorStream(void)
 {
     CTRACE((tfp, "ErrorStream. Created\n"));
-    HTBaseStreamInstance.isa = &HTErrorStreamClass;    /* The rest is random */
+    HTBaseStreamInstance.isa = &HTErrorStreamClass;	/* The rest is random */
     return &HTBaseStreamInstance;
 }
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/HTRules.c
+++ lynx-cur-2.8.6/WWW/Library/Implementation/HTRules.c
@@ -1,23 +1,23 @@
 /*	Configuration manager for Hypertext Daemon		HTRules.c
-**	==========================================
-**
-**
-** History:
-**	 3 Jun 91	Written TBL
-**	10 Aug 91	Authorisation added after Daniel Martin (pass, fail)
-**			Rule order in file changed
-**			Comments allowed with # on 1st char of rule line
-**	17 Jun 92	Bug fix: pass and fail failed if didn't contain '*' TBL
-**	 1 Sep 93	Bug fix: no memory check - Nathan Torkington
-**			BYTE_ADDRESSING removed - Arthur Secret
-**	11 Sep 93  MD	Changed %i into %d in debug printf.
-**			VMS does not recognize %i.
-**			Bug Fix: in case of PASS, only one parameter to printf.
-**	19 Sep 93  AL	Added Access Authorization stuff.
-**	 1 Nov 93  AL	Added htbin.
-**	25 May 99  KW	Added redirect for lynx.
-**
-*/
+ *	==========================================
+ *
+ *
+ * History:
+ *	 3 Jun 91	Written TBL
+ *	10 Aug 91	Authorisation added after Daniel Martin (pass, fail)
+ *			Rule order in file changed
+ *			Comments allowed with # on 1st char of rule line
+ *	17 Jun 92	Bug fix: pass and fail failed if didn't contain '*' TBL
+ *	 1 Sep 93	Bug fix: no memory check - Nathan Torkington
+ *			BYTE_ADDRESSING removed - Arthur Secret
+ *	11 Sep 93  MD	Changed %i into %d in debug printf.
+ *			VMS does not recognize %i.
+ *			Bug Fix: in case of PASS, only one parameter to printf.
+ *	19 Sep 93  AL	Added Access Authorization stuff.
+ *	 1 Nov 93  AL	Added htbin.
+ *	25 May 99  KW	Added redirect for lynx.
+ *
+ */
 
 #include <HTUtils.h>
 
@@ -30,67 +30,65 @@
 
 #define LINE_LENGTH 256
 
-
 typedef struct _rule {
-	struct _rule *	next;
-	HTRuleOp	op;
-	char *		pattern;
-	char *		equiv;
-	char *		condition_op; /* as strings - may be inefficient, */
-	char *		condition;    /* but this is not for a server - kw */
+    struct _rule *next;
+    HTRuleOp op;
+    char *pattern;
+    char *equiv;
+    char *condition_op;		/* as strings - may be inefficient, */
+    char *condition;		/* but this is not for a server - kw */
 } rule;
 
 #ifndef NO_RULES
 
-#include <HTTP.h> /* for redirecting_url, indirectly HTPermitRedir - kw */
-#include <LYGlobalDefs.h> /* for LYUserSpecifiedURL - kw */
+#include <HTTP.h>		/* for redirecting_url, indirectly HTPermitRedir - kw */
+#include <LYGlobalDefs.h>	/* for LYUserSpecifiedURL - kw */
 #include <LYUtils.h>		/* for LYFixCursesOn - kw */
 #include <HTAlert.h>
 
 /*	Global variables
-**	----------------
-*/
-PUBLIC char *HTBinDir = NULL;	/* Physical /htbin directory path.	*/
-				/* In future this should not be global. */
-PUBLIC char *HTSearchScript = NULL;	/* Search script name.		*/
+ *	----------------
+ */
+char *HTBinDir = NULL;		/* Physical /htbin directory path.      */
 
+				/* In future this should not be global. */
+char *HTSearchScript = NULL;	/* Search script name.          */
 
 /*	Module-wide variables
-**	---------------------
-*/
+ *	---------------------
+ */
+
+static rule *rules = 0;		/* Pointer to first on list */
 
-PRIVATE rule * rules = 0;	/* Pointer to first on list */
 #ifndef PUT_ON_HEAD
-PRIVATE rule * rule_tail = 0;	/* Pointer to last on list */
+static rule *rule_tail = 0;	/* Pointer to last on list */
 #endif
 
-
 /*	Add rule to the list					HTAddRule()
-**	--------------------
-**
-**  On entry,
-**	pattern		points to 0-terminated string containing a single "*"
-**	equiv		points to the equivalent string with * for the
-**			place where the text matched by * goes.
-**  On exit,
-**	returns		0 if success, -1 if error.
-*/
-
-PUBLIC int HTAddRule ARGS5(
-    HTRuleOp,		op,
-    CONST char *,	pattern,
-    CONST char *,	equiv,
-    CONST char *,	cond_op,
-    CONST char *,	cond)
-{ /* BYTE_ADDRESSING removed and memory check - AS - 1 Sep 93 */
-    rule *	temp;
-    char *	pPattern = NULL;
+ *	--------------------
+ *
+ *  On entry,
+ *	pattern		points to 0-terminated string containing a single "*"
+ *	equiv		points to the equivalent string with * for the
+ *			place where the text matched by * goes.
+ *  On exit,
+ *	returns		0 if success, -1 if error.
+ */
+
+int HTAddRule(HTRuleOp op, const char *pattern,
+	      const char *equiv,
+	      const char *cond_op,
+	      const char *cond)
+{				/* BYTE_ADDRESSING removed and memory check - AS - 1 Sep 93 */
+    rule *temp;
+    char *pPattern = NULL;
 
     temp = typecalloc(rule);
-    if (temp==NULL)
+    if (temp == NULL)
 	outofmem(__FILE__, "HTAddRule");
     if (equiv) {		/* Two operands */
-	char *	pEquiv = NULL;
+	char *pEquiv = NULL;
+
 	StrAllocCopy(pEquiv, equiv);
 	temp->equiv = pEquiv;
     } else {
@@ -125,29 +123,30 @@
     rules = temp;
 #else
     temp->next = 0;
-    if (rule_tail) rule_tail->next = temp;
-    else rules = temp;
+    if (rule_tail)
+	rule_tail->next = temp;
+    else
+	rules = temp;
     rule_tail = temp;
 #endif
 
-
     return 0;
 }
 
-
 /*	Clear all rules						HTClearRules()
-**	---------------
-**
-** On exit,
-**	There are no rules
-**
-** See also
-**	HTAddRule()
-*/
-void HTClearRules NOARGS
+ *	---------------
+ *
+ * On exit,
+ *	There are no rules
+ *
+ * See also
+ *	HTAddRule()
+ */
+void HTClearRules(void)
 {
     while (rules) {
-	rule * temp = rules;
+	rule *temp = rules;
+
 	rules = temp->next;
 	FREE(temp->pattern);
 	FREE(temp->equiv);
@@ -160,15 +159,15 @@
 #endif
 }
 
-PRIVATE BOOL rule_cond_ok ARGS1(
-    rule *,	 r)
+static BOOL rule_cond_ok(rule * r)
 {
     BOOL result;
+
     if (!r->condition_op)
 	return YES;
     if (strcmp(r->condition_op, "if") && strcmp(r->condition_op, "unless")) {
 	CTRACE((tfp, "....... rule ignored, unrecognized `%s'!\n",
-	       r->condition_op));
+		r->condition_op));
 	return NO;
     }
     if (!strcmp(r->condition, "redirected"))
@@ -177,7 +176,7 @@
 	result = LYUserSpecifiedURL;
     else {
 	CTRACE((tfp, "....... rule ignored, unrecognized `%s %s'!\n",
-	       r->condition_op, NONNULL(r->condition)));
+		r->condition_op, NONNULL(r->condition)));
 	return NO;
     }
     if (!strcmp(r->condition_op, "if"))
@@ -186,31 +185,32 @@
 	return (BOOL) (!result);
 
 }
+
 /*	Translate by rules					HTTranslate()
-**	------------------
-**
-**	The most recently defined rules are applied first.
-**
-** On entry,
-**	required	points to a string whose equivalent value is needed
-** On exit,
-**	returns		the address of the equivalent string allocated from
-**			the heap which the CALLER MUST FREE. If no translation
-**			occurred, then it is a copy of the original.
-** NEW FEATURES:
-**			When a "protect" or "defprot" rule is matched,
-**			a call to HTAA_setCurrentProtection() or
-**			HTAA_setDefaultProtection() is made to notify
-**			the Access Authorization module that the file is
-**			protected, and so it knows how to handle it.
-**								-- AL
-*/
-char * HTTranslate ARGS1(
-    CONST char *,	required)
+ *	------------------
+ *
+ *	The most recently defined rules are applied first.
+ *
+ * On entry,
+ *	required	points to a string whose equivalent value is needed
+ * On exit,
+ *	returns		the address of the equivalent string allocated from
+ *			the heap which the CALLER MUST FREE. If no translation
+ *			occurred, then it is a copy of the original.
+ * NEW FEATURES:
+ *			When a "protect" or "defprot" rule is matched,
+ *			a call to HTAA_setCurrentProtection() or
+ *			HTAA_setDefaultProtection() is made to notify
+ *			the Access Authorization module that the file is
+ *			protected, and so it knows how to handle it.
+ *								-- AL
+ */
+char *HTTranslate(const char *required)
 {
-    rule * r;
+    rule *r;
     char *current = NULL;
-    char *msgtmp = NULL, *pMsg;
+    char *msgtmp = NULL;
+    const char *pMsg;
     int proxy_none_flag = 0;
     int permitredir_flag = 0;
 
@@ -218,25 +218,30 @@
 
     HTAA_clearProtections();	/* Reset from previous call -- AL */
 
-    for(r = rules; r; r = r->next) {
-	char * p = r->pattern;
-	int m=0;   /* Number of characters matched against wildcard */
-	CONST char * q = current;
-	for(;*p && *q; p++, q++) {   /* Find first mismatch */
-	    if (*p!=*q) break;
+    for (r = rules; r; r = r->next) {
+	char *p = r->pattern;
+	int m = 0;		/* Number of characters matched against wildcard */
+	const char *q = current;
+
+	for (; *p && *q; p++, q++) {	/* Find first mismatch */
+	    if (*p != *q)
+		break;
 	}
 
-	if (*p == '*') {		/* Match up to wildcard */
-	    m = strlen(q) - strlen(p+1); /* Amount to match to wildcard */
-	    if(m<0) continue;		/* tail is too short to match */
-	    if (0!=strcmp(q+m, p+1)) continue;	/* Tail mismatch */
-	} else				/* Not wildcard */
-	    if (*p != *q) continue;	/* plain mismatch: go to next rule */
+	if (*p == '*') {	/* Match up to wildcard */
+	    m = strlen(q) - strlen(p + 1);	/* Amount to match to wildcard */
+	    if (m < 0)
+		continue;	/* tail is too short to match */
+	    if (0 != strcmp(q + m, p + 1))
+		continue;	/* Tail mismatch */
+	} else
+	    /* Not wildcard */ if (*p != *q)
+	    continue;		/* plain mismatch: go to next rule */
 
 	if (!rule_cond_ok(r))	/* check condition, next rule if false - kw */
 	    continue;
 
-	switch (r->op) {		/* Perform operation */
+	switch (r->op) {	/* Perform operation */
 
 #ifdef ACCESS_AUTH
 	case HT_DefProt:
@@ -248,11 +253,11 @@
 		char *prot_file = NULL;
 
 		CTRACE((tfp, "HTRule: `%s' matched %s %s: `%s'\n",
-			    current,
-			    (r->op==HT_Protect ? "Protect" : "DefProt"),
-			    "rule, setup",
-			    (r->equiv ? r->equiv :
-			     (r->op==HT_Protect ?"DEFAULT" :"NULL!!"))));
+			current,
+			(r->op == HT_Protect ? "Protect" : "DefProt"),
+			"rule, setup",
+			(r->equiv ? r->equiv :
+			 (r->op == HT_Protect ? "DEFAULT" : "NULL!!"))));
 
 		if (r->equiv) {
 		    StrAllocCopy(local_copy, r->equiv);
@@ -273,40 +278,50 @@
 	    break;
 #endif /* ACCESS_AUTH */
 
-	case HT_UserMsg:		/* Produce message immediately */
+	case HT_UserMsg:	/* Produce message immediately */
 	    LYFixCursesOn("show rule message:");
 	    HTUserMsg2((r->equiv ? r->equiv : "Rule: %s"), current);
 	    break;
-	case HT_InfoMsg:		/* Produce messages immediately */
+	case HT_InfoMsg:	/* Produce messages immediately */
 	case HT_Progress:
 	case HT_Alert:
-	    LYFixCursesOn("show rule message:"); /* and fall through */
+	    LYFixCursesOn("show rule message:");	/* and fall through */
 	case HT_AlwaysAlert:
 	    pMsg = r->equiv ? r->equiv :
-		(r->op==HT_AlwaysAlert) ? "%s" : "Rule: %s";
+		(r->op == HT_AlwaysAlert) ? "%s" : "Rule: %s";
 	    if (strchr(pMsg, '%')) {
 		HTSprintf0(&msgtmp, pMsg, current);
 		pMsg = msgtmp;
 	    }
-	    switch (r->op) {		/* Actually produce message */
-	    case HT_InfoMsg:	HTInfoMsg(pMsg);	break;
-	    case HT_Progress:	HTProgress(pMsg);	break;
-	    case HT_Alert:	HTAlert(pMsg);		break;
-	    case HT_AlwaysAlert: HTAlwaysAlert("Rule alert:", pMsg);	break;
-	    default: break;
+	    switch (r->op) {	/* Actually produce message */
+	    case HT_InfoMsg:
+		HTInfoMsg(pMsg);
+		break;
+	    case HT_Progress:
+		HTProgress(pMsg);
+		break;
+	    case HT_Alert:
+		HTAlert(pMsg);
+		break;
+	    case HT_AlwaysAlert:
+		HTAlwaysAlert("Rule alert:", pMsg);
+		break;
+	    default:
+		break;
 	    }
 	    FREE(msgtmp);
 	    break;
 
-	case HT_PermitRedir:			/* Set special flag */
+	case HT_PermitRedir:	/* Set special flag */
 	    permitredir_flag = 1;
 	    CTRACE((tfp, "HTRule: Mark for redirection permitted\n"));
 	    break;
 
-	case HT_Pass:				/* Authorised */
+	case HT_Pass:		/* Authorised */
 	    if (!r->equiv) {
 		if (proxy_none_flag) {
-		    char * temp = NULL;
+		    char *temp = NULL;
+
 		    StrAllocCopy(temp, "NoProxy=");
 		    StrAllocCat(temp, current);
 		    FREE(current);
@@ -320,93 +335,97 @@
 	case HT_Map:
 	case HT_Redirect:
 	case HT_RedirectPerm:
-	    if (*p == *q) { /* End of both strings, no wildcard */
-		  CTRACE((tfp, "For `%s' using `%s'\n", current, r->equiv));
-		  StrAllocCopy(current, r->equiv); /* use entire translation */
+	    if (*p == *q) {	/* End of both strings, no wildcard */
+		CTRACE((tfp, "For `%s' using `%s'\n", current, r->equiv));
+		StrAllocCopy(current, r->equiv);	/* use entire translation */
 	    } else {
-		  char * ins = strchr(r->equiv, '*');	/* Insertion point */
-		  if (ins) {	/* Consistent rule!!! */
-			char * temp = NULL;
-
-			HTSprintf0(&temp, "%.*s%.*s%s",
-				   ins - r->equiv,
-				   r->equiv,
-				   m,
-				   q,
-				   ins + 1);
-			CTRACE((tfp, "For `%s' using `%s'\n",
-				    current, temp));
-			FREE(current);
-			current = temp;			/* Use this */
-
-		    } else {	/* No insertion point */
-			char * temp = NULL;
-
-			StrAllocCopy(temp, r->equiv);
-			CTRACE((tfp, "For `%s' using `%s'\n",
-						current, temp));
-			FREE(current);
-			current = temp;			/* Use this */
-		    } /* If no insertion point exists */
-		}
-		if (r->op == HT_Pass) {
-		    if (proxy_none_flag) {
-			char * temp = NULL;
-			StrAllocCopy(temp, "NoProxy=");
-			StrAllocCat(temp, current);
-			FREE(current);
-			current = temp;
-		    }
-		    CTRACE((tfp, "HTRule: ...and pass `%s'\n",
-				current));
-		    return current;
-		} else if (r->op == HT_Redirect) {
-		    CTRACE((tfp, "HTRule: ...and redirect to `%s'\n",
-				current));
-		    redirecting_url = current;
-		    HTPermitRedir = (BOOL) (permitredir_flag == 1);
-		    return (char *)0;
-		} else if (r->op == HT_RedirectPerm) {
-		    CTRACE((tfp, "HTRule: ...and redirect like 301 to `%s'\n",
-				current));
-		    redirecting_url = current;
-		    permanent_redirection = TRUE;
-		    HTPermitRedir = (BOOL) (permitredir_flag == 1);
-		    return (char *)0;
-		}
-		break;
+		char *ins = strchr(r->equiv, '*');	/* Insertion point */
 
-	case HT_UseProxy:
-		if (r->equiv && 0==strcasecomp(r->equiv, "none")) {
-		    CTRACE((tfp, "For `%s' will not use proxy\n", current));
-		    proxy_none_flag = 1;
-		} else if (proxy_none_flag) {
-		    CTRACE((tfp, "For `%s' proxy server ignored: %s\n",
-			   current,
-			   NONNULL(r->equiv)));
-		} else {
-		    char * temp = NULL;
-		    StrAllocCopy(temp, "Proxied=");
-		    StrAllocCat(temp, r->equiv);
+		if (ins) {	/* Consistent rule!!! */
+		    char *temp = NULL;
+
+		    HTSprintf0(&temp, "%.*s%.*s%s",
+			       ins - r->equiv,
+			       r->equiv,
+			       m,
+			       q,
+			       ins + 1);
+		    CTRACE((tfp, "For `%s' using `%s'\n",
+			    current, temp));
+		    FREE(current);
+		    current = temp;	/* Use this */
+
+		} else {	/* No insertion point */
+		    char *temp = NULL;
+
+		    StrAllocCopy(temp, r->equiv);
+		    CTRACE((tfp, "For `%s' using `%s'\n",
+			    current, temp));
+		    FREE(current);
+		    current = temp;	/* Use this */
+		}		/* If no insertion point exists */
+	    }
+	    if (r->op == HT_Pass) {
+		if (proxy_none_flag) {
+		    char *temp = NULL;
+
+		    StrAllocCopy(temp, "NoProxy=");
 		    StrAllocCat(temp, current);
-		    CTRACE((tfp, "HTRule: proxy server found: %s\n",
-			   NONNULL(r->equiv)));
 		    FREE(current);
-		    return temp;
+		    current = temp;
 		}
-		break;
+		CTRACE((tfp, "HTRule: ...and pass `%s'\n",
+			current));
+		return current;
+	    } else if (r->op == HT_Redirect) {
+		CTRACE((tfp, "HTRule: ...and redirect to `%s'\n",
+			current));
+		redirecting_url = current;
+		HTPermitRedir = (BOOL) (permitredir_flag == 1);
+		return (char *) 0;
+	    } else if (r->op == HT_RedirectPerm) {
+		CTRACE((tfp, "HTRule: ...and redirect like 301 to `%s'\n",
+			current));
+		redirecting_url = current;
+		permanent_redirection = TRUE;
+		HTPermitRedir = (BOOL) (permitredir_flag == 1);
+		return (char *) 0;
+	    }
+	    break;
 
-	case HT_Invalid:
-	case HT_Fail:				/* Unauthorised */
-		CTRACE((tfp, "HTRule: *** FAIL `%s'\n", current));
+	case HT_UseProxy:
+	    if (r->equiv && 0 == strcasecomp(r->equiv, "none")) {
+		CTRACE((tfp, "For `%s' will not use proxy\n", current));
+		proxy_none_flag = 1;
+	    } else if (proxy_none_flag) {
+		CTRACE((tfp, "For `%s' proxy server ignored: %s\n",
+			current,
+			NONNULL(r->equiv)));
+	    } else {
+		char *temp = NULL;
+
+		StrAllocCopy(temp, "Proxied=");
+		StrAllocCat(temp, r->equiv);
+		StrAllocCat(temp, current);
+		CTRACE((tfp, "HTRule: proxy server found: %s\n",
+			NONNULL(r->equiv)));
 		FREE(current);
-		return (char *)0;
-	} /* if tail matches ... switch operation */
+		return temp;
+	    }
+	    break;
+
+	case HT_Invalid:
+	case HT_Fail:		/* Unauthorised */
+	    CTRACE((tfp, "HTRule: *** FAIL `%s'\n", current));
+	    FREE(current);
+	    return (char *) 0;
+	}			/* if tail matches ... switch operation */
 
-    } /* loop over rules */
+    }				/* loop over rules */
 
     if (proxy_none_flag) {
-	char * temp = NULL;
+	char *temp = NULL;
+
 	StrAllocCopy(temp, "NoProxy=");
 	StrAllocCat(temp, current);
 	FREE(current);
@@ -417,93 +436,103 @@
 }
 
 /*	Load one line of configuration
-**	------------------------------
-**
-**	Call this, for example, to load a X resource with config info.
-**
-** returns	0 OK, < 0 syntax error.
-*/
-PUBLIC int  HTSetConfiguration ARGS1(
-    char *,		config)
+ *	------------------------------
+ *
+ *	Call this, for example, to load a X resource with config info.
+ *
+ * returns	0 OK, < 0 syntax error.
+ */
+int HTSetConfiguration(char *config)
 {
     HTRuleOp op;
-    char * line = NULL;
-    char * pointer = line;
-    char *word1, *word2, *word3;
-    char *cond_op=NULL, *cond=NULL;
+    char *line = NULL;
+    char *pointer = line;
+    char *word1;
+    const char *word2;
+    const char *word3;
+    const char *cond_op = NULL;
+    const char *cond = NULL;
     float quality, secs, secs_per_byte;
     int maxbytes;
     int status;
 
     StrAllocCopy(line, config);
     {
-	char * p = strchr(line, '#');	/* Chop off comments */
-	if (p) *p = 0;
+	char *p = strchr(line, '#');	/* Chop off comments */
+
+	if (p)
+	    *p = 0;
     }
     pointer = line;
     word1 = HTNextField(&pointer);
     if (!word1) {
 	FREE(line);
 	return 0;
-    } ; /* Comment only or blank */
+    };				/* Comment only or blank */
 
     word2 = HTNextField(&pointer);
 
-    if (0==strcasecomp(word1, "defprot") ||
-	0==strcasecomp(word1, "protect"))
-	word3 = pointer;  /* The rest of the line to be parsed by AA module */
+    if (0 == strcasecomp(word1, "defprot") ||
+	0 == strcasecomp(word1, "protect"))
+	word3 = pointer;	/* The rest of the line to be parsed by AA module */
     else
 	word3 = HTNextField(&pointer);	/* Just the next word */
 
     if (!word2) {
 	fprintf(stderr, "HTRule: %s %s\n", RULE_NEEDS_DATA, line);
 	FREE(line);
-	return -2;	/*syntax error */
+	return -2;		/*syntax error */
     }
 
-    if (0==strcasecomp(word1, "suffix")) {
-	char * encoding = HTNextField(&pointer);
-	if (pointer) status = sscanf(pointer, "%f", &quality);
-	else status = 0;
-	HTSetSuffix(word2,	word3,
-				encoding ? encoding : "binary",
-				status >= 1? quality : (float) 1.0);
+    if (0 == strcasecomp(word1, "suffix")) {
+	char *encoding = HTNextField(&pointer);
 
-    } else if (0==strcasecomp(word1, "presentation")) {
-	if (pointer) status = sscanf(pointer, "%f%f%f%d",
+	if (pointer)
+	    status = sscanf(pointer, "%f", &quality);
+	else
+	    status = 0;
+	HTSetSuffix(word2, word3,
+		    encoding ? encoding : "binary",
+		    status >= 1 ? quality : (float) 1.0);
+
+    } else if (0 == strcasecomp(word1, "presentation")) {
+	if (pointer)
+	    status = sscanf(pointer, "%f%f%f%d",
 			    &quality, &secs, &secs_per_byte, &maxbytes);
-	else status = 0;
-	HTSetPresentation(word2, word3,
-		    status >= 1 ? quality		: 1.0,
-		    status >= 2 ? secs			: 0.0,
-		    status >= 3 ? secs_per_byte		: 0.0,
-		    status >= 4 ? maxbytes		: 0 );
+	else
+	    status = 0;
+	HTSetPresentation(word2, word3, NULL,
+			  status >= 1 ? quality : 1.0,
+			  status >= 2 ? secs : 0.0,
+			  status >= 3 ? secs_per_byte : 0.0,
+			  status >= 4 ? maxbytes : 0,
+			  mediaCFG);
 
-    } else if (0==strncasecomp(word1, "htbin", 5) ||
-	       0==strncasecomp(word1, "bindir", 6)) {
+    } else if (0 == strncasecomp(word1, "htbin", 5) ||
+	       0 == strncasecomp(word1, "bindir", 6)) {
 	StrAllocCopy(HTBinDir, word2);	/* Physical /htbin location */
 
-    } else if (0==strncasecomp(word1, "search", 6)) {
+    } else if (0 == strncasecomp(word1, "search", 6)) {
 	StrAllocCopy(HTSearchScript, word2);	/* Search script name */
 
     } else {
-	op =	0==strcasecomp(word1, "map")  ? HT_Map
-	    :	0==strcasecomp(word1, "pass") ? HT_Pass
-	    :	0==strcasecomp(word1, "fail") ? HT_Fail
-	    :	0==strcasecomp(word1, "redirect") ? HT_Redirect
-	    :	0==strncasecomp(word1, "redirectperm", 12) ? HT_RedirectPerm
-	    :	0==strcasecomp(word1, "redirecttemp") ? HT_Redirect
-	    :	0==strcasecomp(word1, "permitredirection") ? HT_PermitRedir
-	    :	0==strcasecomp(word1, "useproxy") ? HT_UseProxy
-	    :	0==strcasecomp(word1, "alert") ? HT_Alert
-	    :	0==strcasecomp(word1, "alwaysalert") ? HT_AlwaysAlert
-	    :	0==strcasecomp(word1, "progress") ? HT_Progress
-	    :	0==strcasecomp(word1, "usermsg") ? HT_UserMsg
-	    :	0==strcasecomp(word1, "infomsg") ? HT_InfoMsg
-	    :	0==strcasecomp(word1, "defprot") ? HT_DefProt
-	    :	0==strcasecomp(word1, "protect") ? HT_Protect
-	    :						HT_Invalid;
-	if (op==HT_Invalid) {
+	op = 0 == strcasecomp(word1, "map") ? HT_Map
+	    : 0 == strcasecomp(word1, "pass") ? HT_Pass
+	    : 0 == strcasecomp(word1, "fail") ? HT_Fail
+	    : 0 == strcasecomp(word1, "redirect") ? HT_Redirect
+	    : 0 == strncasecomp(word1, "redirectperm", 12) ? HT_RedirectPerm
+	    : 0 == strcasecomp(word1, "redirecttemp") ? HT_Redirect
+	    : 0 == strcasecomp(word1, "permitredirection") ? HT_PermitRedir
+	    : 0 == strcasecomp(word1, "useproxy") ? HT_UseProxy
+	    : 0 == strcasecomp(word1, "alert") ? HT_Alert
+	    : 0 == strcasecomp(word1, "alwaysalert") ? HT_AlwaysAlert
+	    : 0 == strcasecomp(word1, "progress") ? HT_Progress
+	    : 0 == strcasecomp(word1, "usermsg") ? HT_UserMsg
+	    : 0 == strcasecomp(word1, "infomsg") ? HT_InfoMsg
+	    : 0 == strcasecomp(word1, "defprot") ? HT_DefProt
+	    : 0 == strcasecomp(word1, "protect") ? HT_Protect
+	    : HT_Invalid;
+	if (op == HT_Invalid) {
 	    fprintf(stderr, "HTRule: %s '%s'\n", RULE_INCORRECT, config);
 	} else {
 	    switch (op) {
@@ -523,29 +552,29 @@
 		    word3 = NULL;
 		    cond = HTNextField(&pointer);
 		    break;
-		} /* else fall through */
-
+		}
+		/* else fall through */
 	    case HT_Map:	/* always a URL2 (or other 2nd parameter) */
 	    case HT_Redirect:
 	    case HT_RedirectPerm:
 	    case HT_UseProxy:
 		cond_op = HTNextField(&pointer);
 		/* check for extra status word in "Redirect" */
-		if (op==HT_Redirect && 0==strcasecomp(word1, "redirect") &&
+		if (op == HT_Redirect && 0 == strcasecomp(word1, "redirect") &&
 		    cond_op &&
 		    strcasecomp(cond_op, "if") &&
 		    strcasecomp(cond_op, "unless")) {
-		    if (0==strcmp(word2, "301") ||
-			0==strcasecomp(word2, "permanent")) {
+		    if (0 == strcmp(word2, "301") ||
+			0 == strcasecomp(word2, "permanent")) {
 			op = HT_RedirectPerm;
-		    } else if (!(0==strcmp(word2, "302") ||
-				 0==strcmp(word2, "303") ||
-				 0==strcasecomp(word2, "temp") ||
-				 0==strcasecomp(word2, "seeother"))) {
+		    } else if (!(0 == strcmp(word2, "302") ||
+				 0 == strcmp(word2, "303") ||
+				 0 == strcasecomp(word2, "temp") ||
+				 0 == strcasecomp(word2, "seeother"))) {
 			CTRACE((tfp, "Rule: Ignoring `%s' in Redirect\n", word2));
 		    }
 		    word2 = word3;
-		    word3 = cond_op; /* cond_op isn't condition op after all */
+		    word3 = cond_op;	/* cond_op isn't condition op after all */
 		    cond_op = HTNextField(&pointer);
 		}
 		if (cond_op && *cond_op)
@@ -561,31 +590,34 @@
 		if (cond_op && *cond_op)
 		    cond = HTNextField(&pointer);
 		if (word3) {	/* Fix string with too may %s - kw */
-		    char *cp = word3, *cp1, *cp2;
-		    while ((cp1=strchr(cp, '%'))) {
+		    const char *cp = word3;
+		    char *cp1, *cp2;
+
+		    while ((cp1 = strchr(cp, '%'))) {
 			if (cp1[1] == '\0') {
 			    *cp1 = '\0';
 			    break;
 			} else if (cp1[1] == '%') {
 			    cp = cp1 + 2;
 			    continue;
-			} else while ((cp2=strchr(cp1+2, '%'))) {
-			    if (cp2[1] == '\0') {
-				*cp2 = '\0';
-				break;
-			    } else if (cp2[1] == '%') {
-				cp1 = cp2;
-			    } else {
-				*cp2 = '?'; /* replace bad % */
-				cp1 = cp2;
+			} else
+			    while ((cp2 = strchr(cp1 + 2, '%'))) {
+				if (cp2[1] == '\0') {
+				    *cp2 = '\0';
+				    break;
+				} else if (cp2[1] == '%') {
+				    cp1 = cp2;
+				} else {
+				    *cp2 = '?';		/* replace bad % */
+				    cp1 = cp2;
+				}
 			    }
-			}
 			break;
 		    }
 		}
 		break;
 
-		default:
+	    default:
 		break;
 	    }
 	    if (cond_op && cond && *cond && !strcasecomp(cond_op, "unless")) {
@@ -599,10 +631,10 @@
 		return -2;	/* NB unrecognized cond passes here - kw */
 	    }
 	    if (cond && !strncasecomp(cond, "redirected", strlen(cond))) {
-		cond = "redirected"; /* recognized, canonical case - kw */
+		cond = "redirected";	/* recognized, canonical case - kw */
 	    } else if (cond && strlen(cond) >= 8 &&
-		!strncasecomp(cond, "userspecified", strlen(cond))) {
-		cond = "userspec"; /* also allow abbreviation - kw */
+		       !strncasecomp(cond, "userspecified", strlen(cond))) {
+		cond = "userspec";	/* also allow abbreviation - kw */
 	    }
 	    HTAddRule(op, word2, word3, cond_op, cond);
 	}
@@ -611,37 +643,36 @@
     return 0;
 }
 
-
 /*	Load the rules from a file				HTLoadRules()
-**	--------------------------
-**
-** On entry,
-**	Rules can be in any state
-** On exit,
-**	Any existing rules will have been kept.
-**	Any new rules will have been loaded.
-**	Returns		0 if no error, 0 if error!
-**
-** Bugs:
-**	The strings may not contain spaces.
-*/
+ *	--------------------------
+ *
+ * On entry,
+ *	Rules can be in any state
+ * On exit,
+ *	Any existing rules will have been kept.
+ *	Any new rules will have been loaded.
+ *	Returns		0 if no error, 0 if error!
+ *
+ * Bugs:
+ *	The strings may not contain spaces.
+ */
 
-int HTLoadRules ARGS1(
-    CONST char *,	filename)
+int HTLoadRules(const char *filename)
 {
-    FILE * fp = fopen(filename, TXT_R);
-    char line[LINE_LENGTH+1];
+    FILE *fp = fopen(filename, TXT_R);
+    char line[LINE_LENGTH + 1];
 
     if (!fp) {
 	CTRACE((tfp, "HTRules: Can't open rules file %s\n", filename));
-	return -1; /* File open error */
+	return -1;		/* File open error */
     }
-    for(;;) {
-	if (!fgets(line, LINE_LENGTH+1, fp)) break;	/* EOF or error */
+    for (;;) {
+	if (!fgets(line, LINE_LENGTH + 1, fp))
+	    break;		/* EOF or error */
 	(void) HTSetConfiguration(line);
     }
     fclose(fp);
-    return 0;		/* No error or syntax errors ignored */
+    return 0;			/* No error or syntax errors ignored */
 }
 
 #endif /* NO_RULES */
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/HTString.c
+++ lynx-cur-2.8.6/WWW/Library/Implementation/HTString.c
@@ -1,12 +1,12 @@
 /*		Case-independent string comparison		HTString.c
-**
-**	Original version came with listserv implementation.
-**	Version TBL Oct 91 replaces one which modified the strings.
-**	02-Dec-91 (JFG) Added stralloccopy and stralloccat
-**	23 Jan 92 (TBL) Changed strallocc* to 8 char HTSAC* for VM and suchlike
-**	 6 Oct 92 (TBL) Moved WWW_TraceFlag in here to be in library
-**	15 Nov 98 (TD)  Added HTSprintf.
-*/
+ *
+ *	Original version came with listserv implementation.
+ *	Version TBL Oct 91 replaces one which modified the strings.
+ *	02-Dec-91 (JFG) Added stralloccopy and stralloccat
+ *	23 Jan 92 (TBL) Changed strallocc* to 8 char HTSAC* for VM and suchlike
+ *	 6 Oct 92 (TBL) Moved WWW_TraceFlag in here to be in library
+ *	15 Nov 98 (TD)  Added HTSprintf.
+ */
 
 #include <HTUtils.h>
 
@@ -14,265 +14,251 @@
 #include <LYStrings.h>
 
 #ifndef NO_LYNX_TRACE
-PUBLIC BOOLEAN WWW_TraceFlag = 0;	/* Global trace flag for ALL W3 code */
-PUBLIC int WWW_TraceMask = 0;		/* Global trace flag for ALL W3 code */
+BOOLEAN WWW_TraceFlag = 0;	/* Global trace flag for ALL W3 code */
+int WWW_TraceMask = 0;		/* Global trace flag for ALL W3 code */
 #endif
 
 #ifndef VC
-#define VC "unknown"
+#define VC "2.14"
 #endif /* !VC */
 
 #ifdef _WINDOWS
-CONST char * HTLibraryVersion = "2.14FM"; /* String for help screen etc */
+const char *HTLibraryVersion = "2.14FM";	/* String for help screen etc */
+
 #else
-PUBLIC CONST char * HTLibraryVersion = VC; /* String for help screen etc */
+const char *HTLibraryVersion = VC;	/* String for help screen etc */
 #endif
 
 /*
-**     strcasecomp8 is a variant of strcasecomp (below)
-**     ------------		    -----------
-**     but uses 8bit upper/lower case information
-**     from the current display charset.
-**     It returns 0 if exact match.
-*/
-PUBLIC int strcasecomp8 ARGS2(
-       CONST char*,    a,
-       CONST char *,   b)
+ *     strcasecomp8 is a variant of strcasecomp (below)
+ *     ------------		    -----------
+ *     but uses 8bit upper/lower case information
+ *     from the current display charset.
+ *     It returns 0 if exact match.
+ */
+int strcasecomp8(const char *a,
+		 const char *b)
 {
-    CONST char *p = a;
-    CONST char *q = b;
+    const char *p = a;
+    const char *q = b;
 
-    for ( ; *p && *q; p++, q++) {
+    for (; *p && *q; p++, q++) {
 	int diff = UPPER8(*p, *q);
-	if (diff) return diff;
+
+	if (diff)
+	    return diff;
     }
     if (*p)
-	return 1;	/* p was longer than q */
+	return 1;		/* p was longer than q */
     if (*q)
-	return -1;	/* p was shorter than q */
-    return 0;		/* Exact match */
+	return -1;		/* p was shorter than q */
+    return 0;			/* Exact match */
 }
 
 /*
-**     strncasecomp8 is a variant of strncasecomp (below)
-**     -------------		     ------------
-**     but uses 8bit upper/lower case information
-**     from the current display charset.
-**     It returns 0 if exact match.
-*/
-PUBLIC int strncasecomp8 ARGS3(
-	CONST char*,	a,
-	CONST char *,	b,
-	int,		n)
+ *     strncasecomp8 is a variant of strncasecomp (below)
+ *     -------------		     ------------
+ *     but uses 8bit upper/lower case information
+ *     from the current display charset.
+ *     It returns 0 if exact match.
+ */
+int strncasecomp8(const char *a,
+		  const char *b,
+		  int n)
 {
-    CONST char *p = a;
-    CONST char *q = b;
+    const char *p = a;
+    const char *q = b;
 
-    for ( ; ; p++, q++) {
+    for (;; p++, q++) {
 	int diff;
-	if (p == (a+n))
-	    return 0;	/*   Match up to n characters */
+
+	if (p == (a + n))
+	    return 0;		/*   Match up to n characters */
 	if (!(*p && *q))
 	    return (*p - *q);
 	diff = UPPER8(*p, *q);
 	if (diff)
 	    return diff;
     }
-    /*NOTREACHED*/
+    /*NOTREACHED */
 }
 
-#ifndef VM		/* VM has these already it seems */
+#ifndef VM			/* VM has these already it seems */
 
-#ifdef SH_EX	/* 1997/12/23 (Tue) 16:40:31 */
+#ifdef SH_EX			/* 1997/12/23 (Tue) 16:40:31 */
 
 /*
  * This array is designed for mapping upper and lower case letter
  * together for a case independent comparison.  The mappings are
  * based upon ascii character sequences.
  */
-static unsigned char charmap[] = {
-	'\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007',
-	'\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017',
-	'\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027',
-	'\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037',
-	'\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047',
-	'\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057',
-	'\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067',
-	'\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077',
-	'\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
-	'\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
-	'\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
-	'\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137',
-	'\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
-	'\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
-	'\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
-	'\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177',
-	'\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207',
-	'\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217',
-	'\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227',
-	'\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237',
-	'\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247',
-	'\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257',
-	'\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267',
-	'\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277',
-	'\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
-	'\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
-	'\360', '\361', '\362', '\363', '\364', '\365', '\366', '\327',
-	'\370', '\371', '\372', '\373', '\374', '\375', '\376', '\337',
-	'\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
-	'\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
-	'\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367',
-	'\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377',
+static unsigned char charmap[] =
+{
+    '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007',
+    '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017',
+    '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027',
+    '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037',
+    '\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047',
+    '\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057',
+    '\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067',
+    '\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077',
+    '\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
+    '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
+    '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
+    '\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137',
+    '\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
+    '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
+    '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
+    '\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177',
+    '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207',
+    '\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217',
+    '\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227',
+    '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237',
+    '\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247',
+    '\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257',
+    '\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267',
+    '\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277',
+    '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
+    '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
+    '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\327',
+    '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\337',
+    '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
+    '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
+    '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367',
+    '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377',
 };
 
-PUBLIC int strcasecomp ARGS2(
-	CONST char*,	s1,
-	CONST char*,	s2)
+int strcasecomp(const char *s1,
+		const char *s2)
 {
     register unsigned char *cm = charmap;
-    register unsigned char *us1 = (unsigned char *)s1;
-    register unsigned char *us2 = (unsigned char *)s2;
+    register unsigned char *us1 = (unsigned char *) s1;
+    register unsigned char *us2 = (unsigned char *) s2;
 
     while (cm[*us1] == cm[*us2++])
 	if (*us1++ == '\0')
-	    return(0);
+	    return (0);
     return (cm[*us1] - cm[*--us2]);
 }
 
-PUBLIC int strncasecomp ARGS3(
-	CONST char*,	a,
-	CONST char*,	b,
-	int,		n)
+int strncasecomp(const char *a,
+		 const char *b,
+		 int n)
 {
     register unsigned char *cm = charmap;
-    register unsigned char *us1 = (unsigned char *)a;
-    register unsigned char *us2 = (unsigned char *)b;
+    register unsigned char *us1 = (unsigned char *) a;
+    register unsigned char *us2 = (unsigned char *) b;
 
-    while ((long)(--n) >= 0 && cm[*us1] == cm[*us2++])
+    while ((long) (--n) >= 0 && cm[*us1] == cm[*us2++])
 	if (*us1++ == '\0')
-	    return(0);
-    return ((long)n < 0 ? 0 : cm[*us1] - cm[*--us2]);
+	    return (0);
+    return ((long) n < 0 ? 0 : cm[*us1] - cm[*--us2]);
 }
 
-#else	/* SH_EX */
+#else /* SH_EX */
 
 /*	Strings of any length
-**	---------------------
-*/
-PUBLIC int strcasecomp ARGS2(
-	CONST char*,	a,
-	CONST char *,	b)
+ *	---------------------
+ */
+int strcasecomp(const char *a,
+		const char *b)
 {
-    CONST char *p = a;
-    CONST char *q = b;
+    const char *p = a;
+    const char *q = b;
 
-    for ( ; *p && *q; p++, q++) {
+    for (; *p && *q; p++, q++) {
 	int diff = TOLOWER(*p) - TOLOWER(*q);
-	if (diff) return diff;
+
+	if (diff)
+	    return diff;
     }
     if (*p)
-	return 1;	/* p was longer than q */
+	return 1;		/* p was longer than q */
     if (*q)
-	return -1;	/* p was shorter than q */
-    return 0;		/* Exact match */
+	return -1;		/* p was shorter than q */
+    return 0;			/* Exact match */
 }
 
-
 /*	With count limit
-**	----------------
-*/
-PUBLIC int strncasecomp ARGS3(
-	CONST char*,	a,
-	CONST char *,	b,
-	int,		n)
+ *	----------------
+ */
+int strncasecomp(const char *a,
+		 const char *b,
+		 int n)
 {
-    CONST char *p = a;
-    CONST char *q = b;
+    const char *p = a;
+    const char *q = b;
 
-    for ( ; ; p++, q++) {
+    for (;; p++, q++) {
 	int diff;
-	if (p == (a+n))
-	    return 0;	/*   Match up to n characters */
+
+	if (p == (a + n))
+	    return 0;		/*   Match up to n characters */
 	if (!(*p && *q))
 	    return (*p - *q);
 	diff = TOLOWER(*p) - TOLOWER(*q);
 	if (diff)
 	    return diff;
     }
-    /*NOTREACHED*/
+    /*NOTREACHED */
 }
 
-#endif	/* SH_EX */
+#endif /* SH_EX */
 #endif /* VM */
 
 #ifdef NOT_ASCII
 
 /*	Case-insensitive with ASCII collating sequence
-**	----------------
-*/
-PUBLIC int AS_casecomp ARGS2(
-	CONST char*,	p,
-	CONST char*,	q)
+ *	----------------
+ */
+int AS_casecomp(const char *p,
+		const char *q)
 {
     int diff;
 
-    for ( ; ; p++, q++) {
+    for (;; p++, q++) {
 	if (!(*p && *q))
-	    return (UCH(*p)  - UCH(*q));
+	    return (UCH(*p) - UCH(*q));
 	diff = TOASCII(TOLOWER(*p))
-	     - TOASCII(TOLOWER(*q));
+	    - TOASCII(TOLOWER(*q));
 	if (diff)
 	    return diff;
     }
-    /*NOTREACHED*/
+    /*NOTREACHED */
 }
 
-
 /*	With count limit and ASCII collating sequence
-**	----------------
-**	AS_cmp uses n == -1 to compare indefinite length.
-*/
-PUBLIC int AS_ncmp ARGS3(
-	CONST char *,	p,
-	CONST char *,	q,
-	unsigned int,	n)
+ *	----------------
+ *	AS_cmp uses n == -1 to compare indefinite length.
+ */
+int AS_ncmp(const char *p,
+	    const char *q,
+	    unsigned int n)
 {
-    CONST char *a = p;
+    const char *a = p;
     int diff;
 
-    for ( ; (p-a) < n; p++, q++) {
+    for (; (unsigned) (p - a) < n; p++, q++) {
 	if (!(*p && *q))
 	    return (UCH(*p) - UCH(*q));
 	diff = TOASCII(*p)
-	     - TOASCII(*q);
+	    - TOASCII(*q);
 	if (diff)
 	    return diff;
     }
-    return 0;	/*   Match up to n characters */
-}
-
-
-/*	With ASCII collating sequence
-**	----------------
-*/
-PUBLIC int AS_cmp ARGS2(
-	CONST char *,	p,
-	CONST char *,	q)
-{
-    return( AS_ncmp( p, q, -1 ) );
+    return 0;			/*   Match up to n characters */
 }
 #endif /* NOT_ASCII */
 
-
 /*	Allocate a new copy of a string, and returns it
 */
-PUBLIC char * HTSACopy ARGS2(
-	char **,	dest,
-	CONST char *,	src)
+char *HTSACopy(char **dest,
+	       const char *src)
 {
     if (src != 0) {
 	if (src != *dest) {
 	    size_t size = strlen(src) + 1;
+
 	    FREE(*dest);
 	    *dest = (char *) malloc(size);
 	    if (*dest == NULL)
@@ -287,58 +273,55 @@
 
 /*	String Allocate and Concatenate
 */
-PUBLIC char * HTSACat ARGS2(
-	char **,	dest,
-	CONST char *,	src)
+char *HTSACat(char **dest,
+	      const char *src)
 {
     if (src && *src && (src != *dest)) {
 	if (*dest) {
 	    size_t length = strlen(*dest);
-	    *dest = (char *)realloc(*dest, length + strlen(src) + 1);
+
+	    *dest = (char *) realloc(*dest, length + strlen(src) + 1);
 	    if (*dest == NULL)
 		outofmem(__FILE__, "HTSACat");
-	    strcpy (*dest + length, src);
+	    strcpy(*dest + length, src);
 	} else {
-	    *dest = (char *)malloc(strlen(src) + 1);
+	    *dest = (char *) malloc(strlen(src) + 1);
 	    if (*dest == NULL)
 		outofmem(__FILE__, "HTSACat");
-	    strcpy (*dest, src);
+	    strcpy(*dest, src);
 	}
     }
     return *dest;
 }
 
-
 /* optimized for heavily realloc'd strings, store length inside */
 
-#define EXTRA_TYPE size_t		/* type we use for length */
+#define EXTRA_TYPE size_t	/* type we use for length */
 #define EXTRA_SIZE sizeof(void *)	/* alignment >= sizeof(EXTRA_TYPE) */
 
-PUBLIC void   HTSAFree_extra ARGS1(
-	char *,		s)
+void HTSAFree_extra(char *s)
 {
     free(s - EXTRA_SIZE);
 }
 
 /* never shrink */
-PUBLIC char * HTSACopy_extra ARGS2(
-	char **,	dest,
-	CONST char *,	src)
+char *HTSACopy_extra(char **dest,
+		     const char *src)
 {
     if (src != 0) {
 	size_t srcsize = strlen(src) + 1;
 	EXTRA_TYPE size = 0;
 
 	if (*dest != 0) {
-	    size = *(EXTRA_TYPE *)((*dest) - EXTRA_SIZE);
+	    size = *(EXTRA_TYPE *) ((*dest) - EXTRA_SIZE);
 	}
 	if (size < srcsize) {
 	    FREE_extra(*dest);
-	    size = srcsize * 2;   /* x2 step */
+	    size = srcsize * 2;	/* x2 step */
 	    *dest = (char *) malloc(size + EXTRA_SIZE);
 	    if (*dest == NULL)
 		outofmem(__FILE__, "HTSACopy_extra");
-	    *(EXTRA_TYPE *)(*dest) = size;
+	    *(EXTRA_TYPE *) (*dest) = size;
 	    *dest += EXTRA_SIZE;
 	}
 	memcpy(*dest, src, srcsize);
@@ -349,42 +332,41 @@
 }
 
 /*	Find next Field
-**	---------------
-**
-** On entry,
-**	*pstr	points to a string containig white space separated
-**		field, optionlly quoted.
-**
-** On exit,
-**	*pstr	has been moved to the first delimiter past the
-**		field
-**		THE STRING HAS BEEN MUTILATED by a 0 terminator
-**
-**	returns a pointer to the first field
-*/
-PUBLIC char * HTNextField ARGS1(
-	char **,	pstr)
+ *	---------------
+ *
+ * On entry,
+ *	*pstr	points to a string containig white space separated
+ *		field, optionlly quoted.
+ *
+ * On exit,
+ *	*pstr	has been moved to the first delimiter past the
+ *		field
+ *		THE STRING HAS BEEN MUTILATED by a 0 terminator
+ *
+ *	returns a pointer to the first field
+ */
+char *HTNextField(char **pstr)
 {
-    char * p = *pstr;
-    char * start;			/* start of field */
+    char *p = *pstr;
+    char *start;		/* start of field */
 
     while (*p && WHITE(*p))
-	p++;				/* Strip white space */
+	p++;			/* Strip white space */
     if (!*p) {
 	*pstr = p;
 	return NULL;		/* No first field */
     }
-    if (*p == '"') {			/* quoted field */
+    if (*p == '"') {		/* quoted field */
 	p++;
 	start = p;
-	for (; *p && *p!='"'; p++) {
+	for (; *p && *p != '"'; p++) {
 	    if (*p == '\\' && p[1])
-		p++;			/* Skip escaped chars */
+		p++;		/* Skip escaped chars */
 	}
     } else {
 	start = p;
 	while (*p && !WHITE(*p))
-	    p++;			/* Skip first field */
+	    p++;		/* Skip first field */
     }
     if (*p)
 	*p++ = '\0';
@@ -393,140 +375,167 @@
 }
 
 /*	Find next Token
-**	---------------
-**	Finds the next token in a string
-**	On entry,
-**	*pstr	points to a string to be parsed.
-**	delims	lists characters to be recognized as delimiters.
-**		If NULL, default is white space "," ";" or "=".
-**		The word can optionally be quoted or enclosed with
-**		chars from bracks.
-**		Comments surrrounded by '(' ')' are filtered out
-**		unless they are specifically reqested by including
-**		' ' or '(' in delims or bracks.
-**	bracks	lists bracketing chars.  Some are recognized as
-**		special, for those give the opening char.
-**		If NULL, defaults to <"> and "<" ">".
-**	found	points to location to fill with the ending delimiter
-**		found, or is NULL.
-**
-**	On exit,
-**	*pstr	has been moved to the first delimiter past the
-**		field
-**		THE STRING HAS BEEN MUTILATED by a 0 terminator
-**	found	points to the delimiter found unless it was NULL.
-**	Returns a pointer to the first word or NULL on error
-*/
-PUBLIC char * HTNextTok ARGS4(
-	char **,	pstr,
-	CONST char *,	delims,
-	CONST char *,	bracks,
-	char *,		found)
+ *	---------------
+ *	Finds the next token in a string
+ *	On entry,
+ *	*pstr	points to a string to be parsed.
+ *	delims	lists characters to be recognized as delimiters.
+ *		If NULL, default is white space "," ";" or "=".
+ *		The word can optionally be quoted or enclosed with
+ *		chars from bracks.
+ *		Comments surrrounded by '(' ')' are filtered out
+ *		unless they are specifically reqested by including
+ *		' ' or '(' in delims or bracks.
+ *	bracks	lists bracketing chars.  Some are recognized as
+ *		special, for those give the opening char.
+ *		If NULL, defaults to <"> and "<" ">".
+ *	found	points to location to fill with the ending delimiter
+ *		found, or is NULL.
+ *
+ *	On exit,
+ *	*pstr	has been moved to the first delimiter past the
+ *		field
+ *		THE STRING HAS BEEN MUTILATED by a 0 terminator
+ *	found	points to the delimiter found unless it was NULL.
+ *	Returns a pointer to the first word or NULL on error
+ */
+char *HTNextTok(char **pstr,
+		const char *delims,
+		const char *bracks,
+		char *found)
 {
-    char * p = *pstr;
-    char * start = NULL;
+    char *p = *pstr;
+    char *start = NULL;
     BOOL get_blanks, skip_comments;
     BOOL get_comments;
     BOOL get_closing_char_too = FALSE;
     char closer;
 
-    if (isEmpty(pstr)) return NULL;
-    if (!delims) delims = " ;,=" ;
-    if (!bracks) bracks = "<\"" ;
-
-    get_blanks = (BOOL) (!strchr(delims,' ') && !strchr(bracks,' '));
-    get_comments = (BOOL) (strchr(bracks,'(') != NULL);
-    skip_comments = (BOOL) (!get_comments && !strchr(delims,'(') && !get_blanks);
+    if (isEmpty(pstr))
+	return NULL;
+    if (!delims)
+	delims = " ;,=";
+    if (!bracks)
+	bracks = "<\"";
+
+    get_blanks = (BOOL) (!strchr(delims, ' ') && !strchr(bracks, ' '));
+    get_comments = (BOOL) (strchr(bracks, '(') != NULL);
+    skip_comments = (BOOL) (!get_comments && !strchr(delims, '(') && !get_blanks);
 #define skipWHITE(c) (!get_blanks && WHITE(c))
 
     while (*p && skipWHITE(*p))
-	p++;				/* Strip white space */
+	p++;			/* Strip white space */
     if (!*p) {
 	*pstr = p;
-	if (found) *found = '\0';
+	if (found)
+	    *found = '\0';
 	return NULL;		/* No first field */
     }
     while (1) {
 	/* Strip white space and other delimiters */
-	while (*p && (skipWHITE(*p) || strchr(delims,*p))) p++;
+	while (*p && (skipWHITE(*p) || strchr(delims, *p)))
+	    p++;
 	if (!*p) {
 	    *pstr = p;
-	    if (found) *found = *(p-1);
-	    return NULL;					 /* No field */
+	    if (found)
+		*found = *(p - 1);
+	    return NULL;	/* No field */
 	}
 
-	if (*p == '(' && (skip_comments || get_comments)) {	  /* Comment */
+	if (*p == '(' && (skip_comments || get_comments)) {	/* Comment */
 	    int comment_level = 0;
-	    if (get_comments && !start) start = p+1;
-	    for(;*p && (*p!=')' || --comment_level>0); p++) {
-		if (*p == '(') comment_level++;
-		else if (*p == '"') {	      /* quoted field within Comment */
-		    for(p++; *p && *p!='"'; p++)
-			if (*p == '\\' && *(p+1)) p++; /* Skip escaped chars */
-		    if (!*p) break; /* (invalid) end of string found, leave */
+
+	    if (get_comments && !start)
+		start = p + 1;
+	    for (; *p && (*p != ')' || --comment_level > 0); p++) {
+		if (*p == '(')
+		    comment_level++;
+		else if (*p == '"') {	/* quoted field within Comment */
+		    for (p++; *p && *p != '"'; p++)
+			if (*p == '\\' && *(p + 1))
+			    p++;	/* Skip escaped chars */
+		    if (!*p)
+			break;	/* (invalid) end of string found, leave */
 		}
-		if (*p == '\\' && *(p+1)) p++;	       /* Skip escaped chars */
+		if (*p == '\\' && *(p + 1))
+		    p++;	/* Skip escaped chars */
 	    }
 	    if (get_comments)
 		break;
-	    if (*p) p++;
+	    if (*p)
+		p++;
 	    if (get_closing_char_too) {
-		if (!*p || (!strchr(bracks,*p) && strchr(delims,*p))) {
+		if (!*p || (!strchr(bracks, *p) && strchr(delims, *p))) {
 		    break;
 		} else
-		    get_closing_char_too = (BOOL) (strchr(bracks,*p) != NULL);
+		    get_closing_char_too = (BOOL) (strchr(bracks, *p) != NULL);
 	    }
-	} else if (strchr(bracks,*p)) {	       /* quoted or bracketed field */
+	} else if (strchr(bracks, *p)) {	/* quoted or bracketed field */
 	    switch (*p) {
-	       case '<': closer = '>'; break;
-	       case '[': closer = ']'; break;
-	       case '{': closer = '}'; break;
-	       case ':': closer = ';'; break;
-	    default:	 closer = *p;
+	    case '<':
+		closer = '>';
+		break;
+	    case '[':
+		closer = ']';
+		break;
+	    case '{':
+		closer = '}';
+		break;
+	    case ':':
+		closer = ';';
+		break;
+	    default:
+		closer = *p;
 	    }
-	    if (!start) start = ++p;
-	    for(;*p && *p!=closer; p++)
-		if (*p == '\\' && *(p+1)) p++;	       /* Skip escaped chars */
+	    if (!start)
+		start = ++p;
+	    for (; *p && *p != closer; p++)
+		if (*p == '\\' && *(p + 1))
+		    p++;	/* Skip escaped chars */
 	    if (get_closing_char_too) {
 		p++;
-		if (!*p || (!strchr(bracks,*p) && strchr(delims,*p))) {
+		if (!*p || (!strchr(bracks, *p) && strchr(delims, *p))) {
 		    break;
 		} else
-		    get_closing_char_too = (BOOL) (strchr(bracks,*p) != NULL);
+		    get_closing_char_too = (BOOL) (strchr(bracks, *p) != NULL);
 	    } else
-	    break;			    /* kr95-10-9: needs to stop here */
-	} else {					      /* Spool field */
-	    if (!start) start = p;
-	    while(*p && !skipWHITE(*p) && !strchr(bracks,*p) &&
-					  !strchr(delims,*p))
+		break;		/* kr95-10-9: needs to stop here */
+	} else {		/* Spool field */
+	    if (!start)
+		start = p;
+	    while (*p && !skipWHITE(*p) && !strchr(bracks, *p) &&
+		   !strchr(delims, *p))
 		p++;
-	    if (*p && strchr(bracks,*p)) {
+	    if (*p && strchr(bracks, *p)) {
 		get_closing_char_too = TRUE;
 	    } else {
-		if (*p=='(' && skip_comments) {
+		if (*p == '(' && skip_comments) {
 		    *pstr = p;
-		    HTNextTok(pstr, NULL, "(", found);	/*	Advance pstr */
+		    HTNextTok(pstr, NULL, "(", found);	/*      Advance pstr */
 		    *p = '\0';
-		    if (*pstr && **pstr) (*pstr)++;
+		    if (*pstr && **pstr)
+			(*pstr)++;
 		    return start;
 		}
-		    break;					   /* Got it */
+		break;		/* Got it */
 	    }
 	}
     }
-    if (found) *found = *p;
+    if (found)
+	*found = *p;
 
-    if (*p) *p++ = '\0';
+    if (*p)
+	*p++ = '\0';
     *pstr = p;
     return start;
 }
 
-PRIVATE char *HTAlloc ARGS2(char *, ptr, size_t, length)
+static char *HTAlloc(char *ptr, size_t length)
 {
     if (ptr != 0)
-	ptr = (char *)realloc(ptr, length);
+	ptr = (char *) realloc(ptr, length);
     else
-	ptr = (char *)malloc(length);
+	ptr = (char *) malloc(length);
     if (ptr == 0)
 	outofmem(__FILE__, "HTAlloc");
     return ptr;
@@ -547,30 +556,36 @@
  * needed for its arguments.  Unlike sprintf, this always concatenates to the
  * destination buffer, so we do not have to provide both flavors.
  */
-typedef enum { Flags, Width, Prec, Type, Format } PRINTF;
+typedef enum {
+    Flags,
+    Width,
+    Prec,
+    Type,
+    Format
+} PRINTF;
 
 #define VA_INTGR(type) ival = va_arg((*ap), type)
 #define VA_FLOAT(type) fval = va_arg((*ap), type)
-#define VA_POINT(type) pval = (void *)va_arg((*ap), type)
+#define VA_POINT(type) pval = (char *)va_arg((*ap), type)
 
-#define NUM_WIDTH 10	/* allow for width substituted for "*" in "%*s" */
+#define NUM_WIDTH 10		/* allow for width substituted for "*" in "%*s" */
 		/* also number of chars assumed to be needed in addition
 		   to a given precision in floating point formats */
 
 #define GROW_EXPR(n) (((n) * 3) / 2)
 #define GROW_SIZE 256
 
-PUBLIC_IF_FIND_LEAKS char * StrAllocVsprintf ARGS4(
-	char **,	pstr,
-	size_t,		dst_len,
-	CONST char *,	fmt,
-	va_list *,	ap)
+PUBLIC_IF_FIND_LEAKS char *StrAllocVsprintf(char **pstr,
+					    size_t dst_len,
+					    const char *fmt,
+					    va_list * ap)
 {
 #ifdef SAVE_TIME_NOT_SPACE
     static size_t tmp_len = 0;
     static size_t fmt_len = 0;
     static char *tmp_ptr = NULL;
     static char *fmt_ptr = NULL;
+
 #else
     size_t tmp_len = GROW_SIZE;
     char *tmp_ptr = 0;
@@ -578,7 +593,7 @@
 #endif /* SAVE_TIME_NOT_SPACE */
     size_t have, need;
     char *dst_ptr = *pstr;
-    CONST char *format = fmt;
+    const char *format = fmt;
 
     if (fmt == 0 || *fmt == '\0')
 	return 0;
@@ -588,23 +603,23 @@
 	if (*pstr)
 	    FREE(*pstr);
 	if (vasprintf(pstr, fmt, *ap) >= 0) {
-	    mark_malloced(*pstr, strlen(*pstr)+1);
-	    return(*pstr);
+	    mark_malloced(*pstr, strlen(*pstr) + 1);
+	    return (*pstr);
 	}
     }
 #endif /* USE_VASPRINTF */
 
     need = strlen(fmt) + 1;
 #ifdef SAVE_TIME_NOT_SPACE
-    if (!fmt_ptr || fmt_len < need*NUM_WIDTH) {
-	fmt_ptr = HTAlloc(fmt_ptr, fmt_len = need*NUM_WIDTH);
+    if (!fmt_ptr || fmt_len < need * NUM_WIDTH) {
+	fmt_ptr = HTAlloc(fmt_ptr, fmt_len = need * NUM_WIDTH);
     }
     if (!tmp_ptr || tmp_len < GROW_SIZE) {
 	tmp_ptr = HTAlloc(tmp_ptr, tmp_len = GROW_SIZE);
     }
 #else
-    if ((fmt_ptr = malloc(need*NUM_WIDTH)) == 0
-     || (tmp_ptr = malloc(tmp_len)) == 0) {
+    if ((fmt_ptr = malloc(need * NUM_WIDTH)) == 0
+	|| (tmp_ptr = malloc(tmp_len)) == 0) {
 	outofmem(__FILE__, "StrAllocVsprintf");
     }
 #endif /* SAVE_TIME_NOT_SPACE */
@@ -622,15 +637,15 @@
 	if (*fmt == '%') {
 	    static char dummy[] = "";
 	    PRINTF state = Flags;
-	    char *pval   = dummy;	/* avoid const-cast */
-	    double fval  = 0.0;
-	    int done     = FALSE;
-	    int ival     = 0;
-	    int prec     = -1;
-	    int type     = 0;
-	    int used     = 0;
-	    int width    = -1;
-	    size_t f     = 0;
+	    char *pval = dummy;	/* avoid const-cast */
+	    double fval = 0.0;
+	    int done = FALSE;
+	    int ival = 0;
+	    int prec = -1;
+	    int type = 0;
+	    int used = 0;
+	    int width = -1;
+	    size_t f = 0;
 
 	    fmt_ptr[f++] = *fmt;
 	    while (*++fmt != '\0' && !done) {
@@ -638,6 +653,7 @@
 
 		if (isdigit(UCH(*fmt))) {
 		    int num = *fmt - '0';
+
 		    if (state == Flags && num != 0)
 			state = Width;
 		    if (state == Width) {
@@ -651,6 +667,7 @@
 		    }
 		} else if (*fmt == '*') {
 		    VA_INTGR(int);
+
 		    if (state == Flags)
 			state = Width;
 		    if (state == Width) {
@@ -663,56 +680,63 @@
 		} else if (isalpha(UCH(*fmt))) {
 		    done = TRUE;
 		    switch (*fmt) {
-		    case 'Z': /* FALLTHRU */
-		    case 'h': /* FALLTHRU */
-		    case 'l': /* FALLTHRU */
-		    case 'L': /* FALLTHRU */
+		    case 'Z':	/* FALLTHRU */
+		    case 'h':	/* FALLTHRU */
+		    case 'l':	/* FALLTHRU */
+		    case 'L':	/* FALLTHRU */
 			done = FALSE;
 			type = *fmt;
 			break;
-		    case 'o': /* FALLTHRU */
-		    case 'i': /* FALLTHRU */
-		    case 'd': /* FALLTHRU */
-		    case 'u': /* FALLTHRU */
-		    case 'x': /* FALLTHRU */
-		    case 'X': /* FALLTHRU */
+		    case 'o':	/* FALLTHRU */
+		    case 'i':	/* FALLTHRU */
+		    case 'd':	/* FALLTHRU */
+		    case 'u':	/* FALLTHRU */
+		    case 'x':	/* FALLTHRU */
+		    case 'X':	/* FALLTHRU */
 			if (type == 'l')
 			    VA_INTGR(long);
+
 			else if (type == 'Z')
 			    VA_INTGR(size_t);
 			else
 			    VA_INTGR(int);
+
 			used = 'i';
 			break;
-		    case 'f': /* FALLTHRU */
-		    case 'e': /* FALLTHRU */
-		    case 'E': /* FALLTHRU */
-		    case 'g': /* FALLTHRU */
-		    case 'G': /* FALLTHRU */
-			    VA_FLOAT(double);
+		    case 'f':	/* FALLTHRU */
+		    case 'e':	/* FALLTHRU */
+		    case 'E':	/* FALLTHRU */
+		    case 'g':	/* FALLTHRU */
+		    case 'G':	/* FALLTHRU */
+			VA_FLOAT(double);
+
 			used = 'f';
 			break;
 		    case 'c':
 			VA_INTGR(int);
+
 			used = 'c';
 			break;
 		    case 's':
 			VA_POINT(char *);
+
 			if (prec < 0)
 			    prec = strlen(pval);
 			used = 's';
 			break;
 		    case 'p':
 			VA_POINT(void *);
+
 			used = 'p';
 			break;
 		    case 'n':
 			VA_POINT(int *);
+
 			used = 0;
 			break;
 		    default:
 			CTRACE((tfp, "unknown format character '%c' in %s\n",
-				    *fmt, format));
+				*fmt, format));
 			break;
 		    }
 		} else if (*fmt == '.') {
@@ -734,7 +758,7 @@
 		    /* FALLTHRU */
 		case 'p':
 		    if (width < prec + 2)
-			width = prec + 2; /* leading sign/space/zero, "0x" */
+			width = prec + 2;	/* leading sign/space/zero, "0x" */
 		    break;
 		case 'c':
 		    break;
@@ -746,7 +770,7 @@
 		    break;
 		}
 	    }
-	    if (width >= (int)tmp_len) {
+	    if (width >= (int) tmp_len) {
 		tmp_len = GROW_EXPR(tmp_len + width);
 		tmp_ptr = HTAlloc(tmp_ptr, tmp_len);
 	    }
@@ -798,23 +822,14 @@
 #ifdef HTSprintf		/* if hidden by LYLeaks stuff */
 #undef HTSprintf
 #endif
-#if ANSI_VARARGS
-PUBLIC char * HTSprintf (char ** pstr, CONST char * fmt, ...)
-#else
-PUBLIC char * HTSprintf (va_alist)
-    va_dcl
-#endif
+char *HTSprintf(char **pstr, const char *fmt,...)
 {
     char *result = 0;
     size_t inuse = 0;
     va_list ap;
 
-    LYva_start(ap,fmt);
+    LYva_start(ap, fmt);
     {
-#if !ANSI_VARARGS
-	char **		pstr = va_arg(ap, char **);
-	CONST char *	fmt  = va_arg(ap, CONST char *);
-#endif
 	if (pstr != 0 && *pstr != 0)
 	    inuse = strlen(*pstr);
 	result = StrAllocVsprintf(pstr, inuse, fmt, &ap);
@@ -834,32 +849,23 @@
 #ifdef HTSprintf0		/* if hidden by LYLeaks stuff */
 #undef HTSprintf0
 #endif
-#if ANSI_VARARGS
-PUBLIC char * HTSprintf0 (char ** pstr, CONST char * fmt, ...)
-#else
-PUBLIC char * HTSprintf0 (va_alist)
-    va_dcl
-#endif
+char *HTSprintf0(char **pstr, const char *fmt,...)
 {
     char *result = 0;
     va_list ap;
 
-    LYva_start(ap,fmt);
+    LYva_start(ap, fmt);
     {
-#if !ANSI_VARARGS
-	char **		pstr = va_arg(ap, char **);
-	CONST char *	fmt  = va_arg(ap, CONST char *);
-#endif
 #ifdef USE_VASPRINTF
 	if (pstr) {
 	    if (*pstr)
 		FREE(*pstr);
-	    if (vasprintf(pstr, fmt, ap) >= 0) /* else call outofmem?? */
-		mark_malloced(*pstr, strlen(*pstr)+1);
+	    if (vasprintf(pstr, fmt, ap) >= 0)	/* else call outofmem?? */
+		mark_malloced(*pstr, strlen(*pstr) + 1);
 	    result = *pstr;
 	} else
 #endif /* USE_VASPRINTF */
-	result = StrAllocVsprintf(pstr, 0, fmt, &ap);
+	    result = StrAllocVsprintf(pstr, 0, fmt, &ap);
     }
     va_end(ap);
 
@@ -873,25 +879,24 @@
 #if USE_QUOTED_PARAMETER
 #define S_QUOTE '\''
 #define D_QUOTE '"'
-PUBLIC char *HTQuoteParameter ARGS1(
-    CONST char *,	parameter)
+char *HTQuoteParameter(const char *parameter)
 {
     size_t i;
     size_t last;
     size_t n = 0;
     size_t quoted = 0;
-    char * result;
+    char *result;
 
     if (parameter == 0)
 	parameter = "";
 
     last = strlen(parameter);
-    for (i=0; i < last; ++i)
+    for (i = 0; i < last; ++i)
 	if (strchr("\\&#$^*?(){}<>\"';`|", parameter[i]) != 0
-	 || isspace(UCH(parameter[i])))
+	    || isspace(UCH(parameter[i])))
 	    ++quoted;
 
-    result = (char *)malloc(last + 5*quoted + 3);
+    result = (char *) malloc(last + 5 * quoted + 3);
     if (result == NULL)
 	outofmem(__FILE__, "HTQuoteParameter");
 
@@ -912,7 +917,7 @@
 	       and compatible shells, so trying to escape a backslash by
 	       doubling it is unnecessary and would be interpreted by the
 	       shell as an additional data character. - kw 2000-05-02
-	       */
+	     */
 	    result[n++] = parameter[i];
 	}
     }
@@ -928,10 +933,10 @@
 /*
  * Returns the number of "%s" tokens in a system command-template.
  */
-PUBLIC int HTCountCommandArgs ARGS1(
-    CONST char *,	command)
+int HTCountCommandArgs(const char *command)
 {
     int number = 0;
+
     while (command[0] != 0) {
 	if (HTIsParam(command))
 	    number++;
@@ -943,9 +948,8 @@
 /*
  * Returns a pointer into the given string after the given parameter number
  */
-PRIVATE CONST char *HTAfterCommandArg ARGS2(
-    CONST char *,	command,
-    int,		number)
+static const char *HTAfterCommandArg(const char *command,
+				     int number)
 {
     while (number > 0) {
 	if (command[0] != 0) {
@@ -972,15 +976,14 @@
  * This is useful only when we quote parameters, of course.
  */
 #if USE_QUOTED_PARAMETER
-PUBLIC void HTAddXpand ARGS4(
-    char **,		result,
-    CONST char *,	command,
-    int,		number,
-    CONST char *,	parameter)
+void HTAddXpand(char **result,
+		const char *command,
+		int number,
+		const char *parameter)
 {
     if (number > 0) {
-	CONST char *last = HTAfterCommandArg(command, number - 1);
-	CONST char *next = last;
+	const char *last = HTAfterCommandArg(command, number - 1);
+	const char *next = last;
 
 	if (number <= 1) {
 	    FREE(*result);
@@ -990,7 +993,8 @@
 	    if (HTIsParam(next)) {
 		if (next != last) {
 		    size_t len = (next - last)
-				+ ((*result != 0) ? strlen(*result) : 0);
+		    + ((*result != 0) ? strlen(*result) : 0);
+
 		    HTSACat(result, last);
 		    (*result)[len] = 0;
 		}
@@ -1014,15 +1018,14 @@
  * Parameters are substituted at "%s" tokens, like printf.  Other printf-style
  * tokens are not substituted; they are passed through without change.
  */
-PUBLIC void HTAddToCmd ARGS4(
-    char **,		result,
-    CONST char *,	command,
-    int,		number,
-    CONST char *,	string)
+void HTAddToCmd(char **result,
+		const char *command,
+		int number,
+		const char *string)
 {
     if (number > 0) {
-	CONST char *last = HTAfterCommandArg(command, number - 1);
-	CONST char *next = last;
+	const char *last = HTAfterCommandArg(command, number - 1);
+	const char *next = last;
 
 	if (number <= 1) {
 	    FREE(*result);
@@ -1033,7 +1036,8 @@
 	    if (HTIsParam(next)) {
 		if (next != last) {
 		    size_t len = (next - last)
-				+ ((*result != 0) ? strlen(*result) : 0);
+		    + ((*result != 0) ? strlen(*result) : 0);
+
 		    HTSACat(result, last);
 		    (*result)[len] = 0;
 		}
@@ -1051,15 +1055,15 @@
  * string is a complete parameter (which is a necessary assumption so we can
  * quote it properly).
  */
-PUBLIC void HTAddParam ARGS4(
-    char **,		result,
-    CONST char *,	command,
-    int,		number,
-    CONST char *,	parameter)
+void HTAddParam(char **result,
+		const char *command,
+		int number,
+		const char *parameter)
 {
     if (number > 0) {
 #if USE_QUOTED_PARAMETER
 	char *quoted = HTQuoteParameter(parameter);
+
 	HTAddToCmd(result, command, number, quoted);
 	FREE(quoted);
 #else
@@ -1072,15 +1076,14 @@
  * Append the remaining command-string to a system command (compare with
  * HTAddParam).  Any remaining "%s" tokens are copied as empty strings.
  */
-PUBLIC void HTEndParam ARGS3(
-    char **,		result,
-    CONST char *,	command,
-    int,		number)
+void HTEndParam(char **result,
+		const char *command,
+		int number)
 {
-    CONST char *last;
+    const char *last;
     int count;
 
-    count = HTCountCommandArgs (command);
+    count = HTCountCommandArgs(command);
     if (count < number)
 	number = count;
     last = HTAfterCommandArg(command, number);
@@ -1090,17 +1093,14 @@
     CTRACE((tfp, "PARAM-END:%s\n", *result));
 }
 
-
-/*	Binary-strings (may have embedded nulls).
- *	Some modules (HTGopher) assume there is a null on the end, anyway.
+/* Binary-strings (may have embedded nulls).  Some modules (HTGopher) assume
+ * there is a null on the end, anyway.
  */
 
-/*	Allocate a new bstring, and return it.
+/* Allocate a new bstring, and return it.
 */
-PUBLIC void HTSABCopy ARGS3(
-	bstring**,	dest,
-	CONST char *,	src,
-	int,		len)
+void HTSABCopy(bstring **dest, const char *src,
+	       int len)
 {
     bstring *t;
     unsigned need = len + 1;
@@ -1113,11 +1113,12 @@
 	    trace_bstring2(src, len);
 	    CTRACE((tfp, "\n"));
 	}
-	if ((t = (bstring*) malloc(sizeof(bstring))) == NULL)
-	    outofmem(__FILE__, "HTSABCopy");
-	if ((t->str = (char *) malloc (need)) == NULL)
+	if ((t = (bstring *) malloc(sizeof(bstring))) == NULL)
+	      outofmem(__FILE__, "HTSABCopy");
+
+	if ((t->str = (char *) malloc(need)) == NULL)
 	    outofmem(__FILE__, "HTSABCopy");
-	memcpy (t->str, src, len);
+	memcpy(t->str, src, len);
 	t->len = len;
 	t->str[t->len] = '\0';
 	*dest = t;
@@ -1132,9 +1133,7 @@
 /*
  * Initialize with a null-terminated string (discards the null).
  */
-PUBLIC void HTSABCopy0 ARGS2(
-	bstring**,	dest,
-	CONST char *,	src)
+void HTSABCopy0(bstring **dest, const char *src)
 {
     HTSABCopy(dest, src, strlen(src));
 }
@@ -1142,10 +1141,8 @@
 /*
  * Append a block of memory to a bstring.
  */
-PUBLIC void HTSABCat ARGS3(
-	bstring **,	dest,
-	CONST char *,	src,
-	int,		len)
+void HTSABCat(bstring **dest, const char *src,
+	      int len)
 {
     bstring *t = *dest;
 
@@ -1160,16 +1157,18 @@
 	}
 	if (t) {
 	    unsigned length = t->len + need;
-	    if ((t->str = (char *)realloc(t->str, length)) == NULL)
+
+	    if ((t->str = (char *) realloc(t->str, length)) == NULL)
 		outofmem(__FILE__, "HTSACat");
 	} else {
 	    if ((t = typecalloc(bstring)) == NULL)
-		outofmem(__FILE__, "HTSACat");
-	    t->str = (char *)malloc(need);
+		  outofmem(__FILE__, "HTSACat");
+
+	    t->str = (char *) malloc(need);
 	}
 	if (t->str == NULL)
 	    outofmem(__FILE__, "HTSACat");
-	memcpy (t->str + t->len, src, len);
+	memcpy(t->str + t->len, src, len);
 	t->len += len;
 	t->str[t->len] = '\0';
 	*dest = t;
@@ -1184,9 +1183,7 @@
 /*
  * Append a null-terminated string (discards the null).
  */
-PUBLIC void HTSABCat0 ARGS2(
-	bstring**,	dest,
-	CONST char *,	src)
+void HTSABCat0(bstring **dest, const char *src)
 {
     HTSABCat(dest, src, strlen(src));
 }
@@ -1194,16 +1191,14 @@
 /*
  * Compare two bstring's for equality
  */
-PUBLIC BOOL HTSABEql   ARGS2(
-	bstring *,	a,
-	bstring *,	b)
+BOOL HTSABEql(bstring *a, bstring *b)
 {
     unsigned len_a = (a != 0) ? a->len : 0;
     unsigned len_b = (b != 0) ? b->len : 0;
 
     if (len_a == len_b) {
 	if (len_a == 0
-	 || memcmp(a->str, b->str, a->len) == 0)
+	    || memcmp(a->str, b->str, a->len) == 0)
 	    return TRUE;
     }
     return FALSE;
@@ -1212,8 +1207,7 @@
 /*
  * Deallocate a bstring.
  */
-PUBLIC void HTSABFree ARGS1(
-	bstring **,	ptr)
+void HTSABFree(bstring **ptr)
 {
     if (*ptr != NULL) {
 	FREE((*ptr)->str);
@@ -1226,26 +1220,17 @@
  * Use this function to perform formatted sprintf's onto the end of a bstring.
  * The bstring may contain embedded nulls; the formatted portions must not.
  */
-#ifdef ANSI_VARARGS
-PUBLIC bstring * HTBprintf (bstring ** pstr, CONST char * fmt, ...)
-#else
-PUBLIC bstring * HTBprintf (va_alist)
-    va_dcl
-#endif
+bstring *HTBprintf(bstring **pstr, const char *fmt,...)
 {
     bstring *result = 0;
     char *temp = 0;
     va_list ap;
 
-    LYva_start(ap,fmt);
+    LYva_start(ap, fmt);
     {
-#if !ANSI_VARARGS
-	bstring **	pstr = va_arg(ap, char **);
-	CONST char *	fmt  = va_arg(ap, CONST char *);
-#endif
 	temp = StrAllocVsprintf(&temp, 0, fmt, &ap);
 	if (!isEmpty(temp)) {
-	    HTSABCat (pstr, temp, strlen(temp));
+	    HTSABCat(pstr, temp, strlen(temp));
 	}
 	FREE(temp);
 	result = *pstr;
@@ -1260,15 +1245,15 @@
  * That is most, since we do not restrict line-length.  Nulls and other
  * non-printing characters are addressed.
  */
-PUBLIC void trace_bstring2 ARGS2(
-	CONST char *,	text,
-	int,		size)
+void trace_bstring2(const char *text,
+		    int size)
 {
     int n;
 
     if (text != 0) {
 	for (n = 0; n < size; ++n) {
 	    int ch = UCH(text[n]);
+
 	    switch (ch) {
 	    case '\\':
 		fputs("\\\\", tfp);
@@ -1294,8 +1279,7 @@
     }
 }
 
-PUBLIC void trace_bstring ARGS1(
-	bstring *,	data)
+void trace_bstring(bstring *data)
 {
     trace_bstring2(BStrData(data), BStrLen(data));
 }
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/HTList.c
+++ lynx-cur-2.8.6/WWW/Library/Implementation/HTList.c
@@ -1,10 +1,10 @@
 /*	A small List class					      HTList.c
-**	==================
-**
-**	A list is represented as a sequence of linked nodes of type HTList.
-**	The first node is a header which contains no object.
-**	New nodes are inserted between the header and the rest of the list.
-*/
+ *	==================
+ *
+ *	A list is represented as a sequence of linked nodes of type HTList.
+ *	The first node is a header which contains no object.
+ *	New nodes are inserted between the header and the rest of the list.
+ */
 
 #include <HTUtils.h>
 #include <HTList.h>
@@ -13,12 +13,12 @@
 
 /*	Create list.
 */
-PUBLIC HTList * HTList_new NOARGS
+HTList *HTList_new(void)
 {
     HTList *newList;
 
     if ((newList = typeMalloc(HTList)) == NULL)
-	outofmem(__FILE__, "HTList_new");
+	  outofmem(__FILE__, "HTList_new");
 
     newList->object = NULL;
     newList->next = NULL;
@@ -26,17 +26,15 @@
     return newList;
 }
 
-
 /*	Delete list.
 */
-PUBLIC void HTList_delete ARGS1(
-	HTList *,	me)
+void HTList_delete(HTList *me)
 {
     HTList *current;
 
     while ((current = me)) {
-      me = me->next;
-      FREE (current);
+	me = me->next;
+	FREE(current);
     }
 
     return;
@@ -44,10 +42,10 @@
 
 /*	Reverse order of elements in list.
  */
-PUBLIC HTList * HTList_reverse ARGS1(
-    HTList *,		start)
+HTList *HTList_reverse(HTList *start)
 {
     HTList *cur, *succ;
+
     if (!(start && start->next && (cur = start->next->next)))
 	return start;
     start->next->next = NULL;
@@ -64,15 +62,15 @@
  *
  *	If successful, the second list will become empty but not freed.
  */
-PUBLIC HTList * HTList_appendList ARGS2(
-    HTList *,		start,
-    HTList *,		tail)
+HTList *HTList_appendList(HTList *start,
+			  HTList *tail)
 {
-    HTList * temp = start;
+    HTList *temp = start;
 
     if (!start) {
-	CTRACE((tfp, "HTList: Trying to append list %p to a nonexisting list\n",
-		    tail));
+	CTRACE((tfp,
+		"HTList: Trying to append list %p to a nonexisting list\n",
+		tail));
 	return NULL;
     }
     if (!(tail && tail->next))
@@ -86,17 +84,14 @@
     return start;
 }
 
-
 /*	Link object to START of list (so it is pointed to by the head).
  *
  *	Unlike HTList_addObject(), it does not malloc memory for HTList entry,
  *	it use already allocated memory which should not be free'd by any
  *	list operations (optimization).
  */
-PUBLIC void HTList_linkObject ARGS3(
-	HTList *,	me,
-	void *,		newObject,
-	HTList *,	newNode)
+void HTList_linkObject(HTList *me, void *newObject,
+		       HTList *newNode)
 {
     if (me) {
 	if (newNode->object == NULL && newNode->next == NULL) {
@@ -107,52 +102,48 @@
 
 	} else {
 	    /*
-	     *  This node is already linked to some list (probably this one),
-	     *  so refuse changing node pointers to keep the list valid!!!
+	     * This node is already linked to some list (probably this one), so
+	     * refuse changing node pointers to keep the list valid!!!
 	     */
 	    CTRACE((tfp, "*** HTList: Refuse linking already linked obj "));
 	    CTRACE((tfp, "%p, node %p, list %p\n",
-			newObject, newNode, me));
+		    newObject, newNode, me));
 	}
 
     } else {
-	CTRACE((tfp, "HTList: Trying to link object %p to a nonexisting list\n",
-		    newObject));
+	CTRACE((tfp,
+		"HTList: Trying to link object %p to a nonexisting list\n",
+		newObject));
     }
 
     return;
 }
 
-
 /*      Add object to START of list (so it is pointed to by the head).
 */
-PUBLIC void HTList_addObject ARGS2(
-	HTList *,	me,
-	void *,		newObject)
+void HTList_addObject(HTList *me, void *newObject)
 {
     HTList *newNode;
 
     if (me) {
 	if ((newNode = typeMalloc(HTList)) == NULL)
-	    outofmem(__FILE__, "HTList_addObject");
+	      outofmem(__FILE__, "HTList_addObject");
+
 	newNode->object = newObject;
 	newNode->next = me->next;
 	me->next = newNode;
 
     } else {
 	CTRACE((tfp, "HTList: Trying to add object %p to a nonexisting list\n",
-		    newObject));
+		newObject));
     }
 
     return;
 }
 
-
 /*      Append object to END of list (furthest from the head).
 */
-PUBLIC void HTList_appendObject ARGS2(
-	HTList *,	me,
-	void *,		newObject)
+void HTList_appendObject(HTList *me, void *newObject)
 {
     HTList *temp = me;
 
@@ -165,37 +156,35 @@
     return;
 }
 
-
 /*	Insert an object into the list at a specified position.
-**      If position is 0, this places the object at the head of the list
-**      and is equivalent to HTList_addObject().
-*/
-PUBLIC void HTList_insertObjectAt ARGS3(
-	HTList *,	me,
-	void *,		newObject,
-	int,		pos)
-{
-    HTList * newNode;
-    HTList * temp = me;
-    HTList * prevNode;
+ *      If position is 0, this places the object at the head of the list
+ *      and is equivalent to HTList_addObject().
+ */
+void HTList_insertObjectAt(HTList *me, void *newObject,
+			   int pos)
+{
+    HTList *newNode;
+    HTList *temp = me;
+    HTList *prevNode;
     int Pos = pos;
 
     if (!temp) {
 	CTRACE((tfp, "HTList: Trying to add object %p to a nonexisting list\n",
-		    newObject));
+		newObject));
 	return;
     }
     if (Pos < 0) {
 	Pos = 0;
 	CTRACE((tfp, "HTList: Treating negative object position %d as %d.\n",
-		    pos, Pos));
+		pos, Pos));
     }
 
     prevNode = temp;
     while ((temp = temp->next)) {
 	if (Pos == 0) {
 	    if ((newNode = typeMalloc(HTList)) == NULL)
-		outofmem(__FILE__, "HTList_addObjectAt");
+		  outofmem(__FILE__, "HTList_addObjectAt");
+
 	    newNode->object = newObject;
 	    newNode->next = temp;
 	    if (prevNode)
@@ -211,13 +200,10 @@
     return;
 }
 
-
 /*	Unlink specified object from list.
  *	It does not free memory.
  */
-PUBLIC BOOL HTList_unlinkObject ARGS2(
-	HTList *,	me,
-	void *,		oldObject)
+BOOL HTList_unlinkObject(HTList *me, void *oldObject)
 {
     HTList *temp = me;
     HTList *prevNode;
@@ -230,19 +216,16 @@
 		prevNode->next = temp->next;
 		temp->next = NULL;
 		temp->object = NULL;
-		return YES;  /* Success */
+		return YES;	/* Success */
 	    }
 	}
     }
-    return NO;  /* object not found or NULL list */
+    return NO;			/* object not found or NULL list */
 }
 
-
 /*	Remove specified object from list.
 */
-PUBLIC BOOL HTList_removeObject ARGS2(
-	HTList *,	me,
-	void *,		oldObject)
+BOOL HTList_removeObject(HTList *me, void *oldObject)
 {
     HTList *temp = me;
     HTList *prevNode;
@@ -253,26 +236,23 @@
 	    temp = temp->next;
 	    if (temp->object == oldObject) {
 		prevNode->next = temp->next;
-		FREE (temp);
-		return YES;  /* Success */
+		FREE(temp);
+		return YES;	/* Success */
 	    }
 	}
     }
-    return NO;  /* object not found or NULL list */
+    return NO;			/* object not found or NULL list */
 }
 
-
 /*	Remove object at a given position in the list, where 0 is the
-**	object pointed to by the head (returns a pointer to the element
-**	(->object) for the object, and NULL if the list is empty, or
-**	if it doesn't exist - Yuk!).
-*/
-PUBLIC void * HTList_removeObjectAt  ARGS2(
-	HTList *,	me,
-	int,		position)
+ *	object pointed to by the head (returns a pointer to the element
+ *	(->object) for the object, and NULL if the list is empty, or
+ *	if it doesn't exist - Yuk!).
+ */
+void *HTList_removeObjectAt(HTList *me, int position)
 {
-    HTList * temp = me;
-    HTList * prevNode;
+    HTList *temp = me;
+    HTList *prevNode;
     int pos = position;
 
     if (!temp || pos < 0)
@@ -290,18 +270,17 @@
 	pos--;
     }
 
-    return NULL;  /* Reached the end of the list */
+    return NULL;		/* Reached the end of the list */
 }
 
 /*	Unlink object from START of list (the Last one inserted
  *	via HTList_linkObject(), and pointed to by the head).
  *	It does not free memory.
  */
-PUBLIC void * HTList_unlinkLastObject ARGS1(
-	HTList *,	me)
+void *HTList_unlinkLastObject(HTList *me)
 {
-    HTList * lastNode;
-    void * lastObject;
+    HTList *lastNode;
+    void *lastObject;
 
     if (me && me->next) {
 	lastNode = me->next;
@@ -311,42 +290,38 @@
 	lastNode->object = NULL;
 	return lastObject;
 
-    } else {  /* Empty list */
+    } else {			/* Empty list */
 	return NULL;
     }
 }
 
-
 /*	Remove object from START of list (the Last one inserted
-**	via HTList_addObject(), and pointed to by the head).
-*/
-PUBLIC void * HTList_removeLastObject ARGS1(
-	HTList *,	me)
+ *	via HTList_addObject(), and pointed to by the head).
+ */
+void *HTList_removeLastObject(HTList *me)
 {
-    HTList * lastNode;
-    void * lastObject;
+    HTList *lastNode;
+    void *lastObject;
 
     if (me && me->next) {
 	lastNode = me->next;
 	lastObject = lastNode->object;
 	me->next = lastNode->next;
-	FREE (lastNode);
+	FREE(lastNode);
 	return lastObject;
 
-    } else {  /* Empty list */
+    } else {			/* Empty list */
 	return NULL;
     }
 }
 
-
 /*	Remove object from END of list (the First one inserted
-**	via HTList_addObject(), and furthest from the head).
-*/
-PUBLIC void * HTList_removeFirstObject ARGS1(
-	HTList *,	me)
+ *	via HTList_addObject(), and furthest from the head).
+ */
+void *HTList_removeFirstObject(HTList *me)
 {
-    HTList * temp = me;
-    HTList * prevNode;
+    HTList *temp = me;
+    HTList *prevNode;
     void *firstObject;
 
     if (!temp)
@@ -360,22 +335,20 @@
 	}
 	firstObject = temp->object;
 	prevNode->next = NULL;
-	FREE (temp);
+	FREE(temp);
 	return firstObject;
 
-    } else {  /* Empty list */
+    } else {			/* Empty list */
 	return NULL;
     }
 }
 
-
 /*	Determine total number of objects in the list,
-**	not counting the head.
-*/
-PUBLIC int HTList_count ARGS1(
-	HTList *,	me)
+ *	not counting the head.
+ */
+int HTList_count(HTList *me)
 {
-    HTList * temp = me;
+    HTList *temp = me;
     int count = 0;
 
     if (temp)
@@ -385,15 +358,12 @@
     return count;
 }
 
-
 /*	Determine position of an object in the list (a value of 0
-**	means it is pointed to by the head; returns -1 if not found).
-*/
-PUBLIC int HTList_indexOf ARGS2(
-	HTList *,	me,
-	void *,		object)
+ *	means it is pointed to by the head; returns -1 if not found).
+ */
+int HTList_indexOf(HTList *me, void *object)
 {
-    HTList * temp = me;
+    HTList *temp = me;
     int position = 0;
 
     if (temp) {
@@ -404,19 +374,16 @@
 	}
     }
 
-    return -1;	/* Object not in the list */
+    return -1;			/* Object not in the list */
 }
 
-
 /*	Return pointer to the object at a specified position in the list,
-**	where 0 is the object pointed to by the head (returns NULL if
-**	the list is empty, or if it doesn't exist - Yuk!).
-*/
-PUBLIC void * HTList_objectAt ARGS2(
-	HTList *,	me,
-	int,		position)
+ *	where 0 is the object pointed to by the head (returns NULL if
+ *	the list is empty, or if it doesn't exist - Yuk!).
+ */
+void *HTList_objectAt(HTList *me, int position)
 {
-    HTList * temp = me;
+    HTList *temp = me;
     int pos = position;
 
     if (!temp || pos < 0)
@@ -428,5 +395,5 @@
 	pos--;
     }
 
-    return NULL;	/* Reached the end of the list */
+    return NULL;		/* Reached the end of the list */
 }
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/HTStyle.c
+++ lynx-cur-2.8.6/WWW/Library/Implementation/HTStyle.c
@@ -1,13 +1,13 @@
 /*	Style Implementation for Hypertext			HTStyle.c
-**	==================================
-**
-**	Styles allow the translation between a logical property
-**	of a piece of text and its physical representation.
-**
-**	A StyleSheet is a collection of styles, defining the
-**	translation necessary to
-**	represent a document.  It is a linked list of styles.
-*/
+ *	==================================
+ *
+ *	Styles allow the translation between a logical property
+ *	of a piece of text and its physical representation.
+ *
+ *	A StyleSheet is a collection of styles, defining the
+ *	translation necessary to
+ *	represent a document.  It is a linked list of styles.
+ */
 
 #include <HTUtils.h>
 #include <HTStyle.h>
@@ -16,9 +16,10 @@
 
 /*	Create a new style
 */
-PUBLIC HTStyle* HTStyleNew NOARGS
+HTStyle *HTStyleNew(void)
 {
-    HTStyle * self = typecalloc(HTStyle);
+    HTStyle *self = typecalloc(HTStyle);
+
     if (self == NULL)
 	outofmem(__FILE__, "HTStyleNew");
     return self;
@@ -26,18 +27,18 @@
 
 /*	Create a new style with a name
 */
-PUBLIC HTStyle* HTStyleNewNamed ARGS1 (CONST char *,name)
+HTStyle *HTStyleNewNamed(const char *name)
 {
-    HTStyle * self = HTStyleNew();
+    HTStyle *self = HTStyleNew();
+
     StrAllocCopy(self->name, name);
-    self->id = -1; /* <0 */
+    self->id = -1;		/* <0 */
     return self;
 }
 
-
 /*	Free a style
 */
-PUBLIC HTStyle * HTStyleFree ARGS1 (HTStyle *,self)
+HTStyle *HTStyleFree(HTStyle *self)
 {
     FREE(self->name);
     FREE(self->SGMLTag);
@@ -45,18 +46,17 @@
     return NULL;
 }
 
-
-#ifdef SUPPRESS  /* Only on the NeXT */
+#ifdef SUPPRESS			/* Only on the NeXT */
 /*	Read a style from a stream	(without its name)
-**	--------------------------
-**
-**	Reads a style with paragraph information from a stream.
-**	The style name is not read or written by these routines.
-*/
+ *	--------------------------
+ *
+ *	Reads a style with paragraph information from a stream.
+ *	The style name is not read or written by these routines.
+ */
 #define NONE_STRING "(None)"
 #define HTStream NXStream
 
-HTStyle * HTStyleRead (HTStyle * style, HTStream * stream)
+HTStyle *HTStyleRead(HTStyle *style, HTStream *stream)
 {
     char myTag[STYLE_NAME_LENGTH];
     char fontName[STYLE_NAME_LENGTH];
@@ -65,10 +65,10 @@
     int gotpara;		/* flag: have we got a paragraph definition? */
 
     NXScanf(stream, "%s%s%f%d",
-	myTag,
-	fontName,
-	&style->fontSize,
-	&gotpara);
+	    myTag,
+	    fontName,
+	    &style->fontSize,
+	    &gotpara);
     if (gotpara) {
 	if (!style->paragraph) {
 	    style->paragraph = malloc(sizeof(*(style->paragraph)));
@@ -78,201 +78,212 @@
 	}
 	p = style->paragraph;
 	NXScanf(stream, "%f%f%f%f%hd%f%f%hd",
-	    &p->indent1st,
-	    &p->indent2nd,
-	    &p->lineHt,
-	    &p->descentLine,
-	    &p->alignment,
-	    &style->spaceBefore,
-	    &style->spaceAfter,
-	    &p->numTabs);
+		&p->indent1st,
+		&p->indent2nd,
+		&p->lineHt,
+		&p->descentLine,
+		&p->alignment,
+		&style->spaceBefore,
+		&style->spaceAfter,
+		&p->numTabs);
 	FREE(p->tabs);
 	p->tabs = malloc(p->numTabs * sizeof(p->tabs[0]));
 	if (!p->tabs)
 	    outofmem(__FILE__, "HTStyleRead");
-	for (tab=0; tab < p->numTabs; tab++) {
+	for (tab = 0; tab < p->numTabs; tab++) {
 	    NXScanf(stream, "%hd%f",
 		    &p->tabs[tab].kind,
 		    &p->tabs[tab].x);
 	}
-    } else { /* No paragraph */
+    } else {			/* No paragraph */
 	FREE(style->paragraph);
-    } /* if no paragraph */
+    }				/* if no paragraph */
     StrAllocCopy(style->SGMLTag, myTag);
-    if (strcmp(fontName, NONE_STRING)==0)
+    if (strcmp(fontName, NONE_STRING) == 0)
 	style->font = 0;
     else
-	style->font = [Font newFont:fontName size:style->fontSize];
+      style->font =[Font newFont: fontName size:style->fontSize];
     return NULL;
 }
 
-
 /*	Write a style to a stream in a compatible way
 */
-HTStyle * HTStyleWrite (HTStyle * style, NXStream * stream)
+HTStyle *HTStyleWrite(HTStyle *style, NXStream * stream)
 {
     int tab;
     NXTextStyle *p = style->paragraph;
+
     NXPrintf(stream, "%s %s %f %d\n",
-	style->SGMLTag,
-	style->font ? [style->font name] : NONE_STRING,
-	style->fontSize,
-	p!=0);
+	     style->SGMLTag,
+	     style->font ?[style->font name] : NONE_STRING,
+	     style->fontSize,
+	     p != 0);
 
     if (p) {
 	NXPrintf(stream, "\t%f %f %f %f %d %f %f\t%d\n",
-	    p->indent1st,
-	    p->indent2nd,
-	    p->lineHt,
-	    p->descentLine,
-	    p->alignment,
-	    style->spaceBefore,
-	    style->spaceAfter,
-	    p->numTabs);
+		 p->indent1st,
+		 p->indent2nd,
+		 p->lineHt,
+		 p->descentLine,
+		 p->alignment,
+		 style->spaceBefore,
+		 style->spaceAfter,
+		 p->numTabs);
 
-	for (tab=0; tab < p->numTabs; tab++)
+	for (tab = 0; tab < p->numTabs; tab++)
 	    NXPrintf(stream, "\t%d %f\n",
-		    p->tabs[tab].kind,
-		    p->tabs[tab].x);
-	}
+		     p->tabs[tab].kind,
+		     p->tabs[tab].x);
+    }
     return style;
 }
 
-
 /*	Write a style to stdout for diagnostics
 */
-HTStyle * HTStyleDump (HTStyle * style)
+HTStyle *HTStyleDump(HTStyle *style)
 {
     int tab;
     NXTextStyle *p = style->paragraph;
+
     printf(STYLE_DUMP_FONT,
-	style,
-	style->name,
-	style->SGMLTag,
-	[style->font name],
-	style->fontSize);
+	   style,
+	   style->name,
+	   style->SGMLTag,
+	   [style->font name],
+	   style->fontSize);
     if (p) {
 	printf(STYLE_DUMP_IDENT,
-	    p->indent1st,
-	    p->indent2nd,
-	    p->lineHt,
-	    p->descentLine);
+	       p->indent1st,
+	       p->indent2nd,
+	       p->lineHt,
+	       p->descentLine);
 	printf(STYLE_DUMP_ALIGN,
-	    p->alignment,
-	    p->numTabs,
-	    style->spaceBefore,
-	    style->spaceAfter);
+	       p->alignment,
+	       p->numTabs,
+	       style->spaceBefore,
+	       style->spaceAfter);
 
-	for (tab=0; tab < p->numTabs; tab++) {
+	for (tab = 0; tab < p->numTabs; tab++) {
 	    printf(STYLE_DUMP_TAB,
-		    p->tabs[tab].kind,
-		    p->tabs[tab].x);
+		   p->tabs[tab].kind,
+		   p->tabs[tab].x);
 	}
 	printf("\n");
-    } /* if paragraph */
+    }				/* if paragraph */
     return style;
 }
 #endif /* SUPPRESS */
 
-
 /*			StyleSheet Functions
-**			====================
-*/
+ *			====================
+ */
 
 /*	Searching for styles:
 */
-HTStyle * HTStyleNamed ARGS2 (HTStyleSheet *,self, CONST char *,name)
+HTStyle *HTStyleNamed(HTStyleSheet *self, const char *name)
 {
-    HTStyle * scan;
-    for (scan=self->styles; scan; scan=scan->next)
-	if (0==strcmp(scan->name, name)) return scan;
+    HTStyle *scan;
+
+    for (scan = self->styles; scan; scan = scan->next)
+	if (0 == strcmp(scan->name, name))
+	    return scan;
     CTRACE((tfp, "StyleSheet: No style named `%s'\n", name));
     return NULL;
 }
 
 #ifdef NEXT_SUPRESS		/* Not in general common code */
 
-HTStyle * HTStyleMatching (HTStyleSheet * self, HTStyle *style)
+HTStyle *HTStyleMatching(HTStyleSheet *self, HTStyle *style)
 {
-    HTStyle * scan;
-    for (scan=self->styles; scan; scan=scan->next)
-	if (scan->paragraph == para) return scan;
+    HTStyle *scan;
+
+    for (scan = self->styles; scan; scan = scan->next)
+	if (scan->paragraph == para)
+	    return scan;
     return NULL;
 }
 
 /*	Find the style which best fits a given run
-**	------------------------------------------
-**
-**	This heuristic is used for guessing the style for a run of
-**	text which has been pasted in.  In order, we try:
-**
-**	A style whose paragraph structure is actually used by the run.
-**	A style matching in font
-**	A style matching in paragraph style exactly
-**	A style matching in paragraph to a degree
-*/
+ *	------------------------------------------
+ *
+ *	This heuristic is used for guessing the style for a run of
+ *	text which has been pasted in.  In order, we try:
+ *
+ *	A style whose paragraph structure is actually used by the run.
+ *	A style matching in font
+ *	A style matching in paragraph style exactly
+ *	A style matching in paragraph to a degree
+ */
 
-HTStyle * HTStyleForRun (HTStyleSheet *self, NXRun *run)
+HTStyle *HTStyleForRun(HTStyleSheet *self, NXRun * run)
 {
-    HTStyle * scan;
-    HTStyle * best = 0;
+    HTStyle *scan;
+    HTStyle *best = 0;
     int bestMatch = 0;
-    NXTextStyle * rp = run->paraStyle;
-    for (scan=self->styles; scan; scan=scan->next)
-	if (scan->paragraph == run->paraStyle) return scan;	/* Exact */
+    NXTextStyle *rp = run->paraStyle;
+
+    for (scan = self->styles; scan; scan = scan->next)
+	if (scan->paragraph == run->paraStyle)
+	    return scan;	/* Exact */
+
+    for (scan = self->styles; scan; scan = scan->next) {
+	NXTextStyle *sp = scan->paragraph;
 
-    for (scan=self->styles; scan; scan=scan->next){
-	NXTextStyle * sp = scan->paragraph;
 	if (sp) {
 	    int match = 0;
-	    if (sp->indent1st ==	rp->indent1st)	match = match+1;
-	    if (sp->indent2nd ==	rp->indent2nd)	match = match+2;
-	    if (sp->lineHt ==		rp->lineHt)	match = match+1;
-	    if (sp->numTabs ==		rp->numTabs)	match = match+1;
-	    if (sp->alignment ==	rp->alignment)	match = match+3;
-	    if (scan->font ==		run->font)	match = match+10;
-	    if (match>bestMatch) {
-		    best=scan;
-		    bestMatch=match;
+
+	    if (sp->indent1st == rp->indent1st)
+		match = match + 1;
+	    if (sp->indent2nd == rp->indent2nd)
+		match = match + 2;
+	    if (sp->lineHt == rp->lineHt)
+		match = match + 1;
+	    if (sp->numTabs == rp->numTabs)
+		match = match + 1;
+	    if (sp->alignment == rp->alignment)
+		match = match + 3;
+	    if (scan->font == run->font)
+		match = match + 10;
+	    if (match > bestMatch) {
+		best = scan;
+		bestMatch = match;
 	    }
 	}
     }
     CTRACE((tfp, "HTStyleForRun: Best match for style is %d out of 18\n",
-		 bestMatch));
+	    bestMatch));
     return best;
 }
 #endif /* NEXT_SUPRESS */
 
-
 /*	Add a style to a sheet
-**	----------------------
-*/
-HTStyleSheet * HTStyleSheetAddStyle ARGS2
-  (HTStyleSheet *,self, HTStyle *,style)
+ *	----------------------
+ */
+HTStyleSheet *HTStyleSheetAddStyle(HTStyleSheet *self, HTStyle *style)
 {
     style->next = 0;		/* The style will go on the end */
     if (!self->styles) {
 	self->styles = style;
     } else {
-	HTStyle * scan;
-	for(scan=self->styles; scan->next; scan=scan->next); /* Find end */
-	scan->next=style;
+	HTStyle *scan;
+
+	for (scan = self->styles; scan->next; scan = scan->next) ;	/* Find end */
+	scan->next = style;
     }
     return self;
 }
 
-
 /*	Remove the given object from a style sheet if it exists
 */
-HTStyleSheet * HTStyleSheetRemoveStyle ARGS2
-  (HTStyleSheet *,self, HTStyle *,style)
+HTStyleSheet *HTStyleSheetRemoveStyle(HTStyleSheet *self, HTStyle *style)
 {
     if (self->styles == style) {
 	self->styles = style->next;
 	return self;
     } else {
-	HTStyle * scan;
-	for(scan = self->styles; scan; scan = scan->next) {
+	HTStyle *scan;
+
+	for (scan = self->styles; scan; scan = scan->next) {
 	    if (scan->next == style) {
 		scan->next = style->next;
 		return self;
@@ -285,21 +296,22 @@
 /*	Create new style sheet
 */
 
-HTStyleSheet * HTStyleSheetNew NOARGS
+HTStyleSheet *HTStyleSheetNew(void)
 {
-    HTStyleSheet * self = typecalloc(HTStyleSheet);
+    HTStyleSheet *self = typecalloc(HTStyleSheet);
+
     if (self == NULL)
 	outofmem(__FILE__, "HTStyleSheetNew");
     return self;
 }
 
-
 /*	Free off a style sheet pointer
 */
-HTStyleSheet * HTStyleSheetFree ARGS1 (HTStyleSheet *,self)
+HTStyleSheet *HTStyleSheetFree(HTStyleSheet *self)
 {
-    HTStyle * style;
-    while((style=self->styles)!=0) {
+    HTStyle *style;
+
+    while ((style = self->styles) != 0) {
 	self->styles = style->next;
 	HTStyleFree(style);
     }
@@ -307,24 +319,24 @@
     return NULL;
 }
 
-
 /*	Read a stylesheet from a typed stream
-**	-------------------------------------
-**
-**	Reads a style sheet from a stream.  If new styles have the same names
-**	as existing styles, they replace the old ones without changing the ids.
-*/
+ *	-------------------------------------
+ *
+ *	Reads a style sheet from a stream.  If new styles have the same names
+ *	as existing styles, they replace the old ones without changing the ids.
+ */
 
-#ifdef NEXT_SUPRESS  /* Only on the NeXT */
-HTStyleSheet * HTStyleSheetRead(HTStyleSheet * self, NXStream * stream)
+#ifdef NEXT_SUPRESS		/* Only on the NeXT */
+HTStyleSheet *HTStyleSheetRead(HTStyleSheet *self, NXStream * stream)
 {
     int numStyles;
     int i;
-    HTStyle * style;
+    HTStyle *style;
     char styleName[80];
+
     NXScanf(stream, " %d ", &numStyles);
     CTRACE((tfp, "Stylesheet: Reading %d styles\n", numStyles));
-    for (i=0; i<numStyles; i++) {
+    for (i = 0; i < numStyles; i++) {
 	NXScanf(stream, "%s", styleName);
 	style = HTStyleNamed(self, styleName);
 	if (!style) {
@@ -332,27 +344,29 @@
 	    (void) HTStyleSheetAddStyle(self, style);
 	}
 	(void) HTStyleRead(style, stream);
-	if (TRACE) HTStyleDump(style);
+	if (TRACE)
+	    HTStyleDump(style);
     }
     return self;
 }
 
 /*	Write a stylesheet to a typed stream
-**	------------------------------------
-**
-**	Writes a style sheet to a stream.
-*/
+ *	------------------------------------
+ *
+ *	Writes a style sheet to a stream.
+ */
 
-HTStyleSheet * HTStyleSheetWrite(HTStyleSheet * self, NXStream * stream)
+HTStyleSheet *HTStyleSheetWrite(HTStyleSheet *self, NXStream * stream)
 {
     int numStyles = 0;
-    HTStyle * style;
+    HTStyle *style;
 
-    for(style=self->styles; style; style=style->next) numStyles++;
+    for (style = self->styles; style; style = style->next)
+	numStyles++;
     NXPrintf(stream, "%d\n", numStyles);
 
     CTRACE((tfp, "StyleSheet: Writing %d styles\n", numStyles));
-    for (style=self->styles; style; style=style->next) {
+    for (style = self->styles; style; style = style->next) {
 	NXPrintf(stream, "%s ", style->name);
 	(void) HTStyleWrite(style, stream);
     }
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/HTAnchor.c
+++ lynx-cur-2.8.6/WWW/Library/Implementation/HTAnchor.c
@@ -1,17 +1,17 @@
 /*	Hypertext "Anchor" Object				HTAnchor.c
-**	==========================
-**
-** An anchor represents a region of a hypertext document which is linked to
-** another anchor in the same or a different document.
-**
-** History
-**
-**	   Nov 1990  Written in Objective-C for the NeXT browser (TBL)
-**	24-Oct-1991 (JFG), written in C, browser-independent
-**	21-Nov-1991 (JFG), first complete version
-**
-**	(c) Copyright CERN 1991 - See Copyright.html
-*/
+ *	==========================
+ *
+ * An anchor represents a region of a hypertext document which is linked to
+ * another anchor in the same or a different document.
+ *
+ * History
+ *
+ *	   Nov 1990  Written in Objective-C for the NeXT browser (TBL)
+ *	24-Oct-1991 (JFG), written in C, browser-independent
+ *	21-Nov-1991 (JFG), first complete version
+ *
+ *	(c) Copyright CERN 1991 - See Copyright.html
+ */
 
 #define HASH_SIZE 101		/* Arbitrary prime.  Memory/speed tradeoff */
 
@@ -39,41 +39,42 @@
 /*
  *	This is the original function.	We'll use it again. - FM
  */
-PRIVATE int HASH_FUNCTION ARGS1(
-	CONST char *,	cp_address)
+static int HASH_FUNCTION(const char *cp_address)
 {
     int hash;
-    CONST unsigned char *p;
+    const unsigned char *p;
 
-    for (p = (CONST unsigned char *)cp_address, hash = 0; *p; p++)
-	hash = (int) (hash * 3 + (*(CONST unsigned char *)p)) % HASH_SIZE;
+    for (p = (const unsigned char *) cp_address, hash = 0; *p; p++)
+	hash = (int) (hash * 3 + (*(const unsigned char *) p)) % HASH_SIZE;
 
-    return(hash);
+    return (hash);
 }
 
 typedef struct _HyperDoc Hyperdoc;
+
 #ifdef VMS
 struct _HyperDoc {
-	int junk;	/* VMS cannot handle pointers to undefined structs */
+    int junk;			/* VMS cannot handle pointers to undefined structs */
 };
 #endif /* VMS */
 
 /* Table of lists of all parents */
-PRIVATE HTList adult_table[HASH_SIZE] = { {NULL, NULL} };
-
+static HTList adult_table[HASH_SIZE] =
+{
+    {NULL, NULL}};
 
 /*				Creation Methods
-**				================
-**
-**	Do not use "new" by itself outside this module.  In order to enforce
-**	consistency, we insist that you furnish more information about the
-**	anchor you are creating : use newWithParent or newWithAddress.
-*/
-PRIVATE HTParentAnchor0 * HTParentAnchor0_new ARGS2(
-	CONST char *,	address,
-	short,		hash)
+ *				================
+ *
+ *	Do not use "new" by itself outside this module.  In order to enforce
+ *	consistency, we insist that you furnish more information about the
+ *	anchor you are creating : use newWithParent or newWithAddress.
+ */
+static HTParentAnchor0 *HTParentAnchor0_new(const char *address,
+					    short hash)
 {
     HTParentAnchor0 *newAnchor = typecalloc(HTParentAnchor0);
+
     if (newAnchor == NULL)
 	outofmem(__FILE__, "HTParentAnchor0_new");
 
@@ -81,33 +82,33 @@
     StrAllocCopy(newAnchor->address, address);
     newAnchor->adult_hash = hash;
 
-    return(newAnchor);
+    return (newAnchor);
 }
 
-PRIVATE HTParentAnchor * HTParentAnchor_new ARGS1(
-	HTParentAnchor0 *,	parent)
+static HTParentAnchor *HTParentAnchor_new(HTParentAnchor0 *parent)
 {
     HTParentAnchor *newAnchor = typecalloc(HTParentAnchor);
+
     if (newAnchor == NULL)
 	outofmem(__FILE__, "HTParentAnchor_new");
 
-    newAnchor->parent = parent;		/* cross reference */
-    parent->info = newAnchor;		/* cross reference */
-    newAnchor->address = parent->address;  /* copy pointer */
+    newAnchor->parent = parent;	/* cross reference */
+    parent->info = newAnchor;	/* cross reference */
+    newAnchor->address = parent->address;	/* copy pointer */
 
     newAnchor->isISMAPScript = FALSE;	/* Lynx appends ?0,0 if TRUE. - FM */
-    newAnchor->isHEAD = FALSE;		/* HEAD request if TRUE. - FM */
-    newAnchor->safe = FALSE;		/* Safe. - FM */
+    newAnchor->isHEAD = FALSE;	/* HEAD request if TRUE. - FM */
+    newAnchor->safe = FALSE;	/* Safe. - FM */
     newAnchor->no_cache = FALSE;	/* no-cache? - FM */
-    newAnchor->inBASE = FALSE;		/* duplicated from HTML.c/h */
+    newAnchor->inBASE = FALSE;	/* duplicated from HTML.c/h */
     newAnchor->content_length = 0;	/* Content-Length. - FM */
-    return(newAnchor);
+    return (newAnchor);
 }
 
-PRIVATE HTChildAnchor * HTChildAnchor_new ARGS1(
-	HTParentAnchor0 *,	parent)
+static HTChildAnchor *HTChildAnchor_new(HTParentAnchor0 *parent)
 {
     HTChildAnchor *p = typecalloc(HTChildAnchor);
+
     if (p == NULL)
 	outofmem(__FILE__, "HTChildAnchor_new");
 
@@ -115,11 +116,11 @@
     return p;
 }
 
-PRIVATE HTChildAnchor * HText_pool_ChildAnchor_new ARGS1(
-	HTParentAnchor *,	parent)
+static HTChildAnchor *HText_pool_ChildAnchor_new(HTParentAnchor *parent)
 {
-    HTChildAnchor *p = (HTChildAnchor *)HText_pool_calloc((HText*)(parent->document),
-						sizeof(HTChildAnchor));
+    HTChildAnchor *p = (HTChildAnchor *) HText_pool_calloc((HText *) (parent->document),
+							   sizeof(HTChildAnchor));
+
     if (p == NULL)
 	outofmem(__FILE__, "HText_pool_ChildAnchor_new");
 
@@ -136,177 +137,171 @@
 #endif
 
 /*	Null-terminated string comparison
-**	---------------------------------
-** On entry,
-**	s	Points to one string, null terminated
-**	t	points to the other.
-** On exit,
-**	returns YES if the strings are equivalent
-**		NO if they differ.
-*/
-PRIVATE BOOL HTSEquivalent ARGS2(
-	CONST char *,	s,
-	CONST char *,	t)
+ *	---------------------------------
+ * On entry,
+ *	s	Points to one string, null terminated
+ *	t	points to the other.
+ * On exit,
+ *	returns YES if the strings are equivalent
+ *		NO if they differ.
+ */
+static BOOL HTSEquivalent(const char *s,
+			  const char *t)
 {
-    if (s && t) {  /* Make sure they point to something */
+    if (s && t) {		/* Make sure they point to something */
 	for (; *s && *t; s++, t++) {
 	    if (!HT_EQUIV(*s, *t)) {
-		return(NO);
+		return (NO);
 	    }
 	}
-	return(HT_EQUIV(*s, *t));
+	return (HT_EQUIV(*s, *t));
     } else {
-	return(s == t);		/* Two NULLs are equivalent, aren't they ? */
+	return (s == t);	/* Two NULLs are equivalent, aren't they ? */
     }
 }
 
 /*	Binary string comparison
-**	------------------------
-** On entry,
-**	s	Points to one bstring
-**	t	points to the other.
-** On exit,
-**	returns YES if the strings are equivalent
-**		NO if they differ.
-*/
-PRIVATE BOOL HTBEquivalent ARGS2(
-	CONST bstring *,	s,
-	CONST bstring *,	t)
+ *	------------------------
+ * On entry,
+ *	s	Points to one bstring
+ *	t	points to the other.
+ * On exit,
+ *	returns YES if the strings are equivalent
+ *		NO if they differ.
+ */
+static BOOL HTBEquivalent(const bstring *s,
+			  const bstring *t)
 {
     if (s && t && BStrLen(s) == BStrLen(t)) {
 	int j;
 	int len = BStrLen(s);
+
 	for (j = 0; j < len; ++j) {
 	    if (!HT_EQUIV(BStrData(s)[j], BStrData(t)[j])) {
-		return(NO);
+		return (NO);
 	    }
 	}
-	return(YES);
+	return (YES);
     } else {
-	return(s == t);		/* Two NULLs are equivalent, aren't they ? */
+	return (s == t);	/* Two NULLs are equivalent, aren't they ? */
     }
 }
 
 /*
- *  Three-way compare function
+ * Three-way compare function
  */
-PRIVATE int compare_anchors ARGS2(
-	void *, l,
-	void *, r)
+static int compare_anchors(void *l,
+			   void *r)
 {
-    CONST char* a = ((HTChildAnchor *)l)->tag;
-    CONST char* b = ((HTChildAnchor *)r)->tag;
+    const char *a = ((HTChildAnchor *) l)->tag;
+    const char *b = ((HTChildAnchor *) r)->tag;
+
     /* both tags are not NULL */
 
 #ifdef CASE_INSENSITIVE_ANCHORS
-	return strcasecomp(a, b); /* Case insensitive */
+    return strcasecomp(a, b);	/* Case insensitive */
 #else
-	return strcmp(a, b);      /* Case sensitive - FM */
+    return strcmp(a, b);	/* Case sensitive - FM */
 #endif /* CASE_INSENSITIVE_ANCHORS */
 }
 
-
 /*	Create new or find old sub-anchor
-**	---------------------------------
-**
-**	This one is for a named child.
-**	The parent anchor must already exist.
-*/
-PRIVATE HTChildAnchor * HTAnchor_findNamedChild ARGS2(
-	HTParentAnchor0 *,	parent,
-	CONST char *,		tag)
+ *	---------------------------------
+ *
+ *	This one is for a named child.
+ *	The parent anchor must already exist.
+ */
+static HTChildAnchor *HTAnchor_findNamedChild(HTParentAnchor0 *parent,
+					      const char *tag)
 {
     HTChildAnchor *child;
 
-    if (parent && tag && *tag) {  /* TBL */
+    if (parent && tag && *tag) {	/* TBL */
 	if (parent->children) {
 	    /*
-	    **  Parent has children.  Search them.
-	    */
+	     * Parent has children.  Search them.
+	     */
 	    HTChildAnchor sample;
-	    sample.tag = (char*)tag;    /* for compare_anchors() only */
 
-	    child = (HTChildAnchor *)HTBTree_search(parent->children, &sample);
+	    sample.tag = (char *) tag;	/* for compare_anchors() only */
+
+	    child = (HTChildAnchor *) HTBTree_search(parent->children, &sample);
 	    if (child != NULL) {
-		CTRACE((tfp, "Child anchor %p of parent %p with name `%s' already exists.\n",
-				(void *)child, (void *)parent, tag));
-		return(child);
+		CTRACE((tfp,
+			"Child anchor %p of parent %p with name `%s' already exists.\n",
+			(void *) child, (void *) parent, tag));
+		return (child);
 	    }
-	} else {  /* parent doesn't have any children yet : create family */
+	} else {		/* parent doesn't have any children yet : create family */
 	    parent->children = HTBTree_new(compare_anchors);
 	}
 
 	child = HTChildAnchor_new(parent);
 	CTRACE((tfp, "HTAnchor: New Anchor %p named `%s' is child of %p\n",
-		(void *)child,
+		(void *) child,
 		NonNull(tag),
-		(void *)child->parent));
+		(void *) child->parent));
 
-	StrAllocCopy(child->tag, tag);   /* should be set before HTBTree_add */
+	StrAllocCopy(child->tag, tag);	/* should be set before HTBTree_add */
 	HTBTree_add(parent->children, child);
-	return(child);
+	return (child);
 
     } else {
 	CTRACE((tfp, "HTAnchor_findNamedChild called with NULL parent.\n"));
-	return(NULL);
+	return (NULL);
     }
 
 }
 
 /*
-**	This one is for a new unnamed child being edited into an existing
-**	document.  The parent anchor and the document must already exist.
-**	(Just add new unnamed child).
-*/
-PRIVATE HTChildAnchor * HTAnchor_addChild ARGS1(
-	HTParentAnchor *,	parent)
+ *	This one is for a new unnamed child being edited into an existing
+ *	document.  The parent anchor and the document must already exist.
+ *	(Just add new unnamed child).
+ */
+static HTChildAnchor *HTAnchor_addChild(HTParentAnchor *parent)
 {
     HTChildAnchor *child;
 
     if (!parent) {
 	CTRACE((tfp, "HTAnchor_addChild called with NULL parent.\n"));
-	return(NULL);
+	return (NULL);
     }
 
     child = HText_pool_ChildAnchor_new(parent);
     CTRACE((tfp, "HTAnchor: New unnamed Anchor %p is child of %p\n",
-		(void *)child,
-		(void *)child->parent));
+	    (void *) child,
+	    (void *) child->parent));
 
     child->tag = 0;
     HTList_linkObject(&parent->children_notag, child, &child->_add_children_notag);
 
-    return(child);
+    return (child);
 }
 
+static HTParentAnchor0 *HTAnchor_findAddress_in_adult_table(const DocAddress *newdoc);
 
-PRIVATE HTParentAnchor0 * HTAnchor_findAddress_in_adult_table PARAMS((
-	CONST DocAddress *	newdoc));
-
-PRIVATE BOOL HTAnchor_link PARAMS((
-	HTChildAnchor *		child,
-	HTAnchor *		destination,
-	HTLinkType *		type));
-
+static BOOL HTAnchor_link(HTChildAnchor *child,
+			  HTAnchor * destination,
+			  HTLinkType *type);
 
 /*	Create or find a child anchor with a possible link
-**	--------------------------------------------------
-**
-**	Create new anchor with a given parent and possibly
-**	a name, and possibly a link to a _relatively_ named anchor.
-**	(Code originally in ParseHTML.h)
-*/
-PUBLIC HTChildAnchor * HTAnchor_findChildAndLink ARGS4(
-	HTParentAnchor *,	parent, /* May not be 0   */
-	CONST char *,		tag,	/* May be "" or 0 */
-	CONST char *,		href,	/* May be "" or 0 */
-	HTLinkType *,		ltype)	/* May be 0	  */
-{
-    HTChildAnchor * child;
-    CTRACE((tfp,"Entered HTAnchor_findChildAndLink:  tag=`%s',%s href=`%s'\n",
-	       NonNull(tag),
-	       (ltype == HTInternalLink) ? " (internal link)" : "",
-	       NonNull(href) ));
+ *	--------------------------------------------------
+ *
+ *	Create new anchor with a given parent and possibly
+ *	a name, and possibly a link to a _relatively_ named anchor.
+ *	(Code originally in ParseHTML.h)
+ */
+HTChildAnchor *HTAnchor_findChildAndLink(HTParentAnchor *parent,	/* May not be 0   */
+					 const char *tag,	/* May be "" or 0 */
+					 const char *href,	/* May be "" or 0 */
+					 HTLinkType *ltype)	/* May be 0       */
+{
+    HTChildAnchor *child;
+
+    CTRACE((tfp, "Entered HTAnchor_findChildAndLink:  tag=`%s',%s href=`%s'\n",
+	    NonNull(tag),
+	    (ltype == HTInternalLink) ? " (internal link)" : "",
+	    NonNull(href)));
 
     if (tag && *tag) {
 	child = HTAnchor_findNamedChild(parent->parent, tag);
@@ -315,15 +310,16 @@
     }
 
     if (href && *href) {
-	CONST char *fragment = NULL;
-	HTParentAnchor0 * dest;
+	const char *fragment = NULL;
+	HTParentAnchor0 *dest;
 
 	if (ltype == HTInternalLink && *href == '#') {
 	    dest = parent->parent;
 	} else {
-	    CONST char *relative_to = (parent->inBASE && *href != '#') ?
-				parent->content_base : parent->address;
+	    const char *relative_to = (parent->inBASE && *href != '#') ?
+	    parent->content_base : parent->address;
 	    DocAddress parsed_doc;
+
 	    parsed_doc.address = HTParse(href, relative_to,
 					 PARSE_ALL_WITHOUT_ANCHOR);
 
@@ -345,59 +341,56 @@
 	}
 
 	/*
-	** [from HTAnchor_findAddress()]
-	** If the address represents a sub-anchor, we load its parent (above),
-	** then we create a named child anchor within that parent.
-	*/
-	fragment = (*href == '#') ?  href+1 : HTParseAnchor(href);
+	 * [from HTAnchor_findAddress()]
+	 * If the address represents a sub-anchor, we load its parent (above),
+	 * then we create a named child anchor within that parent.
+	 */
+	fragment = (*href == '#') ? href + 1 : HTParseAnchor(href);
 
 	if (*fragment)
-	    dest = (HTParentAnchor0 *)HTAnchor_findNamedChild(dest, fragment);
-
+	    dest = (HTParentAnchor0 *) HTAnchor_findNamedChild(dest, fragment);
 
 	if (tag && *tag) {
-	    if (child->dest) { /* DUPLICATE_ANCHOR_NAME_WORKAROUND  - kw */
+	    if (child->dest) {	/* DUPLICATE_ANCHOR_NAME_WORKAROUND  - kw */
 		CTRACE((tfp,
-			   "*** Duplicate ChildAnchor %p named `%s'",
-			   child, tag));
-		if ((HTAnchor *)dest != child->dest || ltype != child->type) {
+			"*** Duplicate ChildAnchor %p named `%s'",
+			child, tag));
+		if ((HTAnchor *) dest != child->dest || ltype != child->type) {
 		    CTRACE((tfp,
-			   ", different dest %p or type, creating unnamed child\n",
-			   child->dest));
+			    ", different dest %p or type, creating unnamed child\n",
+			    child->dest));
 		    child = HTAnchor_addChild(parent);
 		}
 	    }
 	}
-	HTAnchor_link(child, (HTAnchor *)dest, ltype);
+	HTAnchor_link(child, (HTAnchor *) dest, ltype);
     }
     return child;
 }
 
-
 /*	Create new or find old parent anchor
-**	------------------------------------
-**
-**	Me one is for a reference which is found in a document, and might
-**	not be already loaded.
-**	Note: You are not guaranteed a new anchor -- you might get an old one,
-**	like with fonts.
-*/
-PUBLIC HTParentAnchor * HTAnchor_findAddress ARGS1(
-	CONST DocAddress *,	newdoc)
+ *	------------------------------------
+ *
+ *	Me one is for a reference which is found in a document, and might
+ *	not be already loaded.
+ *	Note: You are not guaranteed a new anchor -- you might get an old one,
+ *	like with fonts.
+ */
+HTParentAnchor *HTAnchor_findAddress(const DocAddress *newdoc)
 {
     /* Anchor tag specified ? */
-    CONST char *tag = HTParseAnchor(newdoc->address);
+    const char *tag = HTParseAnchor(newdoc->address);
 
-    CTRACE((tfp,"Entered HTAnchor_findAddress\n"));
+    CTRACE((tfp, "Entered HTAnchor_findAddress\n"));
 
     /*
-    **	If the address represents a sub-anchor, we load its parent,
-    **	then we create a named child anchor within that parent.
-    */
+     * If the address represents a sub-anchor, we load its parent, then we
+     * create a named child anchor within that parent.
+     */
     if (*tag) {
 	DocAddress parsed_doc;
-	HTParentAnchor0 * foundParent;
-	HTChildAnchor * foundAnchor;
+	HTParentAnchor0 *foundParent;
+	HTChildAnchor *foundAnchor;
 
 	parsed_doc.address = HTParse(newdoc->address, "",
 				     PARSE_ALL_WITHOUT_ANCHOR);
@@ -408,66 +401,63 @@
 	parsed_doc.safe = newdoc->safe;
 
 	foundParent = HTAnchor_findAddress_in_adult_table(&parsed_doc);
-	foundAnchor = HTAnchor_findNamedChild (foundParent, tag);
+	foundAnchor = HTAnchor_findNamedChild(foundParent, tag);
 	FREE(parsed_doc.address);
-	return HTAnchor_parent((HTAnchor *)foundParent);
+	return HTAnchor_parent((HTAnchor *) foundParent);
     }
-    return HTAnchor_parent((HTAnchor *)HTAnchor_findAddress_in_adult_table(newdoc));
+    return HTAnchor_parent((HTAnchor *) HTAnchor_findAddress_in_adult_table(newdoc));
 }
 
-
 /*  The address has no anchor tag, for sure.
  */
-PRIVATE HTParentAnchor0 * HTAnchor_findAddress_in_adult_table ARGS1(
-	CONST DocAddress *,	newdoc)
+static HTParentAnchor0 *HTAnchor_findAddress_in_adult_table(const DocAddress *newdoc)
 {
     /*
-    **  Check whether we have this node.
-    */
+     * Check whether we have this node.
+     */
     int hash;
-    HTList * adults;
+    HTList *adults;
     HTList *grownups;
-    HTParentAnchor0 * foundAnchor;
+    HTParentAnchor0 *foundAnchor;
     BOOL need_extra_info = (newdoc->post_data || newdoc->post_content_type ||
-		newdoc->bookmark || newdoc->isHEAD || newdoc->safe);
+			    newdoc->bookmark || newdoc->isHEAD || newdoc->safe);
 
     /*
-     *  We need not free adult_table[] atexit -
-     *  it should be perfectly empty after free'ing all HText's.
-     *  (There is an error if it is not empty at exit). -LP
+     * We need not free adult_table[] atexit - it should be perfectly empty
+     * after free'ing all HText's.  (There is an error if it is not empty at
+     * exit).  -LP
      */
 
     /*
-    **  Select list from hash table,
-    */
+     * Select list from hash table,
+     */
     hash = HASH_FUNCTION(newdoc->address);
     adults = &(adult_table[hash]);
 
     /*
-    **  Search list for anchor.
-    */
+     * Search list for anchor.
+     */
     grownups = adults;
     while (NULL != (foundAnchor =
-		    (HTParentAnchor0 *)HTList_nextObject(grownups))) {
+		    (HTParentAnchor0 *) HTList_nextObject(grownups))) {
 	if (HTSEquivalent(foundAnchor->address, newdoc->address) &&
 
 	    ((!foundAnchor->info && !need_extra_info) ||
 	     (foundAnchor->info &&
 	      HTBEquivalent(foundAnchor->info->post_data, newdoc->post_data) &&
-	      foundAnchor->info->isHEAD == newdoc->isHEAD)))
-	{
+	      foundAnchor->info->isHEAD == newdoc->isHEAD))) {
 	    CTRACE((tfp, "Anchor %p with address `%s' already exists.\n",
-			(void *)foundAnchor, newdoc->address));
+		    (void *) foundAnchor, newdoc->address));
 	    return foundAnchor;
 	}
     }
 
     /*
-    **  Node not found: create new anchor.
-    */
+     * Node not found:  create new anchor.
+     */
     foundAnchor = HTParentAnchor0_new(newdoc->address, hash);
     CTRACE((tfp, "New anchor %p has hash %d and address `%s'\n",
-		(void *)foundAnchor, hash, newdoc->address));
+	    (void *) foundAnchor, hash, newdoc->address));
 
     if (need_extra_info) {
 	/* rare case, create a big structure */
@@ -477,7 +467,7 @@
 	    BStrCopy(p->post_data, newdoc->post_data);
 	if (newdoc->post_content_type)
 	    StrAllocCopy(p->post_content_type,
-		     newdoc->post_content_type);
+			 newdoc->post_content_type);
 	if (newdoc->bookmark)
 	    StrAllocCopy(p->bookmark, newdoc->bookmark);
 	p->isHEAD = newdoc->isHEAD;
@@ -489,17 +479,16 @@
 }
 
 /*	Create new or find old named anchor - simple form
-**	-------------------------------------------------
-**
-**     Like HTAnchor_findAddress, but simpler to use for simple cases.
-**	No post data etc. can be supplied. - kw
-*/
-PUBLIC HTParentAnchor * HTAnchor_findSimpleAddress ARGS1(
-	CONST char *,	url)
+ *	-------------------------------------------------
+ *
+ *     Like HTAnchor_findAddress, but simpler to use for simple cases.
+ *	No post data etc. can be supplied. - kw
+ */
+HTParentAnchor *HTAnchor_findSimpleAddress(const char *url)
 {
     DocAddress urldoc;
 
-    urldoc.address = (char *)url; /* ignore warning, it IS treated like const - kw */
+    urldoc.address = (char *) url;	/* ignore warning, it IS treated like const - kw */
     urldoc.post_data = NULL;
     urldoc.post_content_type = NULL;
     urldoc.bookmark = NULL;
@@ -508,22 +497,20 @@
     return HTAnchor_findAddress(&urldoc);
 }
 
-
 /*	Link me Anchor to another given one
-**	-------------------------------------
-*/
-PRIVATE BOOL HTAnchor_link ARGS3(
-	HTChildAnchor *,	child,
-	HTAnchor *,		destination,
-	HTLinkType *,		type)
+ *	-------------------------------------
+ */
+static BOOL HTAnchor_link(HTChildAnchor *child,
+			  HTAnchor * destination,
+			  HTLinkType *type)
 {
     if (!(child && destination))
-	return(NO);  /* Can't link to/from non-existing anchor */
+	return (NO);		/* Can't link to/from non-existing anchor */
 
     CTRACE((tfp, "Linking child %p to anchor %p\n", child, destination));
     if (child->dest) {
 	CTRACE((tfp, "*** child anchor already has destination, exiting!\n"));
-	return(NO);
+	return (NO);
     }
 
     child->dest = destination;
@@ -533,54 +520,51 @@
 	/* link only foreign children */
 	HTList_linkObject(&destination->parent->sources, child, &child->_add_sources);
 
-    return(YES);  /* Success */
+    return (YES);		/* Success */
 }
 
-
 /*	Delete an anchor and possibly related things (auto garbage collection)
-**	--------------------------------------------
-**
-**	The anchor is only deleted if the corresponding document is not loaded.
-**	All outgoing links from children are deleted, and children are
-**	removed from the sources lists of theirs targets.
-**	We also try to delete the targets whose documents are not loaded.
-**	If this anchor's sources list is empty, we delete it and its children.
-*/
+ *	--------------------------------------------
+ *
+ *	The anchor is only deleted if the corresponding document is not loaded.
+ *	All outgoing links from children are deleted, and children are
+ *	removed from the sources lists of theirs targets.
+ *	We also try to delete the targets whose documents are not loaded.
+ *	If this anchor's sources list is empty, we delete it and its children.
+ */
 
 /*
  *	Recursively try to delete destination anchor of this child.
  *	In any event, this will tell destination anchor that we
  *	no longer consider it a destination.
  */
-PRIVATE void deleteLinks ARGS1(
-	HTChildAnchor *,	me)
+static void deleteLinks(HTChildAnchor *me)
 {
     /*
-     *	Unregister me with our destination anchor's parent.
+     * Unregister me with our destination anchor's parent.
      */
     if (me->dest) {
 	HTParentAnchor0 *parent = me->dest->parent;
 
 	/*
-	 *  Start.  Set the dest pointer to zero.
+	 * Start.  Set the dest pointer to zero.
 	 */
-	 me->dest = NULL;
+	me->dest = NULL;
 
 	/*
-	 *  Remove me from the parent's sources so that the
-	 *  parent knows one less anchor is its dest.
+	 * Remove me from the parent's sources so that the parent knows one
+	 * less anchor is its dest.
 	 */
 	if ((me->parent != parent) && !HTList_isEmpty(&parent->sources)) {
 	    /*
-	     *	Really should only need to deregister once.
+	     * Really should only need to deregister once.
 	     */
-	    HTList_unlinkObject(&parent->sources, (void *)me);
+	    HTList_unlinkObject(&parent->sources, (void *) me);
 	}
 
 	/*
-	 *  Recursive call.
-	 *  Test here to avoid calling overhead.
-	 *  Don't delete if document is loaded or being loaded.
+	 * Recursive call.  Test here to avoid calling overhead.  Don't delete
+	 * if document is loaded or being loaded.
 	 */
 	if ((me->parent != parent) && !parent->underway &&
 	    (!parent->info || !parent->info->document)) {
@@ -588,58 +572,54 @@
 	}
 
 	/*
-	 *  At this point, we haven't a destination.  Set it to be
-	 *  so.
-	 *  Leave the HTAtom pointed to by type up to other code to
-	 *  handle (reusable, near static).
+	 * At this point, we haven't a destination.  Set it to be so.  Leave
+	 * the HTAtom pointed to by type up to other code to handle (reusable,
+	 * near static).
 	 */
 	me->type = NULL;
     }
 }
 
+static void HTParentAnchor_free(HTParentAnchor *me);
 
-PRIVATE void HTParentAnchor_free PARAMS((
-	HTParentAnchor *	me));
-
-PUBLIC BOOL HTAnchor_delete ARGS1(
-	HTParentAnchor0 *,	me)
+BOOL HTAnchor_delete(HTParentAnchor0 *me)
 {
     /*
-     *	Memory leaks fixed.
+     * Memory leaks fixed.
      * 05-27-94 Lynx 2-3-1 Garrett Arch Blythe
      */
     HTBTElement *ele;
     HTChildAnchor *child;
 
     /*
-     *	Do nothing if nothing to do.
+     * Do nothing if nothing to do.
      */
     if (!me) {
-	return(NO);
+	return (NO);
     }
 
     /*
-     *	Don't delete if document is loaded or being loaded.
+     * Don't delete if document is loaded or being loaded.
      */
     if (me->underway || (me->info && me->info->document)) {
-	return(NO);
+	return (NO);
     }
 
     /*
-     *  Mark ourselves busy, so that recursive calls of this function
-     *  on this HTParentAnchor0 will not free it from under our feet. - kw
+     * Mark ourselves busy, so that recursive calls of this function on this
+     * HTParentAnchor0 will not free it from under our feet.  - kw
      */
     me->underway = TRUE;
 
     {
 	/*
-	 *  Delete all outgoing links from named children.
-	 *  Do not delete named children itself (may have incoming links).
+	 * Delete all outgoing links from named children.  Do not delete named
+	 * children itself (may have incoming links).
 	 */
 	if (me->children) {
 	    ele = HTBTree_next(me->children, NULL);
 	    while (ele != NULL) {
-		child = (HTChildAnchor *)HTBTree_object(ele);
+		child = (HTChildAnchor *) HTBTree_object(ele);
 		if (child->dest)
 		    deleteLinks(child);
 		ele = HTBTree_next(me->children, ele);
@@ -648,26 +628,25 @@
     }
     me->underway = FALSE;
 
-
     /*
      * There are still incoming links to this one (we are the
      * destination of another anchor).
      */
     if (!HTList_isEmpty(&me->sources)) {
 	/*
-	 *  Can't delete parent, still have sources.
+	 * Can't delete parent, still have sources.
 	 */
-	return(NO);
+	return (NO);
     }
 
     /*
-     *	No more incoming and outgoing links : kill everything
-     *	First, delete named children.
+     * No more incoming and outgoing links :  kill everything First, delete
+     * named children.
      */
     if (me->children) {
 	ele = HTBTree_next(me->children, NULL);
 	while (ele != NULL) {
-	    child = (HTChildAnchor *)HTBTree_object(ele);
+	    child = (HTChildAnchor *) HTBTree_object(ele);
 	    FREE(child->tag);
 	    FREE(child);
 	    ele = HTBTree_next(me->children, ele);
@@ -676,7 +655,7 @@
     }
 
     /*
-     *  Delete the ParentAnchor, if any. (Document was already deleted).
+     * Delete the ParentAnchor, if any.  (Document was already deleted).
      */
     if (me->info) {
 	HTParentAnchor_free(me->info);
@@ -684,79 +663,76 @@
     }
 
     /*
-     *	Remove ourselves from the hash table's list.
+     * Remove ourselves from the hash table's list.
      */
-    HTList_unlinkObject(&(adult_table[me->adult_hash]), (void *)me);
+    HTList_unlinkObject(&(adult_table[me->adult_hash]), (void *) me);
 
     /*
-     *	Free the address.
+     * Free the address.
      */
     FREE(me->address);
 
     /*
-     *	Finally, kill the parent anchor passed in.
+     * Finally, kill the parent anchor passed in.
      */
     FREE(me);
 
-    return(YES);
+    return (YES);
 }
 
 /*
- *  Unnamed children (children_notag) have no sence without HText -
- *  delete them and their links if we are about to free HText.
- *  Document currently exists. Called within HText_free().
+ * Unnamed children (children_notag) have no sence without HText - delete them
+ * and their links if we are about to free HText.  Document currently exists. 
+ * Called within HText_free().
  */
-PUBLIC void HTAnchor_delete_links ARGS1(
-	HTParentAnchor *,	me)
+void HTAnchor_delete_links(HTParentAnchor *me)
 {
     HTList *cur;
     HTChildAnchor *child;
 
     /*
-     *	Do nothing if nothing to do.
+     * Do nothing if nothing to do.
      */
     if (!me || !me->document) {
 	return;
     }
 
     /*
-     *  Mark ourselves busy, so that recursive calls
-     *  on this HTParentAnchor0 will not free it from under our feet. - kw
+     * Mark ourselves busy, so that recursive calls on this HTParentAnchor0
+     * will not free it from under our feet.  - kw
      */
     me->parent->underway = TRUE;
 
     /*
-     *  Delete all outgoing links from unnamed children.
+     * Delete all outgoing links from unnamed children.
      */
     if (!HTList_isEmpty(&me->children_notag)) {
 	cur = &me->children_notag;
 	while ((child =
-		(HTChildAnchor *)HTList_unlinkLastObject(cur)) != 0) {
+		(HTChildAnchor *) HTList_unlinkLastObject(cur)) != 0) {
 	    deleteLinks(child);
-	    /* child allocated in HText pool, HText_free() will free it later*/
+	    /* child allocated in HText pool, HText_free() will free it later */
 	}
     }
     me->parent->underway = FALSE;
 }
 
-
-PRIVATE void HTParentAnchor_free ARGS1(
-	HTParentAnchor *,	me)
+static void HTParentAnchor_free(HTParentAnchor *me)
 {
     /*
-     *	Delete the methods list.
+     * Delete the methods list.
      */
     if (me->methods) {
 	/*
-	 *  Leave what the methods point to up in memory for
-	 *  other code (near static stuff).
+	 * Leave what the methods point to up in memory for other code (near
+	 * static stuff).
 	 */
 	HTList_delete(me->methods);
 	me->methods = NULL;
     }
 
     /*
-     *	Free up all allocated members.
+     * Free up all allocated members.
      */
     FREE(me->charset);
     FREE(me->isIndexAction);
@@ -774,6 +750,7 @@
 #endif
     if (me->FileCache) {
 	FILE *fd;
+
 	if ((fd = fopen(me->FileCache, "r")) != NULL) {
 	    fclose(fd);
 	    remove(me->FileCache);
@@ -782,6 +759,10 @@
     }
     FREE(me->SugFname);
     FREE(me->cache_control);
+#ifdef EXP_HTTP_HEADERS
+    HTChunkClear(&(me->http_headers));
+#endif
+    FREE(me->content_type_params);
     FREE(me->content_type);
     FREE(me->content_language);
     FREE(me->content_encoding);
@@ -802,10 +783,10 @@
 #endif
 
     /*
-     *	Original code wanted a way to clean out the HTFormat if no
-     *	longer needed (ref count?).  I'll leave it alone since
-     *	those HTAtom objects are a little harder to know where
-     *	they are being referenced all at one time. (near static)
+     * Original code wanted a way to clean out the HTFormat if no longer needed
+     * (ref count?).  I'll leave it alone since those HTAtom objects are a
+     * little harder to know where they are being referenced all at one time. 
+     * (near static)
      */
 
     FREE(me->UCStages);
@@ -813,21 +794,20 @@
 }
 
 #ifdef USE_SOURCE_CACHE
-PUBLIC void HTAnchor_clearSourceCache ARGS1(
-	HTParentAnchor *,	me)
+void HTAnchor_clearSourceCache(HTParentAnchor *me)
 {
     /*
      * Clean up the source cache, if any.
      */
     if (me->source_cache_file) {
 	CTRACE((tfp, "SourceCache: Removing file %s\n",
-	       me->source_cache_file));
+		me->source_cache_file));
 	LYRemoveTemp(me->source_cache_file);
 	FREE(me->source_cache_file);
     }
     if (me->source_cache_chunk) {
 	CTRACE((tfp, "SourceCache: Removing memory chunk %p\n",
-	       (void *)me->source_cache_chunk));
+		(void *) me->source_cache_chunk));
 	HTChunkFree(me->source_cache_chunk);
 	me->source_cache_chunk = NULL;
     }
@@ -835,10 +815,9 @@
 #endif /* USE_SOURCE_CACHE */
 
 /*	Data access functions
-**	---------------------
-*/
-PUBLIC HTParentAnchor * HTAnchor_parent ARGS1(
-	HTAnchor *,	me)
+ *	---------------------
+ */
+HTParentAnchor *HTAnchor_parent(HTAnchor * me)
 {
     if (!me)
 	return NULL;
@@ -850,56 +829,49 @@
     return HTParentAnchor_new(me->parent);
 }
 
-PUBLIC void HTAnchor_setDocument ARGS2(
-	HTParentAnchor *,	me,
-	HyperDoc *,		doc)
+void HTAnchor_setDocument(HTParentAnchor *me,
+			  HyperDoc *doc)
 {
     if (me)
 	me->document = doc;
 }
 
-PUBLIC HyperDoc * HTAnchor_document ARGS1(
-	HTParentAnchor *,	me)
+HyperDoc *HTAnchor_document(HTParentAnchor *me)
 {
-    return( me ? me->document : NULL);
+    return (me ? me->document : NULL);
 }
 
-
-PUBLIC char * HTAnchor_address ARGS1(
-	HTAnchor *,	me)
+char *HTAnchor_address(HTAnchor * me)
 {
     char *addr = NULL;
 
     if (me) {
-	if (((HTParentAnchor0 *)me == me->parent) ||
-	    ((HTParentAnchor *)me == me->parent->info) ||
-	    !((HTChildAnchor *)me)->tag) {  /* it's an adult or no tag */
+	if (((HTParentAnchor0 *) me == me->parent) ||
+	    ((HTParentAnchor *) me == me->parent->info) ||
+	    !((HTChildAnchor *) me)->tag) {	/* it's an adult or no tag */
 	    StrAllocCopy(addr, me->parent->address);
-	} else {  /* it's a named child */
+	} else {		/* it's a named child */
 	    HTSprintf0(&addr, "%s#%s",
-		       me->parent->address, ((HTChildAnchor *)me)->tag);
+		       me->parent->address, ((HTChildAnchor *) me)->tag);
 	}
     }
-    return(addr);
+    return (addr);
 }
 
-PUBLIC void HTAnchor_setFormat ARGS2(
-	HTParentAnchor *,	me,
-	HTFormat,		form)
+void HTAnchor_setFormat(HTParentAnchor *me,
+			HTFormat form)
 {
     if (me)
 	me->format = form;
 }
 
-PUBLIC HTFormat HTAnchor_format ARGS1(
-	HTParentAnchor *,	me)
+HTFormat HTAnchor_format(HTParentAnchor *me)
 {
-    return( me ? me->format : NULL);
+    return (me ? me->format : NULL);
 }
 
-PUBLIC void HTAnchor_setIndex ARGS2(
-	HTParentAnchor *,	me,
-	CONST char *,		address)
+void HTAnchor_setIndex(HTParentAnchor *me,
+		       const char *address)
 {
     if (me) {
 	me->isIndex = YES;
@@ -907,42 +879,37 @@
     }
 }
 
-PUBLIC void HTAnchor_setPrompt ARGS2(
-	HTParentAnchor *,	me,
-	CONST char *,		prompt)
+void HTAnchor_setPrompt(HTParentAnchor *me,
+			const char *prompt)
 {
     if (me) {
 	StrAllocCopy(me->isIndexPrompt, prompt);
     }
 }
 
-PUBLIC BOOL HTAnchor_isIndex ARGS1(
-	HTParentAnchor *,	me)
+BOOL HTAnchor_isIndex(HTParentAnchor *me)
 {
-    return( me ? me->isIndex : NO);
+    return (me ? me->isIndex : NO);
 }
 
 /*	Whether Anchor has been designated as an ISMAP link
-**	(normally by presence of an ISMAP attribute on A or IMG) - KW
-*/
-PUBLIC BOOL HTAnchor_isISMAPScript ARGS1(
-	HTAnchor *,	me)
+ *	(normally by presence of an ISMAP attribute on A or IMG) - KW
+ */
+BOOL HTAnchor_isISMAPScript(HTAnchor * me)
 {
-    return( (me && me->parent->info) ? me->parent->info->isISMAPScript : NO);
+    return ((me && me->parent->info) ? me->parent->info->isISMAPScript : NO);
 }
 
 #if defined(USE_COLOR_STYLE)
 /*	Style handling.
 */
-PUBLIC CONST char * HTAnchor_style ARGS1(
-	HTParentAnchor *,	me)
+const char *HTAnchor_style(HTParentAnchor *me)
 {
-	return( me ? me->style : NULL);
+    return (me ? me->style : NULL);
 }
 
-PUBLIC void HTAnchor_setStyle ARGS2(
-	HTParentAnchor *,	me,
-	CONST char *,		style)
+void HTAnchor_setStyle(HTParentAnchor *me,
+		       const char *style)
 {
     if (me) {
 	StrAllocCopy(me->style, style);
@@ -950,18 +917,15 @@
 }
 #endif
 
-
 /*	Title handling.
 */
-PUBLIC CONST char * HTAnchor_title ARGS1(
-	HTParentAnchor *,	me)
+const char *HTAnchor_title(HTParentAnchor *me)
 {
-    return( me ? me->title : NULL);
+    return (me ? me->title : NULL);
 }
 
-PUBLIC void HTAnchor_setTitle ARGS2(
-	HTParentAnchor *,	me,
-	CONST char *,		title)
+void HTAnchor_setTitle(HTParentAnchor *me,
+		       const char *title)
 {
     int i;
 
@@ -975,20 +939,19 @@
 		}
 	    }
 	} else {
-	    CTRACE((tfp,"HTAnchor_setTitle: New title is NULL! "));
+	    CTRACE((tfp, "HTAnchor_setTitle: New title is NULL! "));
 	    if (me->title) {
-		CTRACE((tfp,"Old title was \"%s\".\n", me->title));
+		CTRACE((tfp, "Old title was \"%s\".\n", me->title));
 		FREE(me->title);
 	    } else {
-		CTRACE((tfp,"Old title was NULL.\n"));
+		CTRACE((tfp, "Old title was NULL.\n"));
 	    }
 	}
     }
 }
 
-PUBLIC void HTAnchor_appendTitle ARGS2(
-	HTParentAnchor *,	me,
-	CONST char *,		title)
+void HTAnchor_appendTitle(HTParentAnchor *me,
+			  const char *title)
 {
     int i;
 
@@ -1005,15 +968,13 @@
 
 /*	Bookmark handling.
 */
-PUBLIC CONST char * HTAnchor_bookmark ARGS1(
-	HTParentAnchor *,	me)
+const char *HTAnchor_bookmark(HTParentAnchor *me)
 {
-    return( me ? me->bookmark : NULL);
+    return (me ? me->bookmark : NULL);
 }
 
-PUBLIC void HTAnchor_setBookmark ARGS2(
-	HTParentAnchor *,	me,
-	CONST char *,		bookmark)
+void HTAnchor_setBookmark(HTParentAnchor *me,
+			  const char *bookmark)
 {
     if (me)
 	StrAllocCopy(me->bookmark, bookmark);
@@ -1021,15 +982,13 @@
 
 /*	Owner handling.
 */
-PUBLIC CONST char * HTAnchor_owner ARGS1(
-	HTParentAnchor *,	me)
+const char *HTAnchor_owner(HTParentAnchor *me)
 {
-    return( me ? me->owner : NULL);
+    return (me ? me->owner : NULL);
 }
 
-PUBLIC void HTAnchor_setOwner ARGS2(
-	HTParentAnchor *,	me,
-	CONST char *,		owner)
+void HTAnchor_setOwner(HTParentAnchor *me,
+		       const char *owner)
 {
     if (me) {
 	StrAllocCopy(me->owner, owner);
@@ -1038,15 +997,13 @@
 
 /*	TITLE handling in LINKs with REV="made" or REV="owner". - FM
 */
-PUBLIC CONST char * HTAnchor_RevTitle ARGS1(
-	HTParentAnchor *,	me)
+const char *HTAnchor_RevTitle(HTParentAnchor *me)
 {
-    return( me ? me->RevTitle : NULL);
+    return (me ? me->RevTitle : NULL);
 }
 
-PUBLIC void HTAnchor_setRevTitle ARGS2(
-	HTParentAnchor *,	me,
-	CONST char *,		title)
+void HTAnchor_setRevTitle(HTParentAnchor *me,
+			  const char *title)
 {
     int i;
 
@@ -1064,15 +1021,13 @@
 #ifndef DISABLE_BIBP
 /*	Citehost for bibp links from LINKs with REL="citehost". - RDC
 */
-PUBLIC CONST char * HTAnchor_citehost ARGS1(
-	HTParentAnchor *,	me)
+const char *HTAnchor_citehost(HTParentAnchor *me)
 {
-    return( me ? me->citehost : NULL);
+    return (me ? me->citehost : NULL);
 }
 
-PUBLIC void HTAnchor_setCitehost ARGS2(
-	HTParentAnchor *,	me,
-	CONST char *,		citehost)
+void HTAnchor_setCitehost(HTParentAnchor *me,
+			  const char *citehost)
 {
     if (me) {
 	StrAllocCopy(me->citehost, citehost);
@@ -1081,92 +1036,97 @@
 #endif /* !DISABLE_BIBP */
 
 /*	Suggested filename handling. - FM
-**	(will be loaded if we had a Content-Disposition
-**	 header or META element with filename=name.suffix)
+ *	(will be loaded if we had a Content-Disposition
+ *	 header or META element with filename=name.suffix)
+ */
+const char *HTAnchor_SugFname(HTParentAnchor *me)
+{
+    return (me ? me->SugFname : NULL);
+}
+
+#ifdef EXP_HTTP_HEADERS
+/*	HTTP Headers.
 */
-PUBLIC CONST char * HTAnchor_SugFname ARGS1(
-	HTParentAnchor *,	me)
+const char *HTAnchor_http_headers(HTParentAnchor *me)
 {
-    return( me ? me->SugFname : NULL);
+    return (me ? me->http_headers.data : NULL);
 }
+#endif
 
-/*	Content-Encoding handling. - FM
-**	(will be loaded if we had a Content-Encoding
-**	 header.)
+/*	Content-Type handling (parameter list).
 */
-PUBLIC CONST char * HTAnchor_content_encoding ARGS1(
-	HTParentAnchor *,	me)
+const char *HTAnchor_content_type_params(HTParentAnchor *me)
 {
-    return( me ? me->content_encoding : NULL);
+    return (me ? me->content_type_params : NULL);
+}
+
+/*	Content-Encoding handling. - FM
+ *	(will be loaded if we had a Content-Encoding
+ *	 header.)
+ */
+const char *HTAnchor_content_encoding(HTParentAnchor *me)
+{
+    return (me ? me->content_encoding : NULL);
 }
 
 /*	Content-Type handling. - FM
 */
-PUBLIC CONST char * HTAnchor_content_type ARGS1(
-	HTParentAnchor *,	me)
+const char *HTAnchor_content_type(HTParentAnchor *me)
 {
-    return( me ? me->content_type : NULL);
+    return (me ? me->content_type : NULL);
 }
 
 /*	Last-Modified header handling. - FM
 */
-PUBLIC CONST char * HTAnchor_last_modified ARGS1(
-	HTParentAnchor *,	me)
+const char *HTAnchor_last_modified(HTParentAnchor *me)
 {
-    return( me ? me->last_modified : NULL);
+    return (me ? me->last_modified : NULL);
 }
 
 /*	Date header handling. - FM
 */
-PUBLIC CONST char * HTAnchor_date ARGS1(
-	HTParentAnchor *,	me)
+const char *HTAnchor_date(HTParentAnchor *me)
 {
-    return( me ? me->date : NULL);
+    return (me ? me->date : NULL);
 }
 
 /*	Server header handling. - FM
 */
-PUBLIC CONST char * HTAnchor_server ARGS1(
-	HTParentAnchor *,	me)
+const char *HTAnchor_server(HTParentAnchor *me)
 {
-    return( me ? me->server : NULL);
+    return (me ? me->server : NULL);
 }
 
 /*	Safe header handling. - FM
 */
-PUBLIC BOOL HTAnchor_safe ARGS1(
-	HTParentAnchor *,	me)
+BOOL HTAnchor_safe(HTParentAnchor *me)
 {
-    return (BOOL) ( me ? me->safe : FALSE);
+    return (BOOL) (me ? me->safe : FALSE);
 }
 
 /*	Content-Base header handling. - FM
 */
-PUBLIC CONST char * HTAnchor_content_base ARGS1(
-	HTParentAnchor *,	me)
+const char *HTAnchor_content_base(HTParentAnchor *me)
 {
-    return( me ? me->content_base : NULL);
+    return (me ? me->content_base : NULL);
 }
 
 /*	Content-Location header handling. - FM
 */
-PUBLIC CONST char * HTAnchor_content_location ARGS1(
-	HTParentAnchor *,	me)
+const char *HTAnchor_content_location(HTParentAnchor *me)
 {
-    return( me ? me->content_location : NULL);
+    return (me ? me->content_location : NULL);
 }
 
 /*	Message-ID, used for mail replies - kw
 */
-PUBLIC CONST char * HTAnchor_messageID ARGS1(
-	HTParentAnchor *,	me)
+const char *HTAnchor_messageID(HTParentAnchor *me)
 {
-    return( me ? me->message_id : NULL);
+    return (me ? me->message_id : NULL);
 }
 
-PUBLIC BOOL HTAnchor_setMessageID ARGS2(
-	HTParentAnchor *,	me,
-	CONST char *,		messageid)
+BOOL HTAnchor_setMessageID(HTParentAnchor *me,
+			   const char *messageid)
 {
     if (!(me && messageid && *messageid)) {
 	return FALSE;
@@ -1177,15 +1137,13 @@
 
 /*	Subject, used for mail replies - kw
 */
-PUBLIC CONST char * HTAnchor_subject ARGS1(
-	HTParentAnchor *,	me)
+const char *HTAnchor_subject(HTParentAnchor *me)
 {
-    return( me ? me->subject : NULL);
+    return (me ? me->subject : NULL);
 }
 
-PUBLIC BOOL HTAnchor_setSubject ARGS2(
-	HTParentAnchor *,	me,
-	CONST char *,		subject)
+BOOL HTAnchor_setSubject(HTParentAnchor *me,
+			 const char *subject)
 {
     if (!(me && subject && *subject)) {
 	return FALSE;
@@ -1195,64 +1153,56 @@
 }
 
 /*	Manipulation of links
-**	---------------------
-*/
-PUBLIC HTAnchor * HTAnchor_followLink ARGS1(
-	HTChildAnchor *,	me)
+ *	---------------------
+ */
+HTAnchor *HTAnchor_followLink(HTChildAnchor *me)
 {
-    return( me->dest);
+    return (me->dest);
 }
 
-PUBLIC HTAnchor * HTAnchor_followTypedLink ARGS2(
-	HTChildAnchor *,	me,
-	HTLinkType *,		type)
+HTAnchor *HTAnchor_followTypedLink(HTChildAnchor *me,
+				   HTLinkType *type)
 {
     if (me->type == type)
-	return( me->dest);
-    return(NULL);  /* No link of me type */
+	return (me->dest);
+    return (NULL);		/* No link of me type */
 }
 
-
 /*	Methods List
-**	------------
-*/
-PUBLIC HTList * HTAnchor_methods ARGS1(
-	HTParentAnchor *,	me)
+ *	------------
+ */
+HTList *HTAnchor_methods(HTParentAnchor *me)
 {
     if (!me->methods) {
 	me->methods = HTList_new();
     }
-    return( me->methods);
+    return (me->methods);
 }
 
 /*	Protocol
-**	--------
-*/
-PUBLIC void * HTAnchor_protocol ARGS1(
-	HTParentAnchor *,	me)
+ *	--------
+ */
+void *HTAnchor_protocol(HTParentAnchor *me)
 {
-    return( me->protocol);
+    return (me->protocol);
 }
 
-PUBLIC void HTAnchor_setProtocol ARGS2(
-	HTParentAnchor *,	me,
-	void*,			protocol)
+void HTAnchor_setProtocol(HTParentAnchor *me,
+			  void *protocol)
 {
     me->protocol = protocol;
 }
 
 /*	Physical Address
-**	----------------
-*/
-PUBLIC char * HTAnchor_physical ARGS1(
-	HTParentAnchor *,	me)
+ *	----------------
+ */
+char *HTAnchor_physical(HTParentAnchor *me)
 {
-    return( me->physical);
+    return (me->physical);
 }
 
-PUBLIC void HTAnchor_setPhysical ARGS2(
-	HTParentAnchor *,	me,
-	char *,			physical)
+void HTAnchor_setPhysical(HTParentAnchor *me,
+			  char *physical)
 {
     if (me) {
 	StrAllocCopy(me->physical, physical);
@@ -1260,37 +1210,37 @@
 }
 
 /*
-**  We store charset info in the HTParentAnchor object, for several
-**  "stages".  (See UCDefs.h)
-**  A stream method is supposed to know what stage in the model it is.
-**
-**  General model	MIME	 ->  parser  ->  structured  ->  HText
-**  e.g., text/html
-**	from HTTP:	HTMIME.c ->  SGML.c  ->  HTML.c      ->  GridText.c
-**     text/plain
-**	from file:	HTFile.c ->  HTPlain.c		     ->  GridText.c
-**
-**  The lock/set_by is used to lock e.g. a charset set by an explicit
-**  HTTP MIME header against overriding by a HTML META tag - the MIME
-**  header has higher priority.  Defaults (from -assume_.. options etc.)
-**  will not override charset explicitly given by server.
-**
-**  Some advantages of keeping this in the HTAnchor:
-**  - Global variables are bad.
-**  - Can remember a charset given by META tag when toggling to SOURCE view.
-**  - Can remember a charset given by <A CHARSET=...> href in another doc.
-**
-**  We don't modify the HTParentAnchor's charset element
-**  here, that one will only be set when explicitly given.
-*/
-PUBLIC LYUCcharset * HTAnchor_getUCInfoStage ARGS2(
-	HTParentAnchor *,	me,
-	int,			which_stage)
+ *  We store charset info in the HTParentAnchor object, for several
+ *  "stages".  (See UCDefs.h)
+ *  A stream method is supposed to know what stage in the model it is.
+ *
+ *  General model	MIME	 ->  parser  ->  structured  ->  HText
+ *  e.g., text/html
+ *	from HTTP:	HTMIME.c ->  SGML.c  ->  HTML.c      ->  GridText.c
+ *     text/plain
+ *	from file:	HTFile.c ->  HTPlain.c		     ->  GridText.c
+ *
+ *  The lock/set_by is used to lock e.g. a charset set by an explicit
+ *  HTTP MIME header against overriding by a HTML META tag - the MIME
+ *  header has higher priority.  Defaults (from -assume_.. options etc.)
+ *  will not override charset explicitly given by server.
+ *
+ *  Some advantages of keeping this in the HTAnchor:
+ *  - Global variables are bad.
+ *  - Can remember a charset given by META tag when toggling to SOURCE view.
+ *  - Can remember a charset given by <A CHARSET=...> href in another doc.
+ *
+ *  We don't modify the HTParentAnchor's charset element
+ *  here, that one will only be set when explicitly given.
+ */
+LYUCcharset *HTAnchor_getUCInfoStage(HTParentAnchor *me,
+				     int which_stage)
 {
     if (me && !me->UCStages) {
 	int i;
-	int chndl = UCLYhndl_for_unspec;  /* always >= 0 */
-	UCAnchorInfo * stages = typecalloc(UCAnchorInfo);
+	int chndl = UCLYhndl_for_unspec;	/* always >= 0 */
+	UCAnchorInfo *stages = typecalloc(UCAnchorInfo);
+
 	if (stages == NULL)
 	    outofmem(__FILE__, "HTAnchor_getUCInfoStage");
 	for (i = 0; i < UCT_STAGEMAX; i++) {
@@ -1303,68 +1253,69 @@
 		chndl = UCLYhndl_for_unrec;
 	    if (chndl < 0)
 		/*
-		**  UCLYhndl_for_unrec not defined :-(
-		**  fallback to UCLYhndl_for_unspec which always valid.
-		*/
-		chndl = UCLYhndl_for_unspec;  /* always >= 0 */
+		 * UCLYhndl_for_unrec not defined :-(
+		 * fallback to UCLYhndl_for_unspec which always valid.
+		 */
+		chndl = UCLYhndl_for_unspec;	/* always >= 0 */
 	}
 	memcpy(&stages->s[UCT_STAGE_MIME].C, &LYCharSet_UC[chndl],
 	       sizeof(LYUCcharset));
+
 	stages->s[UCT_STAGE_MIME].lock = UCT_SETBY_DEFAULT;
 	stages->s[UCT_STAGE_MIME].LYhndl = chndl;
 	me->UCStages = stages;
     }
     if (me) {
-	return( &me->UCStages->s[which_stage].C);
+	return (&me->UCStages->s[which_stage].C);
     }
-    return(NULL);
+    return (NULL);
 }
 
-PUBLIC int HTAnchor_getUCLYhndl ARGS2(
-	HTParentAnchor *,	me,
-	int,			which_stage)
+int HTAnchor_getUCLYhndl(HTParentAnchor *me,
+			 int which_stage)
 {
     if (me) {
 	if (!me->UCStages) {
 	    /*
-	     *	This will allocate and initialize, if not yet done.
+	     * This will allocate and initialize, if not yet done.
 	     */
 	    (void) HTAnchor_getUCInfoStage(me, which_stage);
 	}
 	if (me->UCStages->s[which_stage].lock > UCT_SETBY_NONE) {
-	    return( me->UCStages->s[which_stage].LYhndl);
+	    return (me->UCStages->s[which_stage].LYhndl);
 	}
     }
-    return( -1);
+    return (-1);
 }
 
 #ifdef CAN_SWITCH_DISPLAY_CHARSET
-PRIVATE void setup_switch_display_charset ARGS2(HTParentAnchor *, me, int, h)
+static void setup_switch_display_charset(HTParentAnchor *me, int h)
 {
-    if (!Switch_Display_Charset(h,SWITCH_DISPLAY_CHARSET_MAYBE))
+    if (!Switch_Display_Charset(h, SWITCH_DISPLAY_CHARSET_MAYBE))
 	return;
     HTAnchor_setUCInfoStage(me, current_char_set,
-			    UCT_STAGE_HTEXT, UCT_SETBY_MIME); /* highest priorty! */
+			    UCT_STAGE_HTEXT, UCT_SETBY_MIME);	/* highest priorty! */
     HTAnchor_setUCInfoStage(me, current_char_set,
-			    UCT_STAGE_STRUCTURED, UCT_SETBY_MIME); /* highest priorty! */
-    CTRACE((tfp, "changing UCInfoStage: HTEXT/STRUCTURED stages charset='%s'.\n",
+			    UCT_STAGE_STRUCTURED, UCT_SETBY_MIME);	/* highest priorty! */
+    CTRACE((tfp,
+	    "changing UCInfoStage: HTEXT/STRUCTURED stages charset='%s'.\n",
 	    LYCharSet_UC[current_char_set].MIMEname));
 }
 #endif
 
-PUBLIC LYUCcharset * HTAnchor_setUCInfoStage ARGS4(
-	HTParentAnchor *,	me,
-	int,			LYhndl,
-	int,			which_stage,
-	int,			set_by)
+LYUCcharset *HTAnchor_setUCInfoStage(HTParentAnchor *me,
+				     int LYhndl,
+				     int which_stage,
+				     int set_by)
 {
     if (me) {
 	/*
-	 *  This will allocate and initialize, if not yet done.
+	 * This will allocate and initialize, if not yet done.
 	 */
-	LYUCcharset * p = HTAnchor_getUCInfoStage(me, which_stage);
+	LYUCcharset *p = HTAnchor_getUCInfoStage(me, which_stage);
+
 	/*
-	 *  Can we override?
+	 * Can we override?
 	 */
 	if (set_by >= me->UCStages->s[which_stage].lock) {
 #ifdef CAN_SWITCH_DISPLAY_CHARSET
@@ -1374,31 +1325,30 @@
 	    me->UCStages->s[which_stage].LYhndl = LYhndl;
 	    if (LYhndl >= 0) {
 		memcpy(p, &LYCharSet_UC[LYhndl], sizeof(LYUCcharset));
+
 #ifdef CAN_SWITCH_DISPLAY_CHARSET
 		/* Allow a switch to a more suitable display charset */
-		if ( LYhndl != ohandle && which_stage == UCT_STAGE_PARSER )
+		if (LYhndl != ohandle && which_stage == UCT_STAGE_PARSER)
 		    setup_switch_display_charset(me, LYhndl);
 #endif
-	    }
-	    else {
+	    } else {
 		p->UChndl = -1;
 	    }
-	    return(p);
+	    return (p);
 	}
     }
-    return(NULL);
+    return (NULL);
 }
 
-PUBLIC LYUCcharset * HTAnchor_resetUCInfoStage ARGS4(
-	HTParentAnchor *,	me,
-	int,			LYhndl,
-	int,			which_stage,
-	int,			set_by)
+LYUCcharset *HTAnchor_resetUCInfoStage(HTParentAnchor *me,
+				       int LYhndl,
+				       int which_stage,
+				       int set_by)
 {
     int ohandle;
 
     if (!me || !me->UCStages)
-	return(NULL);
+	return (NULL);
     me->UCStages->s[which_stage].lock = set_by;
     ohandle = me->UCStages->s[which_stage].LYhndl;
     me->UCStages->s[which_stage].LYhndl = LYhndl;
@@ -1407,26 +1357,26 @@
     if (LYhndl >= 0 && LYhndl != ohandle && which_stage == UCT_STAGE_PARSER)
 	setup_switch_display_charset(me, LYhndl);
 #endif
-    return( &me->UCStages->s[which_stage].C);
+    return (&me->UCStages->s[which_stage].C);
 }
 
 /*
-**  A set_by of (-1) means use the lock value from the from_stage.
-*/
-PUBLIC LYUCcharset * HTAnchor_copyUCInfoStage ARGS4(
-	HTParentAnchor *,	me,
-	int,			to_stage,
-	int,			from_stage,
-	int,			set_by)
+ *  A set_by of (-1) means use the lock value from the from_stage.
+ */
+LYUCcharset *HTAnchor_copyUCInfoStage(HTParentAnchor *me,
+				      int to_stage,
+				      int from_stage,
+				      int set_by)
 {
     if (me) {
 	/*
-	 *  This will allocate and initialize, if not yet done.
+	 * This will allocate and initialize, if not yet done.
 	 */
-	LYUCcharset * p_from = HTAnchor_getUCInfoStage(me, from_stage);
-	LYUCcharset * p_to = HTAnchor_getUCInfoStage(me, to_stage);
+	LYUCcharset *p_from = HTAnchor_getUCInfoStage(me, from_stage);
+	LYUCcharset *p_to = HTAnchor_getUCInfoStage(me, to_stage);
+
 	/*
-	 *  Can we override?
+	 * Can we override?
 	 */
 	if (set_by == -1)
 	    set_by = me->UCStages->s[from_stage].lock;
@@ -1441,16 +1391,17 @@
 		me->UCStages->s[from_stage].LYhndl;
 #ifdef CAN_SWITCH_DISPLAY_CHARSET
 	    /* Allow a switch to a more suitable display charset */
-	    if ( me->UCStages->s[to_stage].LYhndl >= 0
-		 && me->UCStages->s[to_stage].LYhndl != ohandle
-		 && to_stage == UCT_STAGE_PARSER )
+	    if (me->UCStages->s[to_stage].LYhndl >= 0
+		&& me->UCStages->s[to_stage].LYhndl != ohandle
+		&& to_stage == UCT_STAGE_PARSER)
 		setup_switch_display_charset(me,
 					     me->UCStages->s[to_stage].LYhndl);
 #endif
 	    if (p_to != p_from)
 		memcpy(p_to, p_from, sizeof(LYUCcharset));
-	    return(p_to);
+
+	    return (p_to);
 	}
     }
-    return(NULL);
+    return (NULL);
 }
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/HTAtom.c
+++ lynx-cur-2.8.6/WWW/Library/Implementation/HTAtom.c
@@ -1,21 +1,21 @@
 /*			Atoms: Names to numbers			HTAtom.c
-**			=======================
-**
-**	Atoms are names which are given representative pointer values
-**	so that they can be stored more efficiently, and comparisons
-**	for equality done more efficiently.
-**
-**	Atoms are kept in a hash table consisting of an array of linked lists.
-**
-** Authors:
-**	TBL	Tim Berners-Lee, WorldWideWeb project, CERN
-**	(c) Copyright CERN 1991 - See Copyright.html
-**
-*/
+ *			=======================
+ *
+ *	Atoms are names which are given representative pointer values
+ *	so that they can be stored more efficiently, and comparisons
+ *	for equality done more efficiently.
+ *
+ *	Atoms are kept in a hash table consisting of an array of linked lists.
+ *
+ * Authors:
+ *	TBL	Tim Berners-Lee, WorldWideWeb project, CERN
+ *	(c) Copyright CERN 1991 - See Copyright.html
+ *
+ */
 
 #include <HTUtils.h>
 
-#define HASH_SIZE	101		/* Tunable */
+#define HASH_SIZE	101	/* Tunable */
 #include <HTAtom.h>
 
 #include <HTList.h>
@@ -23,14 +23,14 @@
 #include <LYexit.h>
 #include <LYLeaks.h>
 
-PRIVATE HTAtom * hash_table[HASH_SIZE];
-PRIVATE BOOL initialised = NO;
+static HTAtom *hash_table[HASH_SIZE];
+static BOOL initialised = NO;
 
 /*
  *	To free off all atoms.
  */
 #ifdef LY_FIND_LEAKS
-PRIVATE void free_atoms NOPARAMS;
+static void free_atoms(void);
 #endif
 
 /*
@@ -38,19 +38,20 @@
  */
 #define HASH_FUNCTION(cp_hash) ((strlen(cp_hash) * UCH(*cp_hash)) % HASH_SIZE)
 
-PUBLIC HTAtom * HTAtom_for ARGS1(CONST char *, string)
+HTAtom *HTAtom_for(const char *string)
 {
     int hash;
-    HTAtom * a;
+    HTAtom *a;
 
-    /*		First time around, clear hash table
-    */
+    /* First time around, clear hash table
+     */
     /*
-     *	Memory leak fixed.
-     *  05-29-94 Lynx 2-3-1 Garrett Arch Blythe
+     * Memory leak fixed.
+     * 05-29-94 Lynx 2-3-1 Garrett Arch Blythe
      */
     if (!initialised) {
 	int i;
+
 	for (i = 0; i < HASH_SIZE; i++)
 	    hash_table[i] = (HTAtom *) 0;
 	initialised = YES;
@@ -59,29 +60,29 @@
 #endif
     }
 
-    /*		Generate hash function
-    */
+    /*          Generate hash function
+     */
     hash = HASH_FUNCTION(string);
 
-    /*		Search for the string in the list
-    */
+    /*          Search for the string in the list
+     */
     for (a = hash_table[hash]; a; a = a->next) {
 	if (0 == strcasecomp(a->name, string)) {
 	    /* CTRACE((tfp, "HTAtom: Old atom %p for `%s'\n", a, string)); */
-	    return a;				/* Found: return it */
+	    return a;		/* Found: return it */
 	}
     }
 
-    /*		Generate a new entry
-    */
-    a = (HTAtom *)malloc(sizeof(*a));
+    /*          Generate a new entry
+     */
+    a = (HTAtom *) malloc(sizeof(*a));
     if (a == NULL)
 	outofmem(__FILE__, "HTAtom_for");
-    a->name = (char *)malloc(strlen(string)+1);
+    a->name = (char *) malloc(strlen(string) + 1);
     if (a->name == NULL)
 	outofmem(__FILE__, "HTAtom_for");
     strcpy(a->name, string);
-    a->next = hash_table[hash];		/* Put onto the head of list */
+    a->next = hash_table[hash];	/* Put onto the head of list */
     hash_table[hash] = a;
 #ifdef NOT_DEFINED
     CTRACE((tfp, "HTAtom: New atom %p for `%s'\n", a, string));
@@ -99,32 +100,33 @@
  *	Revision History:
  *		05-29-94	created Lynx 2-3-1 Garrett Arch Blythe
  */
-PRIVATE void free_atoms NOARGS
+static void free_atoms(void)
 {
-	auto int i_counter;
-	HTAtom *HTAp_freeme;
+    auto int i_counter;
+    HTAtom *HTAp_freeme;
+
+    /*
+     * Loop through all lists of atoms.
+     */
+    for (i_counter = 0; i_counter < HASH_SIZE; i_counter++) {
 	/*
-	 *	Loop through all lists of atoms.
+	 * Loop through the list.
 	 */
-	for (i_counter = 0; i_counter < HASH_SIZE; i_counter++)	{
-		/*
-		 *	Loop through the list.
-		 */
-		while (hash_table[i_counter] != NULL)	{
-			/*
-			 *	Free off atoms and any members.
-			 */
-			HTAp_freeme = hash_table[i_counter];
-			hash_table[i_counter] = HTAp_freeme->next;
-			FREE(HTAp_freeme->name);
-			FREE(HTAp_freeme);
-		}
+	while (hash_table[i_counter] != NULL) {
+	    /*
+	     * Free off atoms and any members.
+	     */
+	    HTAp_freeme = hash_table[i_counter];
+	    hash_table[i_counter] = HTAp_freeme->next;
+	    FREE(HTAp_freeme->name);
+	    FREE(HTAp_freeme);
 	}
+    }
 }
 #endif /* LY_FIND_LEAKS */
 
-PRIVATE BOOL mime_match ARGS2(CONST char *, name,
-			      CONST char *, templ)
+static BOOL mime_match(const char *name,
+		       const char *templ)
 {
     if (name && templ) {
 	static char *n1 = NULL;
@@ -132,14 +134,14 @@
 	char *n2;
 	char *t2;
 
-	StrAllocCopy(n1, name);		/* These also free the ones	*/
-	StrAllocCopy(t1, templ);	/* from previous call.		*/
+	StrAllocCopy(n1, name);	/* These also free the ones */
+	StrAllocCopy(t1, templ);	/* from previous call.  */
 
-	if (!(n2 = strchr(n1, '/'))  ||  !(t2 = strchr(t1, '/')))
+	if (!(n2 = strchr(n1, '/')) || !(t2 = strchr(t1, '/')))
 	    return NO;
 
-	*(n2++) = (char)0;
-	*(t2++) = (char)0;
+	*(n2++) = (char) 0;
+	*(t2++) = (char) 0;
 
 	if ((0 == strcmp(t1, "*") || 0 == strcmp(t1, n1)) &&
 	    (0 == strcmp(t2, "*") || 0 == strcmp(t2, n2)))
@@ -148,8 +150,7 @@
     return NO;
 }
 
-
-PUBLIC HTList *HTAtom_templateMatches ARGS1(CONST char *, templ)
+HTList *HTAtom_templateMatches(const char *templ)
 {
     HTList *matches = HTList_new();
 
@@ -158,12 +159,11 @@
 	HTAtom *cur;
 
 	for (i = 0; i < HASH_SIZE; i++) {
-	    for (cur = hash_table[i];  cur;  cur = cur->next) {
+	    for (cur = hash_table[i]; cur; cur = cur->next) {
 		if (mime_match(cur->name, templ))
-		    HTList_addObject(matches, (void*)cur);
+		    HTList_addObject(matches, (void *) cur);
 	    }
 	}
     }
     return matches;
 }
-
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/HTChunk.c
+++ lynx-cur-2.8.6/WWW/Library/Implementation/HTChunk.c
@@ -1,7 +1,7 @@
 /*		Chunk handling:	Flexible arrays
-**		===============================
-**
-*/
+ *		===============================
+ *
+ */
 
 #include <HTUtils.h>
 #include <HTChunk.h>
@@ -9,9 +9,9 @@
 #include <LYLeaks.h>
 
 /*
-**	Initialize a chunk with a certain allocation unit
-*/
-PUBLIC void HTChunkInit ARGS2 (HTChunk *,ch, int,grow)
+ *	Initialize a chunk with a certain allocation unit
+ */
+void HTChunkInit(HTChunk *ch, int grow)
 {
     ch->data = 0;
     ch->growby = grow;
@@ -20,21 +20,23 @@
 }
 
 /*	Create a chunk with a certain allocation unit
-**	--------------
-*/
-PUBLIC HTChunk * HTChunkCreate ARGS1 (int,grow)
+ *	--------------
+ */
+HTChunk *HTChunkCreate(int grow)
 {
-    HTChunk * ch = typecalloc(HTChunk);
+    HTChunk *ch = typecalloc(HTChunk);
+
     if (ch == NULL)
 	outofmem(__FILE__, "creation of chunk");
 
-    HTChunkInit (ch, grow);
+    HTChunkInit(ch, grow);
     return ch;
 }
 
-PUBLIC HTChunk * HTChunkCreateMayFail ARGS2 (int,grow, int,failok)
+HTChunk *HTChunkCreateMayFail(int grow, int failok)
 {
-    HTChunk * ch = typecalloc(HTChunk);
+    HTChunk *ch = typecalloc(HTChunk);
+
     if (ch == NULL) {
 	if (!failok) {
 	    outofmem(__FILE__, "creation of chunk");
@@ -42,65 +44,67 @@
 	    return ch;
 	}
     }
-    HTChunkInit (ch, grow);
+    HTChunkInit(ch, grow);
     ch->failok = failok;
     return ch;
 }
 
 /*	Create a chunk with a certain allocation unit and ensured size
-**	--------------
-*/
-PUBLIC HTChunk * HTChunkCreate2 ARGS2 (int,grow, size_t, needed)
+ *	--------------
+ */
+HTChunk *HTChunkCreate2(int grow, size_t needed)
 {
-    HTChunk * ch = typecalloc(HTChunk);
+    HTChunk *ch = typecalloc(HTChunk);
+
     if (ch == NULL)
 	outofmem(__FILE__, "HTChunkCreate2");
 
-    HTChunkInit (ch, grow);
+    HTChunkInit(ch, grow);
     if (needed > 0) {
-	ch->allocated = needed-1 - ((needed-1) % ch->growby)
-	    + ch->growby; /* Round up */
+	ch->allocated = needed - 1 - ((needed - 1) % ch->growby)
+	    + ch->growby;	/* Round up */
 	CTRACE((tfp, "HTChunkCreate2: requested %d, allocate %d\n",
-	       (int) needed, ch->allocated));
+		(int) needed, ch->allocated));
 	ch->data = typecallocn(char, ch->allocated);
+
 	if (!ch->data)
 	    outofmem(__FILE__, "HTChunkCreate2 data");
     }
     return ch;
 }
 
-
 /*	Clear a chunk of all data
-**	--------------------------
-*/
-PUBLIC void HTChunkClear ARGS1 (HTChunk *,ch)
+ *	--------------------------
+ */
+void HTChunkClear(HTChunk *ch)
 {
     FREE(ch->data);
     ch->size = 0;
     ch->allocated = 0;
 }
 
-
 /*	Free a chunk
-**	------------
-*/
-PUBLIC void HTChunkFree ARGS1 (HTChunk *,ch)
+ *	------------
+ */
+void HTChunkFree(HTChunk *ch)
 {
     FREE(ch->data);
     FREE(ch);
 }
 
-
 /*	Realloc the chunk
-**	-----------------
-*/
-PUBLIC BOOL HTChunkRealloc ARGS2 (HTChunk *,ch, int,growby)
+ *	-----------------
+ */
+BOOL HTChunkRealloc(HTChunk *ch, int growby)
 {
     char *data;
+
     ch->allocated = ch->allocated + growby;
 
-    data = ch->data ? (char *)realloc(ch->data, ch->allocated)
-			: typecallocn(char, ch->allocated);
+    data = (ch->data
+	    ? (char *) realloc(ch->data, ch->allocated)
+	    : typecallocn(char, ch->allocated));
+
     if (data) {
 	ch->data = data;
     } else if (ch->failok) {
@@ -112,13 +116,12 @@
     return TRUE;
 }
 
-
 /*	Append a character
-**	------------------
-*/
+ *	------------------
+ */
 /* Warning: the code of this function is defined as macro in SGML.c. Change
   the macro or undefine it in SGML.c when changing this function. -VH */
-PUBLIC void HTChunkPutc ARGS2 (HTChunk *,ch, char,c)
+void HTChunkPutc(HTChunk *ch, char c)
 {
     if (ch->size >= ch->allocated) {
 	if (!HTChunkRealloc(ch, ch->growby))
@@ -127,26 +130,29 @@
     ch->data[ch->size++] = c;
 }
 
-
 /*	Ensure a certain size
-**	---------------------
-*/
-PUBLIC void HTChunkEnsure ARGS2 (HTChunk *,ch, int,needed)
-{
-    if (needed <= ch->allocated) return;
-    ch->allocated = needed-1 - ((needed-1) % ch->growby)
-			     + ch->growby; /* Round up */
-    ch->data = ch->data ? (char *)realloc(ch->data, ch->allocated)
-			: typecallocn(char, ch->allocated);
+ *	---------------------
+ */
+void HTChunkEnsure(HTChunk *ch, int needed)
+{
+    if (needed <= ch->allocated)
+	return;
+    ch->allocated = needed - 1 - ((needed - 1) % ch->growby)
+	+ ch->growby;		/* Round up */
+    ch->data = ch->data ? (char *) realloc(ch->data, ch->allocated)
+	: typecallocn(char, ch->allocated);
+
     if (ch->data == NULL)
 	outofmem(__FILE__, "HTChunkEnsure");
 }
 
-PUBLIC void HTChunkPutb ARGS3 (HTChunk *,ch, CONST char *,b, int,l)
+void HTChunkPutb(HTChunk *ch, const char *b, int l)
 {
-    if (l <= 0) return;
+    if (l <= 0)
+	return;
     if (ch->size + l > ch->allocated) {
-	int growby = l - (l % ch->growby) + ch->growby; /* Round up */
+	int growby = l - (l % ch->growby) + ch->growby;		/* Round up */
+
 	if (!HTChunkRealloc(ch, growby))
 	    return;
     }
@@ -154,32 +160,31 @@
     ch->size += l;
 }
 
-#define PUTC(code) ch->data[ch->size++] = (char)(code)
+#define PUTC(code)  ch->data[ch->size++] = (char)(code)
 #define PUTC2(code) ch->data[ch->size++] = (char)(0x80|(0x3f &(code)))
 
-PUBLIC void HTChunkPutUtf8Char ARGS2(
-	HTChunk *,	ch,
-	UCode_t,	code)
+void HTChunkPutUtf8Char(HTChunk *ch, UCode_t code)
 {
     int utflen;
 
     if (TOASCII(code) < 128)
 	utflen = 1;
-    else if   (code <     0x800L) {
+    else if (code < 0x800L) {
 	utflen = 2;
-    } else if (code <   0x10000L) {
+    } else if (code < 0x10000L) {
 	utflen = 3;
-    } else if (code <  0x200000L) {
+    } else if (code < 0x200000L) {
 	utflen = 4;
     } else if (code < 0x4000000L) {
 	utflen = 5;
-    } else if (code<=0x7fffffffL) {
+    } else if (code <= 0x7fffffffL) {
 	utflen = 6;
     } else
 	utflen = 0;
 
     if (ch->size + utflen > ch->allocated) {
 	int growby = (ch->growby >= utflen) ? ch->growby : utflen;
+
 	if (!HTChunkRealloc(ch, growby))
 	    return;
     }
@@ -188,36 +193,36 @@
     case 0:
 	return;
     case 1:
-	ch->data[ch->size++] = (char)code;
+	ch->data[ch->size++] = (char) code;
 	return;
     case 2:
-	PUTC(0xc0 | (code>>6));
+	PUTC(0xc0 | (code >> 6));
 	break;
     case 3:
-	PUTC(0xe0 | (code>>12));
+	PUTC(0xe0 | (code >> 12));
 	break;
     case 4:
-	PUTC(0xf0 | (code>>18));
+	PUTC(0xf0 | (code >> 18));
 	break;
     case 5:
-	PUTC(0xf8 | (code>>24));
+	PUTC(0xf8 | (code >> 24));
 	break;
     case 6:
-	PUTC(0xfc | (code>>30));
+	PUTC(0xfc | (code >> 30));
 	break;
     }
     switch (utflen) {
     case 6:
-	PUTC2(code>>24);
+	PUTC2(code >> 24);
 	/* FALLTHRU */
     case 5:
-	PUTC2(code>>18);
+	PUTC2(code >> 18);
 	/* FALLTHRU */
     case 4:
-	PUTC2(code>>12);
+	PUTC2(code >> 12);
 	/* FALLTHRU */
     case 3:
-	PUTC2(code>>6);
+	PUTC2(code >> 6);
 	/* FALLTHRU */
     case 2:
 	PUTC2(code);
@@ -226,25 +231,27 @@
 }
 
 /*	Terminate a chunk
-**	-----------------
-*/
-PUBLIC void HTChunkTerminate ARGS1 (HTChunk *,ch)
+ *	-----------------
+ */
+void HTChunkTerminate(HTChunk *ch)
 {
-    HTChunkPutc(ch, (char)0);
+    HTChunkPutc(ch, (char) 0);
 }
 
-
 /*	Append a string
-**	---------------
-*/
-PUBLIC void HTChunkPuts ARGS2 (HTChunk *,ch, CONST char *,s)
-{
-    CONST char * p;
-    for (p = s; *p; p++) {
-	if (ch->size >= ch->allocated) {
-	    if (!HTChunkRealloc(ch, ch->growby))
-		return;
+ *	---------------
+ */
+void HTChunkPuts(HTChunk *ch, const char *s)
+{
+    const char *p;
+
+    if (s != NULL) {
+	for (p = s; *p; p++) {
+	    if (ch->size >= ch->allocated) {
+		if (!HTChunkRealloc(ch, ch->growby))
+		    return;
+	    }
+	    ch->data[ch->size++] = *p;
 	}
-	ch->data[ch->size++] = *p;
     }
 }
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/HTMLGen.c
+++ lynx-cur-2.8.6/WWW/Library/Implementation/HTMLGen.c
@@ -1,16 +1,16 @@
 /*		HTML Generator
-**		==============
-**
-**	This version of the HTML object sends HTML markup to the output stream.
-**
-** Bugs:	Line wrapping is not done at all.
-**		All data handled as PCDATA.
-**		Should convert old XMP, LISTING and PLAINTEXT to PRE.
-**
-**	It is not obvious to me right now whether the HEAD should be generated
-**	from the incomming data or the anchor.	Currently it is from the former
-**	which is cleanest.
-*/
+ *		==============
+ *
+ *	This version of the HTML object sends HTML markup to the output stream.
+ *
+ * Bugs:	Line wrapping is not done at all.
+ *		All data handled as PCDATA.
+ *		Should convert old XMP, LISTING and PLAINTEXT to PRE.
+ *
+ *	It is not obvious to me right now whether the HEAD should be generated
+ *	from the incomming data or the anchor.	Currently it is from the former
+ *	which is cleanest.
+ */
 
 #include <HTUtils.h>
 
@@ -34,6 +34,7 @@
 #endif
 
 #include <LYGlobalDefs.h>
+#include <LYCurses.h>
 #include <LYLeaks.h>
 
 #define PUTC(c) (*me->targetClass.put_character)(me->target, c)
@@ -41,7 +42,7 @@
 #define PUTB(s,l) (*me->targetClass.put_block)(me->target, s, l)
 
 #ifdef USE_COLOR_STYLE
-PUBLIC char class_string[TEMPSTRINGSIZE];
+char class_string[TEMPSTRINGSIZE];
 
 static char *Style_className = NULL;
 static char myHash[128];
@@ -49,53 +50,52 @@
 #endif
 
 /*		HTML Object
-**		-----------
-*/
+ *		-----------
+ */
 struct _HTStream {
-	CONST HTStreamClass *		isa;
-	HTStream *			target;
-	HTStreamClass			targetClass;	/* COPY for speed */
+    const HTStreamClass *isa;
+    HTStream *target;
+    HTStreamClass targetClass;	/* COPY for speed */
 };
 
 struct _HTStructured {
-	CONST HTStructuredClass *	isa;
-	HTStream *			target;
-	HTStreamClass			targetClass;	/* COPY for speed */
-
-	char				buffer[BUFFER_SIZE+1]; /* 1for NL */
-	int				buffer_maxchars;
-	char *				write_pointer;
-	char *				line_break [MAX_CLEANNESS+1];
-	int				cleanness;
-	BOOL				overflowed;
-	BOOL				delete_line_break_char[MAX_CLEANNESS+1];
-	BOOL				preformatted;
-	BOOL				escape_specials;
-	BOOL				in_attrval;
+    const HTStructuredClass *isa;
+    HTStream *target;
+    HTStreamClass targetClass;	/* COPY for speed */
+
+    char buffer[BUFFER_SIZE + 1];	/* 1for NL */
+    int buffer_maxchars;
+    char *write_pointer;
+    char *line_break[MAX_CLEANNESS + 1];
+    int cleanness;
+    BOOL overflowed;
+    BOOL delete_line_break_char[MAX_CLEANNESS + 1];
+    BOOL preformatted;
+    BOOL escape_specials;
+    BOOL in_attrval;
 #ifdef USE_COLOR_STYLE
-	HText *				text;
+    HText *text;
 #endif
 };
 
 /*	Flush Buffer
-**	------------
-*/
+ *	------------
+ */
 
-PRIVATE void flush_breaks ARGS1(
-	HTStructured *,		me)
+static void flush_breaks(HTStructured * me)
 {
     int i;
-    for (i=0; i<= MAX_CLEANNESS; i++) {
+
+    for (i = 0; i <= MAX_CLEANNESS; i++) {
 	me->line_break[i] = NULL;
     }
 }
 
-PRIVATE void HTMLGen_flush ARGS1(
-	HTStructured *,		me)
+static void HTMLGen_flush(HTStructured * me)
 {
-    (*me->targetClass.put_block)(me->target,
-				 me->buffer,
-				 me->write_pointer - me->buffer);
+    (*me->targetClass.put_block) (me->target,
+				  me->buffer,
+				  me->write_pointer - me->buffer);
     me->write_pointer = me->buffer;
     flush_breaks(me);
     me->cleanness = 0;
@@ -104,34 +104,30 @@
 
 #ifdef USE_COLOR_STYLE
 /*
- *  We need to flush our buffer each time before we effect a color style
- *  change, this also relies on the subsequent stage not doing any
- *  buffering - this is currently true, in cases where it matters the
- *  target stream should be the HTPlain converter.
- *  The flushing currently prevents reasonable line breaking in lines
- *  with tags.  Since color styles help visual scanning of displayed
- *  source lines, and long lines are wrapped in GridText anyway, this
- *  is probably acceptable (or even A Good Thing - more to see in one
- *  screenful).
- *  The pointer to the HText structure is initialized here before
- *  we effect the first style change.  Getting it from the global
- *  HTMainText variable isn't very clean, since it relies on the fact
- *  that HText_new() has already been called for the current stream
- *  stack's document by the time we start processing the first element;
- *  we rely on HTMLGenerator's callers (HTMLParsedPresent in particular)
- *  to guarantee this when it matters.  Normally the target stream will
- *  have been setup by HTPlainPresent, which does what we need in this
- *  respect.  (A check whether we have the right output stream could be
- *  done by checking that targetClass.name is "PlainPresenter" or similar.)
- *
- *  All special color style handling is only done if LYPreparsedSource
- *  is set.  We could always do it for displaying source generated by
- *  an internal gateway, but this makes the rule more simple for the
- *  user: color styles are applied to html source only with the
- *  -preparsed flag. - kw
+ * We need to flush our buffer each time before we effect a color style change,
+ * this also relies on the subsequent stage not doing any buffering - this is
+ * currently true, in cases where it matters the target stream should be the
+ * HTPlain converter.  The flushing currently prevents reasonable line breaking
+ * in lines with tags.  Since color styles help visual scanning of displayed
+ * source lines, and long lines are wrapped in GridText anyway, this is
+ * probably acceptable (or even A Good Thing - more to see in one screenful). 
+ * The pointer to the HText structure is initialized here before we effect the
+ * first style change.  Getting it from the global HTMainText variable isn't
+ * very clean, since it relies on the fact that HText_new() has already been
+ * called for the current stream stack's document by the time we start
+ * processing the first element; we rely on HTMLGenerator's callers
+ * (HTMLParsedPresent in particular) to guarantee this when it matters. 
+ * Normally the target stream will have been setup by HTPlainPresent, which
+ * does what we need in this respect.  (A check whether we have the right
+ * output stream could be done by checking that targetClass.name is
+ * "PlainPresenter" or similar.)
+ *
+ * All special color style handling is only done if LYPreparsedSource is set. 
+ * We could always do it for displaying source generated by an internal
+ * gateway, but this makes the rule more simple for the user:  color styles are
+ * applied to html source only with the -preparsed flag.  - kw
  */
-PRIVATE void do_cstyle_flush ARGS1(
-	HTStructured *,		me)
+static void do_cstyle_flush(HTStructured * me)
 {
     if (!me->text && LYPreparsedSource) {
 	me->text = HTMainText;
@@ -143,19 +139,18 @@
 #endif /* COLOR_STYLE */
 
 /*	Weighted optional line break
-**
-**	We keep track of all the breaks for when we chop the line
-*/
+ *
+ *	We keep track of all the breaks for when we chop the line
+ */
 
-PRIVATE void allow_break ARGS3(
-	HTStructured *, me,
-	int,		new_cleanness,
-	BOOL,		dlbc)
+static void allow_break(HTStructured * me, int new_cleanness,
+			BOOL dlbc)
 {
-    if (dlbc && me->write_pointer == me->buffer) dlbc = NO;
+    if (dlbc && me->write_pointer == me->buffer)
+	dlbc = NO;
     me->line_break[new_cleanness] =
-			 dlbc ? me->write_pointer - 1 /* Point to space */
-			      : me->write_pointer ;   /* point to gap */
+	dlbc ? me->write_pointer - 1	/* Point to space */
+	: me->write_pointer;	/* point to gap */
     me->delete_line_break_char[new_cleanness] = dlbc;
     if (new_cleanness >= me->cleanness &&
 	(me->overflowed || me->line_break[new_cleanness] > me->buffer))
@@ -163,40 +158,38 @@
 }
 
 /*	Character handling
-**	------------------
-**
-**	The tricky bits are the line break handling.  This attempts
-**	to synchrononise line breaks on sentence or phrase ends.  This
-**	is important if one stores SGML files in a line-oriented code
-**	repository, so that if a small change is made, line ends don't
-**	shift in a ripple-through to apparently change a large part of the
-**	file.  We give extra "cleanness" to spaces appearing directly
-**	after periods (full stops), [semi]colons and commas.
-**	   This should make the source files easier to read and modify
-**	by hand, too, though this is not a primary design consideration. TBL
-*/
-PRIVATE void HTMLGen_put_character ARGS2(
-	HTStructured *,		me,
-	char,			c)
+ *	------------------
+ *
+ *	The tricky bits are the line break handling.  This attempts
+ *	to synchrononise line breaks on sentence or phrase ends.  This
+ *	is important if one stores SGML files in a line-oriented code
+ *	repository, so that if a small change is made, line ends don't
+ *	shift in a ripple-through to apparently change a large part of the
+ *	file.  We give extra "cleanness" to spaces appearing directly
+ *	after periods (full stops), [semi]colons and commas.
+ *	   This should make the source files easier to read and modify
+ *	by hand, too, though this is not a primary design consideration. TBL
+ */
+static void HTMLGen_put_character(HTStructured * me, char c)
 {
     if (me->escape_specials && UCH(c) < 32) {
 	if (c == HT_NON_BREAK_SPACE || c == HT_EN_SPACE ||
-	    c == LY_SOFT_HYPHEN) { /* recursion... */
+	    c == LY_SOFT_HYPHEN) {	/* recursion... */
 	    HTMLGen_put_character(me, '&');
 	    HTMLGen_put_character(me, '#');
 	    HTMLGen_put_character(me, 'x');
-	    switch(c) {
-	    case HT_NON_BREAK_SPACE: /* &#xA0; */
+	    switch (c) {
+	    case HT_NON_BREAK_SPACE:	/* &#xA0; */
 		HTMLGen_put_character(me, 'A');
 		HTMLGen_put_character(me, '0');
 		break;
-	    case HT_EN_SPACE: /* &#x2002; */
+	    case HT_EN_SPACE:	/* &#x2002; */
 		HTMLGen_put_character(me, '2');
 		HTMLGen_put_character(me, '0');
 		HTMLGen_put_character(me, '0');
 		HTMLGen_put_character(me, '2');
 		break;
-	    case LY_SOFT_HYPHEN: /* &#xAD; */
+	    case LY_SOFT_HYPHEN:	/* &#xAD; */
 		HTMLGen_put_character(me, 'A');
 		HTMLGen_put_character(me, 'D');
 		break;
@@ -213,54 +206,62 @@
     }
 
     /* Figure our whether we can break at this point
-    */
+     */
     if ((!me->preformatted && (c == ' ' || c == '\t'))) {
 	int new_cleanness = 3;
+
 	if (me->write_pointer > (me->buffer + 1)) {
 	    char delims[5];
-	    char * p;
-	    strcpy(delims, ",;:.");		/* @@ english bias */
+	    char *p;
+
+	    strcpy(delims, ",;:.");	/* @@ english bias */
 	    p = strchr(delims, me->write_pointer[-2]);
-	    if (p) new_cleanness = p - delims + 6;
-	    if (!me->in_attrval) new_cleanness += 10;
+	    if (p)
+		new_cleanness = p - delims + 6;
+	    if (!me->in_attrval)
+		new_cleanness += 10;
 	}
 	allow_break(me, new_cleanness, YES);
     }
 
     /*
-     *	Flush buffer out when full, or whenever the line is over
-     *	the nominal maximum and we can break at all
+     * Flush buffer out when full, or whenever the line is over the nominal
+     * maximum and we can break at all
      */
     if (me->write_pointer >= me->buffer + me->buffer_maxchars ||
 	(me->overflowed && me->cleanness)) {
 	if (me->cleanness) {
 	    char line_break_char = me->line_break[me->cleanness][0];
-	    char * saved = me->line_break[me->cleanness];
+	    char *saved = me->line_break[me->cleanness];
 
-	    if (me->delete_line_break_char[me->cleanness]) saved++;
+	    if (me->delete_line_break_char[me->cleanness])
+		saved++;
 	    me->line_break[me->cleanness][0] = '\n';
-	    (*me->targetClass.put_block)(me->target,
-					 me->buffer,
-			       me->line_break[me->cleanness] - me->buffer + 1);
+	    (*me->targetClass.put_block) (me->target,
+					  me->buffer,
+					  me->line_break[me->cleanness] -
+					  me->buffer + 1);
 	    me->line_break[me->cleanness][0] = line_break_char;
-	    {  /* move next line in */
-		char * p = saved;
+	    {			/* move next line in */
+		char *p = saved;
 		char *q;
-		for (q = me->buffer; p < me->write_pointer; )
+
+		for (q = me->buffer; p < me->write_pointer;)
 		    *q++ = *p++;
 	    }
 	    me->cleanness = 0;
 	    /* Now we have to check whether ther are any perfectly good breaks
-	    ** which weren't good enough for the last line but may be
-	    **	good enough for the next
-	    */
+	     * which weren't good enough for the last line but may be good
+	     * enough for the next
+	     */
 	    {
 		int i;
-		for(i=0; i <= MAX_CLEANNESS; i++) {
+
+		for (i = 0; i <= MAX_CLEANNESS; i++) {
 		    if (me->line_break[i] != NULL &&
 			me->line_break[i] > saved) {
 			me->line_break[i] = me->line_break[i] -
-						(saved-me->buffer);
+			    (saved - me->buffer);
 			me->cleanness = i;
 		    } else {
 			me->line_break[i] = NULL;
@@ -269,13 +270,13 @@
 	    }
 
 	    me->delete_line_break_char[0] = 0;
-	    me->write_pointer = me->write_pointer - (saved-me->buffer);
+	    me->write_pointer = me->write_pointer - (saved - me->buffer);
 	    me->overflowed = NO;
 
 	} else {
-	    (*me->targetClass.put_block)(me->target,
-					 me->buffer,
-					 me->buffer_maxchars);
+	    (*me->targetClass.put_block) (me->target,
+					  me->buffer,
+					  me->buffer_maxchars);
 	    me->write_pointer = me->buffer;
 	    flush_breaks(me);
 	    me->overflowed = YES;
@@ -284,46 +285,40 @@
 }
 
 /*	String handling
-**	---------------
-*/
-PRIVATE void HTMLGen_put_string ARGS2(
-	HTStructured *,		me,
-	CONST char *,		s)
+ *	---------------
+ */
+static void HTMLGen_put_string(HTStructured * me, const char *s)
 {
-    CONST char * p;
+    const char *p;
 
     for (p = s; *p; p++)
 	HTMLGen_put_character(me, *p);
 }
 
-PRIVATE void HTMLGen_write ARGS3(
-	HTStructured *,		me,
-	CONST char *,		s,
-	int,			l)
+static void HTMLGen_write(HTStructured * me, const char *s,
+			  int l)
 {
-    CONST char * p;
+    const char *p;
 
     for (p = s; p < (s + l); p++)
 	HTMLGen_put_character(me, *p);
 }
 
 /*	Start Element
-**	-------------
-**
-**	Within the opening tag, there may be spaces
-**	and the line may be broken at these spaces.
-*/
-PRIVATE int HTMLGen_start_element ARGS6(
-	HTStructured *,		me,
-	int,			element_number,
-	CONST BOOL*,		present,
-	CONST char **,		value,
-	int,			charset GCC_UNUSED,
-	char **,		insert GCC_UNUSED)
+ *	-------------
+ *
+ *	Within the opening tag, there may be spaces
+ *	and the line may be broken at these spaces.
+ */
+static int HTMLGen_start_element(HTStructured * me, int element_number,
+				 const BOOL *present,
+				 const char **value,
+				 int charset GCC_UNUSED,
+				 char **insert GCC_UNUSED)
 {
     int i;
     BOOL was_preformatted = me->preformatted;
-    HTTag * tag = &HTML_dtd.tags[element_number];
+    HTTag *tag = &HTML_dtd.tags[element_number];
 
 #if defined(USE_COLOR_STYLE)
     char *title = NULL;
@@ -331,49 +326,47 @@
 
     if (LYPreparsedSource) {
 	/*
-	 *  Same logic as in HTML_start_element, copied from there. - kw
+	 * Same logic as in HTML_start_element, copied from there.  - kw
 	 */
-	HTSprintf (&Style_className, ";%s", HTML_dtd.tags[element_number].name);
-	strcpy (myHash, HTML_dtd.tags[element_number].name);
-	if (class_string[0])
-	{
+	HTSprintf(&Style_className, ";%s", HTML_dtd.tags[element_number].name);
+	strcpy(myHash, HTML_dtd.tags[element_number].name);
+	if (class_string[0]) {
 	    int len = strlen(myHash);
-	    sprintf (myHash + len, ".%.*s", (int) sizeof(myHash) - len - 2, class_string);
-	    HTSprintf (&Style_className, ".%s", class_string);
+
+	    sprintf(myHash + len, ".%.*s", (int) sizeof(myHash) - len - 2, class_string);
+	    HTSprintf(&Style_className, ".%s", class_string);
 	}
 	class_string[0] = '\0';
 	strtolower(myHash);
 	hcode = hash_code(myHash);
 	strtolower(Style_className);
 
-	if (TRACE_STYLE)
-	{
+	if (TRACE_STYLE) {
 	    fprintf(tfp, "CSSTRIM:%s -> %d", myHash, hcode);
-	    if (hashStyles[hcode].code!=hcode)
-	    {
+	    if (hashStyles[hcode].code != hcode) {
 		char *rp = strrchr(myHash, '.');
+
 		fprintf(tfp, " (undefined) %s\n", myHash);
-		if (rp)
-		{
+		if (rp) {
 		    int hcd;
-		    *rp = '\0'; /* trim the class */
+
+		    *rp = '\0';	/* trim the class */
 		    hcd = hash_code(myHash);
 		    fprintf(tfp, "CSS:%s -> %d", myHash, hcd);
-		    if (hashStyles[hcd].code!=hcd)
+		    if (hashStyles[hcd].code != hcd)
 			fprintf(tfp, " (undefined) %s\n", myHash);
 		    else
 			fprintf(tfp, " ca=%d\n", hashStyles[hcd].color);
 		}
-	    }
-	    else
+	    } else
 		fprintf(tfp, " ca=%d\n", hashStyles[hcode].color);
 	}
 
-	if (displayStyles[element_number + STARTAT].color > -2) /* actually set */
+	if (displayStyles[element_number + STARTAT].color > -2)		/* actually set */
 	{
 	    CTRACE2(TRACE_STYLE,
 		    (tfp, "CSSTRIM: start_element: top <%s>\n",
-			  HTML_dtd.tags[element_number].name));
+		     HTML_dtd.tags[element_number].name));
 	    do_cstyle_flush(me);
 	    HText_characterStyle(me->text, hcode, 1);
 	}
@@ -384,6 +377,7 @@
     HTMLGen_put_string(me, tag->name);
     if (present) {
 	BOOL had_attr = NO;
+
 	for (i = 0; i < tag->number_of_attributes; i++) {
 	    if (present[i]) {
 		had_attr = YES;
@@ -391,14 +385,14 @@
 		allow_break(me, 11, YES);
 #ifdef USE_COLOR_STYLE
 		/*
-		 *  Try to mimic HTML_start_element's special handling
-		 *  for HTML_LINK.  If applicable, color the displayed
-		 *  attribute / value pairs differently. - kw
+		 * Try to mimic HTML_start_element's special handling for
+		 * HTML_LINK.  If applicable, color the displayed attribute /
+		 * value pairs differently.  - kw
 		 */
 		if (LYPreparsedSource &&
 		    element_number == HTML_LINK && !title &&
 		    present[HTML_LINK_CLASS] &&
-		    value && *value[HTML_LINK_CLASS]!='\0' &&
+		    value && *value[HTML_LINK_CLASS] != '\0' &&
 		    !present[HTML_LINK_REV] &&
 		    (present[HTML_LINK_REL] || present[HTML_LINK_HREF])) {
 		    if (present[HTML_LINK_TITLE] && *value[HTML_LINK_TITLE]) {
@@ -406,7 +400,7 @@
 			LYTrimHead(title);
 			LYTrimTail(title);
 		    }
-		    if ((!title || *title=='\0') && present[HTML_LINK_REL]) {
+		    if ((!title || *title == '\0') && present[HTML_LINK_REL]) {
 			StrAllocCopy(title, value[HTML_LINK_REL]);
 		    }
 		    if (title && *title) {
@@ -432,8 +426,9 @@
 			HTMLGen_put_string(me, "='");
 			HTMLGen_put_string(me, value[i]);
 			HTMLGen_put_character(me, '\'');
-		    } else {  /* attribute value has both kinds of quotes */
-			CONST char *p;
+		    } else {	/* attribute value has both kinds of quotes */
+			const char *p;
+
 			HTMLGen_put_string(me, "=\"");
 			for (p = value[i]; *p; p++) {
 			    if (*p != '"') {
@@ -452,7 +447,7 @@
 #ifdef USE_COLOR_STYLE
 	if (had_attr && LYPreparsedSource && element_number == HTML_LINK) {
 	    /*
-	     *  Clean up after special HTML_LINK handling - kw
+	     * Clean up after special HTML_LINK handling - kw
 	     */
 	    if (title && *title) {
 		do_cstyle_flush(me);
@@ -465,15 +460,15 @@
 	if (had_attr)
 	    allow_break(me, 12, NO);
     }
-    HTMLGen_put_string(me, ">"); /* got rid of \n LJM */
+    HTMLGen_put_string(me, ">");	/* got rid of \n LJM */
 
     /*
-     *	Make very specific HTML assumption that PRE can't be nested!
+     * Make very specific HTML assumption that PRE can't be nested!
      */
-    me->preformatted = (element_number == HTML_PRE)  ? YES : was_preformatted;
+    me->preformatted = (element_number == HTML_PRE) ? YES : was_preformatted;
 
     /*
-     *	Can break after element start.
+     * Can break after element start.
      */
     if (!me->preformatted && tag->contents != SGML_EMPTY) {
 	if (HTML_dtd.tags[element_number].contents == SGML_ELEMENT)
@@ -481,15 +476,13 @@
 	else
 	    allow_break(me, 2, NO);
     }
-
 #if defined(USE_COLOR_STYLE)
     /*
-     *  Same logic as in HTML_start_element, copied from there. - kw
+     * Same logic as in HTML_start_element, copied from there.  - kw
      */
 
     /* end really empty tags straight away */
-    if (LYPreparsedSource && ReallyEmptyTagNum(element_number))
-    {
+    if (LYPreparsedSource && ReallyEmptyTagNum(element_number)) {
 	CTRACE2(TRACE_STYLE,
 		(tfp, "STYLE:begin_element:ending EMPTY element style\n"));
 	do_cstyle_flush(me);
@@ -500,14 +493,14 @@
 #endif /* USE_COLOR_STYLE */
     if (element_number == HTML_OBJECT && tag->contents == SGML_LITTERAL) {
 	/*
-	 *  These conditions only approximate the ones used in HTML.c.
-	 *  Let our SGML parser know that further content is to be parsed
-	 *  normally not literally. - kw
+	 * These conditions only approximate the ones used in HTML.c.  Let our
+	 * SGML parser know that further content is to be parsed normally not
+	 * literally.  - kw
 	 */
 	if (!present) {
 	    return HT_PARSER_OTHER_CONTENT;
 	} else if (!present[HTML_OBJECT_DECLARE] &&
-		   !(present[HTML_OBJECT_NAME]  &&
+		   !(present[HTML_OBJECT_NAME] &&
 		     value[HTML_OBJECT_NAME] && *value[HTML_OBJECT_NAME])) {
 	    if (present[HTML_OBJECT_SHAPES] ||
 		!(present[HTML_OBJECT_USEMAP] &&
@@ -519,25 +512,23 @@
 }
 
 /*		End Element
-**		-----------
-**
-*/
+ *		-----------
+ *
+ */
 /*	When we end an element, the style must be returned to that
-**	in effect before that element.	Note that anchors (etc?)
-**	don't have an associated style, so that we must scan down the
-**	stack for an element with a defined style. (In fact, the styles
-**	should be linked to the whole stack not just the top one.)
-**	TBL 921119
-*/
-PRIVATE int HTMLGen_end_element ARGS3(
-	HTStructured *,		me,
-	int,			element_number,
-	char **,		insert GCC_UNUSED)
+ *	in effect before that element.	Note that anchors (etc?)
+ *	don't have an associated style, so that we must scan down the
+ *	stack for an element with a defined style. (In fact, the styles
+ *	should be linked to the whole stack not just the top one.)
+ *	TBL 921119
+ */
+static int HTMLGen_end_element(HTStructured * me, int element_number,
+			       char **insert GCC_UNUSED)
 {
     if (!me->preformatted &&
 	HTML_dtd.tags[element_number].contents != SGML_EMPTY) {
 	/*
-	 *  Can break before element end.
+	 * Can break before element end.
 	 */
 	if (HTML_dtd.tags[element_number].contents == SGML_ELEMENT)
 	    allow_break(me, 14, NO);
@@ -552,7 +543,7 @@
     }
 #ifdef USE_COLOR_STYLE
     /*
-     *  Same logic as in HTML_end_element, copied from there. - kw
+     * Same logic as in HTML_end_element, copied from there.  - kw
      */
     TrimColorClass(HTML_dtd.tags[element_number].name,
 		   Style_className, &hcode);
@@ -568,49 +559,43 @@
 }
 
 /*		Expanding entities
-**		------------------
-**
-*/
-PRIVATE int HTMLGen_put_entity ARGS2(
-	HTStructured *,		me,
-	int,			entity_number)
+ *		------------------
+ *
+ */
+static int HTMLGen_put_entity(HTStructured * me, int entity_number)
 {
     int nent = HTML_dtd.number_of_entities;
 
     HTMLGen_put_character(me, '&');
     if (entity_number < nent) {
-      HTMLGen_put_string(me, HTML_dtd.entity_names[entity_number]);
+	HTMLGen_put_string(me, HTML_dtd.entity_names[entity_number]);
     }
     HTMLGen_put_character(me, ';');
     return HT_OK;
 }
 
 /*	Free an HTML object
-**	-------------------
-**
-*/
-PRIVATE void HTMLGen_free ARGS1(
-	HTStructured *,		me)
+ *	-------------------
+ *
+ */
+static void HTMLGen_free(HTStructured * me)
 {
-    (*me->targetClass.put_character)(me->target, '\n');
+    (*me->targetClass.put_character) (me->target, '\n');
     HTMLGen_flush(me);
-    (*me->targetClass._free)(me->target);	/* ripple through */
+    (*me->targetClass._free) (me->target);	/* ripple through */
 #ifdef USE_COLOR_STYLE
     FREE(Style_className);
 #endif
     FREE(me);
 }
 
-PRIVATE void PlainToHTML_free ARGS1(
-	HTStructured *,		me)
+static void PlainToHTML_free(HTStructured * me)
 {
     HTMLGen_end_element(me, HTML_PRE, 0);
     HTMLGen_free(me);
 }
 
-PRIVATE void HTMLGen_abort ARGS2(
-	HTStructured *,		me,
-	HTError,		e GCC_UNUSED)
+static void HTMLGen_abort(HTStructured * me, HTError e GCC_UNUSED)
 {
     HTMLGen_free(me);
 #ifdef USE_COLOR_STYLE
@@ -618,82 +603,77 @@
 #endif
 }
 
-PRIVATE void PlainToHTML_abort ARGS2(
-	HTStructured *,		me,
-	HTError,		e GCC_UNUSED)
+static void PlainToHTML_abort(HTStructured * me, HTError e GCC_UNUSED)
 {
     PlainToHTML_free(me);
 }
 
 /*	Structured Object Class
-**	-----------------------
-*/
-PRIVATE CONST HTStructuredClass HTMLGeneration = /* As opposed to print etc */
+ *	-----------------------
+ */
+static const HTStructuredClass HTMLGeneration =		/* As opposed to print etc */
 {
-	"HTMLGen",
-	HTMLGen_free,
-	HTMLGen_abort,
-	HTMLGen_put_character,	HTMLGen_put_string, HTMLGen_write,
-	HTMLGen_start_element,	HTMLGen_end_element,
-	HTMLGen_put_entity
+    "HTMLGen",
+    HTMLGen_free,
+    HTMLGen_abort,
+    HTMLGen_put_character, HTMLGen_put_string, HTMLGen_write,
+    HTMLGen_start_element, HTMLGen_end_element,
+    HTMLGen_put_entity
 };
 
 /*	Subclass-specific Methods
-**	-------------------------
-*/
-extern int LYcols;			/* LYCurses.h, set in LYMain.c	*/
-
-PUBLIC HTStructured * HTMLGenerator ARGS1(
-	HTStream *,		output)
+ *	-------------------------
+ */
+HTStructured *HTMLGenerator(HTStream *output)
 {
-    HTStructured* me = (HTStructured*)malloc(sizeof(*me));
+    HTStructured *me = (HTStructured *) malloc(sizeof(*me));
+
     if (me == NULL)
 	outofmem(__FILE__, "HTMLGenerator");
     me->isa = &HTMLGeneration;
 
     me->target = output;
-    me->targetClass = *me->target->isa; /* Copy pointers to routines for speed*/
+    me->targetClass = *me->target->isa;		/* Copy pointers to routines for speed */
 
     me->write_pointer = me->buffer;
     flush_breaks(me);
     me->line_break[0] = me->buffer;
-    me->cleanness =	0;
+    me->cleanness = 0;
     me->overflowed = NO;
     me->delete_line_break_char[0] = NO;
-    me->preformatted =	NO;
+    me->preformatted = NO;
     me->in_attrval = NO;
 
     /*
-     *	For what line length should we attempt to wrap ? - kw
+     * For what line length should we attempt to wrap ?  - kw
      */
     if (!LYPreparsedSource) {
-	me->buffer_maxchars = 80; /* work as before - kw */
+	me->buffer_maxchars = 80;	/* work as before - kw */
     } else if (dump_output_width > 1) {
-	me->buffer_maxchars = dump_output_width; /* try to honor -width - kw */
+	me->buffer_maxchars = dump_output_width;	/* try to honor -width - kw */
     } else if (dump_output_immediately) {
-	me->buffer_maxchars = 80; /* try to honor -width - kw */
+	me->buffer_maxchars = 80;	/* try to honor -width - kw */
     } else {
-	me->buffer_maxchars = LYcols - 2;
-	if (me->buffer_maxchars < 38) /* too narrow, let GridText deal */
+	me->buffer_maxchars = (LYcolLimit - 1);
+	if (me->buffer_maxchars < 38)	/* too narrow, let GridText deal */
 	    me->buffer_maxchars = 40;
     }
-    if (me->buffer_maxchars > 900) /* likely not true - kw */
+    if (me->buffer_maxchars > 900)	/* likely not true - kw */
 	me->buffer_maxchars = 78;
-    if (me->buffer_maxchars > BUFFER_SIZE) /* must not be larger! */
+    if (me->buffer_maxchars > BUFFER_SIZE)	/* must not be larger! */
 	me->buffer_maxchars = BUFFER_SIZE - 2;
 
     /*
-     *	If dump_output_immediately is set, there likely isn't anything
-     *	after this stream to interpret the Lynx special chars.	Also
-     *	if they get displayed via HTPlain, that will probably make
-     *	non-breaking space chars etc. invisible.  So let's translate
-     *	them to numerical character references.  For debugging
-     *	purposes we'll use the new hex format.
+     * If dump_output_immediately is set, there likely isn't anything after
+     * this stream to interpret the Lynx special chars.  Also if they get
+     * displayed via HTPlain, that will probably make non-breaking space chars
+     * etc.  invisible.  So let's translate them to numerical character
+     * references.  For debugging purposes we'll use the new hex format.
      */
     me->escape_specials = LYPreparsedSource;
 
 #ifdef USE_COLOR_STYLE
-    me->text = NULL;	/* Will be initialized when first needed. - kw */
+    me->text = NULL;		/* Will be initialized when first needed. - kw */
     FREE(Style_className);
     class_string[0] = '\0';
 #endif /* COLOR_STYLE */
@@ -702,46 +682,46 @@
 }
 
 /*	Stream Object Class
-**	-------------------
-**
-**	This object just converts a plain text stream into HTML
-**	It is officially a structured strem but only the stream bits exist.
-**	This is just the easiest way of typecasting all the routines.
-*/
-PRIVATE CONST HTStructuredClass PlainToHTMLConversion =
+ *	-------------------
+ *
+ *	This object just converts a plain text stream into HTML
+ *	It is officially a structured strem but only the stream bits exist.
+ *	This is just the easiest way of typecasting all the routines.
+ */
+static const HTStructuredClass PlainToHTMLConversion =
 {
-	"plaintexttoHTML",
-	HTMLGen_free,
-	PlainToHTML_abort,
-	HTMLGen_put_character,
-	HTMLGen_put_string,
-	HTMLGen_write,
-	NULL,		/* Structured stuff */
-	NULL,
-	NULL
+    "plaintexttoHTML",
+    HTMLGen_free,
+    PlainToHTML_abort,
+    HTMLGen_put_character,
+    HTMLGen_put_string,
+    HTMLGen_write,
+    NULL,			/* Structured stuff */
+    NULL,
+    NULL
 };
 
 /*	HTConverter from plain text to HTML Stream
-**	------------------------------------------
-*/
-PUBLIC HTStream* HTPlainToHTML ARGS3(
-	HTPresentation *,	pres GCC_UNUSED,
-	HTParentAnchor *,	anchor GCC_UNUSED,
-	HTStream *,		sink)
+ *	------------------------------------------
+ */
+HTStream *HTPlainToHTML(HTPresentation *pres GCC_UNUSED,
+			HTParentAnchor *anchor GCC_UNUSED,
+			HTStream *sink)
 {
-    HTStructured *me = (HTStructured *)malloc(sizeof(*me));
+    HTStructured *me = (HTStructured *) malloc(sizeof(*me));
+
     if (me == NULL)
 	outofmem(__FILE__, "PlainToHTML");
-    me->isa = (CONST HTStructuredClass *)&PlainToHTMLConversion;
+    me->isa = (const HTStructuredClass *) &PlainToHTMLConversion;
 
     /*
-     *	Copy pointers to routines for speed.
+     * Copy pointers to routines for speed.
      */
     me->target = sink;
     me->targetClass = *me->target->isa;
     me->write_pointer = me->buffer;
     flush_breaks(me);
-    me->cleanness =	0;
+    me->cleanness = 0;
     me->overflowed = NO;
     me->delete_line_break_char[0] = NO;
     /* try to honor -width - kw */
@@ -752,5 +732,5 @@
     me->preformatted = YES;
     me->escape_specials = NO;
     me->in_attrval = NO;
-    return (HTStream*) me;
+    return (HTStream *) me;
 }
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/HTFWriter.c
+++ lynx-cur-2.8.6/WWW/Library/Implementation/HTFWriter.c
@@ -1,12 +1,12 @@
 /*		FILE WRITER				HTFWrite.h
-**		===========
-**
-**	This version of the stream object just writes to a C file.
-**	The file is assumed open and left open.
-**
-**	Bugs:
-**		strings written must be less than buffer size.
-*/
+ *		===========
+ *
+ *	This version of the stream object just writes to a C file.
+ *	The file is assumed open and left open.
+ *
+ *	Bugs:
+ *		strings written must be less than buffer size.
+ */
 
 #include <HTUtils.h>
 
@@ -20,119 +20,115 @@
 #include <LYLeaks.h>
 
 /*		Stream Object
-**		------------
-*/
+ *		------------
+ */
 
 struct _HTStream {
-	CONST HTStreamClass *	isa;
+    const HTStreamClass *isa;
 
-	FILE *			fp;
-	char *			end_command;
-	char *			remove_command;
-	BOOL			announce;
+    FILE *fp;
+    char *end_command;
+    char *remove_command;
+    BOOL announce;
 };
 
-
 /*_________________________________________________________________________
-**
-**		B L A C K    H O L E    C L A S S
-**
-**	There is only one black hole instance shared by anyone
-**	who wanst a black hole.  These black holes don't radiate,
-**	they just absorb data.
-*/
-PRIVATE void HTBlackHole_put_character ARGS2(HTStream *, me, char, c)
-{}
-PRIVATE void HTBlackHole_put_string ARGS2(HTStream *, me, CONST char*, s)
-{}
-PRIVATE void HTBlackHole_write ARGS3(HTStream *, me, CONST char*, s, int, l)
-{}
-PRIVATE void HTBlackHole_free ARGS1(HTStream *, me)
-{}
-PRIVATE void HTBlackHole_abort ARGS2(HTStream *, me, HTError, e)
-{}
-
+ *
+ *		B L A C K    H O L E    C L A S S
+ *
+ *	There is only one black hole instance shared by anyone
+ *	who wanst a black hole.  These black holes don't radiate,
+ *	they just absorb data.
+ */
+static void HTBlackHole_put_character(HTStream *me, char c)
+{
+}
+static void HTBlackHole_put_string(HTStream *me, const char *s)
+{
+}
+static void HTBlackHole_write(HTStream *me, const char *s, int l)
+{
+}
+static void HTBlackHole_free(HTStream *me)
+{
+}
+static void HTBlackHole_abort(HTStream *me, HTError e)
+{
+}
 
 /*	Black Hole stream
-**	-----------------
-*/
-PRIVATE CONST HTStreamClass HTBlackHoleClass =
-{
-	"BlackHole",
-	HTBlackHole_free,
-	HTBlackHole_abort,
-	HTBlackHole_put_character,	HTBlackHole_put_string,
-	HTBlackHole_write
+ *	-----------------
+ */
+static const HTStreamClass HTBlackHoleClass =
+{
+    "BlackHole",
+    HTBlackHole_free,
+    HTBlackHole_abort,
+    HTBlackHole_put_character, HTBlackHole_put_string,
+    HTBlackHole_write
 };
 
-PRIVATE HTStream HTBlackHoleInstance =
+static HTStream HTBlackHoleInstance =
 {
-	&HTBlackHoleClass,
-	NULL,
-	NULL,
-	NULL,
-	NO
+    &HTBlackHoleClass,
+    NULL,
+    NULL,
+    NULL,
+    NO
 };
 
 /*	Black hole craetion
 */
-PUBLIC HTStream * HTBlackHole NOARGS
+HTStream *HTBlackHole(void)
 {
     return &HTBlackHoleInstance;
 }
 
-
 /*_________________________________________________________________________
-**
-**		F I L E     A C T I O N 	R O U T I N E S
-**  Bug:
-**	All errors are ignored.
-*/
+ *
+ *		F I L E     A C T I O N 	R O U T I N E S
+ *  Bug:
+ *	All errors are ignored.
+ */
 
 /*	Character handling
-**	------------------
-*/
+ *	------------------
+ */
 
-PRIVATE void HTFWriter_put_character ARGS2(HTStream *, me, char, c)
+static void HTFWriter_put_character(HTStream *me, char c)
 {
     putc(c, me->fp);
 }
 
-
-
 /*	String handling
-**	---------------
-**
-**	Strings must be smaller than this buffer size.
-*/
-PRIVATE void HTFWriter_put_string ARGS2(HTStream *, me, CONST char*, s)
+ *	---------------
+ *
+ *	Strings must be smaller than this buffer size.
+ */
+static void HTFWriter_put_string(HTStream *me, const char *s)
 {
     fputs(s, me->fp);
 }
 
-
 /*	Buffer write.  Buffers can (and should!) be big.
-**	------------
-*/
-PRIVATE void HTFWriter_write ARGS3(HTStream *, me, CONST char*, s, int, l)
+ *	------------
+ */
+static void HTFWriter_write(HTStream *me, const char *s, int l)
 {
     fwrite(s, 1, l, me->fp);
 }
 
-
-
-
 /*	Free an HTML object
-**	-------------------
-**
-**	Note that the SGML parsing context is freed, but the created
-**	object is not,
-**	as it takes on an existence of its own unless explicitly freed.
-*/
-PRIVATE void HTFWriter_free ARGS1(HTStream *, me)
+ *	-------------------
+ *
+ *	Note that the SGML parsing context is freed, but the created
+ *	object is not,
+ *	as it takes on an existence of its own unless explicitly freed.
+ */
+static void HTFWriter_free(HTStream *me)
 {
     fclose(me->fp);
-    if (me->end_command) {		/* Temp file */
+    if (me->end_command) {	/* Temp file */
 	_HTProgress(me->end_command);	/* Tell user what's happening */
 	system(me->end_command);
 	FREE(me->end_command);
@@ -148,10 +144,10 @@
 /*	End writing
 */
 
-PRIVATE void HTFWriter_abort ARGS2(HTStream *, me, HTError, e)
+static void HTFWriter_abort(HTStream *me, HTError e)
 {
     fclose(me->fp);
-    if (me->end_command) {		/* Temp file */
+    if (me->end_command) {	/* Temp file */
 	CTRACE((tfp, "HTFWriter: Aborting: file not executed.\n"));
 	FREE(me->end_command);
 	if (me->remove_command) {
@@ -163,33 +159,32 @@
     FREE(me);
 }
 
-
-
 /*	Structured Object Class
-**	-----------------------
-*/
-PRIVATE CONST HTStreamClass HTFWriter = /* As opposed to print etc */
-{
-	"FileWriter",
-	HTFWriter_free,
-	HTFWriter_abort,
-	HTFWriter_put_character,	HTFWriter_put_string,
-	HTFWriter_write
+ *	-----------------------
+ */
+static const HTStreamClass HTFWriter =	/* As opposed to print etc */
+{
+    "FileWriter",
+    HTFWriter_free,
+    HTFWriter_abort,
+    HTFWriter_put_character, HTFWriter_put_string,
+    HTFWriter_write
 };
 
-
 /*	Subclass-specific Methods
-**	-------------------------
-*/
+ *	-------------------------
+ */
 
-PUBLIC HTStream* HTFWriter_new ARGS1(FILE *, fp)
+HTStream *HTFWriter_new(FILE *fp)
 {
-    HTStream* me;
+    HTStream *me;
 
-    if (!fp) return NULL;
+    if (!fp)
+	return NULL;
 
-    me = (HTStream*)malloc(sizeof(*me));
-    if (me == NULL) outofmem(__FILE__, "HTML_new");
+    me = (HTStream *) malloc(sizeof(*me));
+    if (me == NULL)
+	outofmem(__FILE__, "HTML_new");
     me->isa = &HTFWriter;
 
     me->fp = fp;
@@ -201,27 +196,24 @@
 }
 
 /*	Make system command from template
-**	---------------------------------
-**
-**	See mailcap spec for description of template.
-*/
+ *	---------------------------------
+ *
+ *	See mailcap spec for description of template.
+ */
 /* @@ to be written.  sprintfs will do for now.  */
 
-
-
 /*	Take action using a system command
-**	----------------------------------
-**
-**	originally from Ghostview handling by Marc Andreseen.
-**	Creates temporary file, writes to it, executes system command
-**	on end-document.  The suffix of the temp file can be given
-**	in case the application is fussy, or so that a generic opener can
-**	be used.
-*/
-PUBLIC HTStream* HTSaveAndExecute ARGS3(
-	HTPresentation *,	pres,
-	HTParentAnchor *,	anchor,	/* Not used */
-	HTStream *,		sink)	/* Not used */
+ *	----------------------------------
+ *
+ *	originally from Ghostview handling by Marc Andreseen.
+ *	Creates temporary file, writes to it, executes system command
+ *	on end-document.  The suffix of the temp file can be given
+ *	in case the application is fussy, or so that a generic opener can
+ *	be used.
+ */
+HTStream *HTSaveAndExecute(HTPresentation *pres,
+			   HTParentAnchor *anchor,	/* Not used */
+			   HTStream *sink)	/* Not used */
 
 #ifdef UNIX
 #define REMOVE_COMMAND "/bin/rm -f %s\n"
@@ -233,30 +225,31 @@
 #ifdef REMOVE_COMMAND
 {
     char *fnam;
-    CONST char * suffix;
+    const char *suffix;
 
-    HTStream* me;
+    HTStream *me;
 
     if (HTClientHost) {
 	HTAlert(CANNOT_SAVE_REMOTE);
 	return HTBlackHole();
     }
 
-    me = (HTStream*)malloc(sizeof(*me));
-    if (me == NULL) outofmem(__FILE__, "Save and execute");
+    me = (HTStream *) malloc(sizeof(*me));
+    if (me == NULL)
+	outofmem(__FILE__, "Save and execute");
     me->isa = &HTFWriter;
 
     /* Save the file under a suitably suffixed name */
 
     suffix = HTFileSuffix(pres->rep, anchor->content_encoding);
 
-    fnam = (char *)malloc (L_tmpnam + 16 + strlen(suffix));
+    fnam = (char *) malloc(L_tmpnam + 16 + strlen(suffix));
     if (fnam == NULL)
 	outofmem(__FILE__, "HTSaveAndExecute");
-    tmpnam (fnam);
+    tmpnam(fnam);
     strcat(fnam, suffix);
 
-    me->fp = fopen (fnam, BIN_W);
+    me->fp = fopen(fnam, BIN_W);
     if (!me->fp) {
 	HTAlert(CANNOT_OPEN_TEMP);
 	FREE(fnam);
@@ -282,37 +275,38 @@
     return me;
 }
 
-#else	/* can do remove */
-{ return NULL; }
+#else				/* can do remove */
+{
+    return NULL;
+}
 #endif
 
-
 /*	Save Locally
-**	------------
-**
-**  Bugs:
-**	GUI Apps should open local Save panel here really.
-**
-*/
-PUBLIC HTStream* HTSaveLocally ARGS3(
-	HTPresentation *,	pres,
-	HTParentAnchor *,	anchor,	/* Not used */
-	HTStream *,		sink)	/* Not used */
+ *	------------
+ *
+ *  Bugs:
+ *	GUI Apps should open local Save panel here really.
+ *
+ */
+HTStream *HTSaveLocally(HTPresentation *pres,
+			HTParentAnchor *anchor,		/* Not used */
+			HTStream *sink)		/* Not used */
 
 {
     char *fnam;
     char *answer;
-    CONST char * suffix;
+    const char *suffix;
 
-    HTStream* me;
+    HTStream *me;
 
     if (HTClientHost) {
 	HTAlert(CANNOT_SAVE_REMOTE);
 	return HTBlackHole();
     }
 
-    me = (HTStream*)malloc(sizeof(*me));
-    if (me == NULL) outofmem(__FILE__, "SaveLocally");
+    me = (HTStream *) malloc(sizeof(*me));
+    if (me == NULL)
+	outofmem(__FILE__, "SaveLocally");
     me->isa = &HTFWriter;
     me->end_command = NULL;
     me->remove_command = NULL;	/* If needed, put into end_command */
@@ -322,18 +316,18 @@
 
     suffix = HTFileSuffix(pres->rep, anchor->content_encoding);
 
-    fnam = (char *)malloc (L_tmpnam + 16 + strlen(suffix));
+    fnam = (char *) malloc(L_tmpnam + 16 + strlen(suffix));
     if (fnam == NULL)
 	outofmem(__FILE__, "HTSaveLocally");
-    tmpnam (fnam);
+    tmpnam(fnam);
     strcat(fnam, suffix);
 
-    /*	Save Panel */
+    /*  Save Panel */
     answer = HTPrompt(GIVE_FILENAME, fnam);
 
     FREE(fnam);
 
-    me->fp = fopen (answer, BIN_W);
+    me->fp = fopen(answer, BIN_W);
     if (!me->fp) {
 	HTAlert(CANNOT_OPEN_OUTPUT);
 	FREE(answer);
@@ -345,8 +339,6 @@
     return me;
 }
 
-
-
 /*	Format Converter using system command
-**	-------------------------------------
-*/
+ *	-------------------------------------
+ */
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/HTPlain.c
+++ lynx-cur-2.8.6/WWW/Library/Implementation/HTPlain.c
@@ -1,15 +1,15 @@
 /*		Plain text object		HTWrite.c
-**		=================
-**
-**	This version of the stream object just writes to a socket.
-**	The socket is assumed open and left open.
-**
-**	Bugs:
-**		strings written must be less than buffer size.
-*/
+ *		=================
+ *
+ *	This version of the stream object just writes to a socket.
+ *	The socket is assumed open and left open.
+ *
+ *	Bugs:
+ *		strings written must be less than buffer size.
+ */
 
 #include <HTUtils.h>
-#include <LYCharVals.h>  /* S/390 -- gil -- 0288 */
+#include <LYCharVals.h>		/* S/390 -- gil -- 0288 */
 
 #include <HTPlain.h>
 
@@ -30,51 +30,50 @@
 #include <LYCharSets.h>
 #include <LYLeaks.h>
 
-PUBLIC int HTPlain_lastraw = -1;
-PRIVATE int HTPlain_bs_pending = 0; /* 1:bs 2:underline 3:underline+bs - kw */
+static int HTPlain_lastraw = -1;
+static int HTPlain_bs_pending = 0;	/* 1:bs 2:underline 3:underline+bs - kw */
 
 /*		HTML Object
-**		-----------
-*/
+ *		-----------
+ */
 struct _HTStream {
-    CONST HTStreamClass *	isa;
-    HText *			text;
+    const HTStreamClass *isa;
+    HText *text;
     /*
-    **	The node_anchor UCInfo and handle for the input (PARSER) stage. - FM
-    */
-    LYUCcharset		*	inUCI;
-    int				inUCLYhndl;
+     * The node_anchor UCInfo and handle for the input (PARSER) stage.  - FM
+     */
+    LYUCcharset *inUCI;
+    int inUCLYhndl;
     /*
-    **	The node_anchor UCInfo and handle for the output (HTEXT) stage. - FM
-    */
-    LYUCcharset	*		outUCI;
+     * The node_anchor UCInfo and handle for the output (HTEXT) stage.  - FM
+     */
+    LYUCcharset *outUCI;
     int outUCLYhndl;
     /*
-    **	Counter, value, buffer and pointer for UTF-8 handling. - FM
-    */
-    char			utf_count;
-    UCode_t			utf_char;
-    char			utf_buf[8];
-    char *			utf_buf_p;
+     * Counter, value, buffer and pointer for UTF-8 handling.  - FM
+     */
+    char utf_count;
+    UCode_t utf_char;
+    char utf_buf[8];
+    char *utf_buf_p;
     /*
-    **	The charset transformation structure. - FM
-    */
-    UCTransParams		T;
+     * The charset transformation structure.  - FM
+     */
+    UCTransParams T;
 };
 
-PRIVATE char replace_buf [64];	      /* buffer for replacement strings */
+static char replace_buf[64];	/* buffer for replacement strings */
 
-PRIVATE void HTPlain_getChartransInfo ARGS2(
-	HTStream *,		me,
-	HTParentAnchor *,	anchor)
+static void HTPlain_getChartransInfo(HTStream *me, HTParentAnchor *anchor)
 {
     if (me->inUCLYhndl < 0) {
 	HTAnchor_copyUCInfoStage(anchor, UCT_STAGE_PARSER, UCT_STAGE_MIME,
-					 UCT_SETBY_PARSER);
+				 UCT_SETBY_PARSER);
 	me->inUCLYhndl = HTAnchor_getUCLYhndl(anchor, UCT_STAGE_PARSER);
     }
     if (me->outUCLYhndl < 0) {
 	int chndl = HTAnchor_getUCLYhndl(anchor, UCT_STAGE_HTEXT);
+
 	if (chndl < 0) {
 	    chndl = current_char_set;
 	    HTAnchor_setUCInfoStage(anchor, chndl,
@@ -89,41 +88,36 @@
 }
 
 /*	Write the buffer out to the socket
-**	----------------------------------
-*/
+ *	----------------------------------
+ */
 
 /*_________________________________________________________________________
-**
-**			A C T I O N	R O U T I N E S
-*/
+ *
+ *			A C T I O N	R O U T I N E S
+ */
 
-PRIVATE void HTPlain_write PARAMS((
-	HTStream *		me,
-	CONST char *		s,
-	int			l));
+static void HTPlain_write(HTStream *me, const char *s,
+			  int l);
 
 /*	Character handling
-**	------------------
-*/
-PRIVATE void HTPlain_put_character ARGS2(
-	HTStream *,		me,
-	char,			c)
+ *	------------------
+ */
+static void HTPlain_put_character(HTStream *me, char c)
 {
 #ifdef REMOVE_CR_ONLY
     /*
-    **	Throw away \r's.
-    */
+     * Throw away \r's.
+     */
     if (c != '\r') {
-       HText_appendCharacter(me->text, c);
+	HText_appendCharacter(me->text, c);
     }
 #else
     /*
-    **	See HTPlain_write() for explanations of the following code
-    **	(we've been called via HTPlain_put_string() to do for each
-    **	character of a terminated string what HTPlain_write() does
-    **	via a while loop for each character in a stream of given
-    **	length). - FM
-    */
+     * See HTPlain_write() for explanations of the following code (we've been
+     * called via HTPlain_put_string() to do for each character of a terminated
+     * string what HTPlain_write() does via a while loop for each character in
+     * a stream of given length).  - FM
+     */
     if ((HTPlain_lastraw == '\r') && c == '\n') {
 	HTPlain_lastraw = -1;
 	return;
@@ -135,18 +129,17 @@
     HTPlain_lastraw = UCH(c);
     if (c == '\r') {
 	HText_appendCharacter(me->text, '\n');
-    } else if (TOASCII(UCH(c)) >= 127) {  /* S/390 -- gil -- 0305 */
+    } else if (TOASCII(UCH(c)) >= 127) {	/* S/390 -- gil -- 0305 */
 	/*
-	**  For now, don't repeat everything here
-	**  that has been done below - KW
-	*/
+	 * For now, don't repeat everything here that has been done below - KW
+	 */
 	HTPlain_write(me, &c, 1);
     } else if (HTCJK != NOCJK) {
 	HText_appendCharacter(me->text, c);
     } else if (TOASCII(UCH(c)) >= 127 && TOASCII(UCH(c)) < 161 &&
 	       HTPassHighCtrlRaw) {
 	HText_appendCharacter(me->text, c);
-    } else if (UCH(c) == CH_NBSP) { /* S/390 -- gil -- 0341 */
+    } else if (UCH(c) == CH_NBSP) {	/* S/390 -- gil -- 0341 */
 	HText_appendCharacter(me->text, ' ');
     } else if (UCH(c) == CH_SHY) {
 	return;
@@ -158,16 +151,16 @@
 	    !((me->outUCLYhndl == LATIN1) ||
 	      (me->outUCI->enc & (UCT_CP_SUPERSETOF_LAT1)))) {
 	    int len, high, low, i, diff = 1;
-	    CONST char * name;
-	    UCode_t value = (UCode_t)FROMASCII((TOASCII(UCH(c)) - 160));
+	    const char *name;
+	    UCode_t value = (UCode_t) FROMASCII((TOASCII(UCH(c)) - 160));
 
 	    name = HTMLGetEntityName(value);
-	    len =  strlen(name);
+	    len = strlen(name);
 	    for (low = 0, high = HTML_dtd.number_of_entities;
-		high > low;
-		diff < 0 ? (low = i+1) : (high = i)) {
+		 high > low;
+		 diff < 0 ? (low = i + 1) : (high = i)) {
 		/* Binary search */
-		i = (low + (high-low)/2);
+		i = (low + (high - low) / 2);
 		diff = AS_ncmp(HTML_dtd.entity_names[i], name, len);
 		if (diff == 0) {
 		    HText_appendText(me->text,
@@ -185,17 +178,16 @@
 #endif /* REMOVE_CR_ONLY */
 }
 
-
 /*	String handling
-**	---------------
-**
-*/
-PRIVATE void HTPlain_put_string ARGS2(HTStream *, me, CONST char*, s)
+ *	---------------
+ *
+ */
+static void HTPlain_put_string(HTStream *me, const char *s)
 {
 #ifdef REMOVE_CR_ONLY
     HText_appendText(me->text, s);
 #else
-    CONST char * p;
+    const char *p;
 
     if (s == NULL)
 	return;
@@ -205,15 +197,14 @@
 #endif /* REMOVE_CR_ONLY */
 }
 
-
 /*
-**	Entry function for displayed text/plain and WWW_SOURCE strings. - FM
-**	---------------------------------------------------------------
-*/
-PRIVATE void HTPlain_write ARGS3(HTStream *, me, CONST char*, s, int, l)
+ *	Entry function for displayed text/plain and WWW_SOURCE strings. - FM
+ *	---------------------------------------------------------------
+ */
+static void HTPlain_write(HTStream *me, const char *s, int l)
 {
-    CONST char * p;
-    CONST char * e = s+l;
+    const char *p;
+    const char *e = s + l;
     char c;
     unsigned c_unsign;
     BOOL chk;
@@ -223,8 +214,8 @@
     for (p = s; p < e; p++) {
 #ifdef REMOVE_CR_ONLY
 	/*
-	**  Append the whole string, but remove any \r's. - FM
-	*/
+	 * Append the whole string, but remove any \r's.  - FM
+	 */
 	if (*p != '\r') {
 	    HText_appendCharacter(me->text, *p);
 	}
@@ -244,25 +235,24 @@
 		HText_appendCharacter(me->text, '_');
 	    HTPlain_bs_pending = 0;
 	} else if (*p == '_') {
-		if (!HTPlain_bs_pending) {
-		    HTPlain_bs_pending = 2;
-		    HTPlain_lastraw = UCH(*p);
-		    continue;
+	    if (!HTPlain_bs_pending) {
+		HTPlain_bs_pending = 2;
+		HTPlain_lastraw = UCH(*p);
+		continue;
 #if 0
-		} else if (HTPlain_bs_pending != 2) {
-		    HTPlain_bs_pending--; /* 1 -> 0, 3 -> 2 */
-		    HTPlain_lastraw = UCH(*p);
-		    continue;
+	    } else if (HTPlain_bs_pending != 2) {
+		HTPlain_bs_pending--;	/* 1 -> 0, 3 -> 2 */
+		HTPlain_lastraw = UCH(*p);
+		continue;
 #endif
-		}
+	    }
 	}
 
 	/*
-	**  Try to handle lone LFs, CRLFs and lone CRs
-	**  as newline, and to deal with control, ASCII,
-	**  and 8-bit characters based on best guesses
-	**  of what's appropriate. - FM
-	*/
+	 * Try to handle lone LFs, CRLFs and lone CRs as newline, and to deal
+	 * with control, ASCII, and 8-bit characters based on best guesses of
+	 * what's appropriate.  - FM
+	 */
 	if ((HTPlain_lastraw == '\r') && *p == '\n') {
 	    HTPlain_lastraw = -1;
 	    continue;
@@ -278,14 +268,14 @@
 	    HTPlain_bs_pending = 0;
 	} else if (HTPlain_bs_pending == 1) {
 	    HTPlain_bs_pending = 0;
-	    continue;	/* ignore last two of "X\bX" or "X\b_" - kw */
+	    continue;		/* ignore last two of "X\bX" or "X\b_" - kw */
 	} else if (HTPlain_bs_pending == 3) {
 	    if (*p == '_') {
 		HTPlain_bs_pending = 2;
 		continue;	/* ignore last two of "_\b_" - kw */
 	    } else {
 		HTPlain_bs_pending = 0;
-				/* ignore first two of "_\bX" - kw */
+		/* ignore first two of "_\bX" - kw */
 	    }
 	} else if (HTPlain_bs_pending == 2) {
 	    HText_appendCharacter(me->text, '_');
@@ -301,57 +291,55 @@
 	    continue;
 	}
 	/*
-	**  Make sure the character is handled as Unicode
-	**  whenever that's appropriate.  - FM
-	*/
+	 * Make sure the character is handled as Unicode whenever that's
+	 * appropriate.  - FM
+	 */
 	c = *p;
 	c_unsign = UCH(c);
-	code = (UCode_t)c_unsign;
+	code = (UCode_t) c_unsign;
 	saved_char_in = '\0';
 	/*
-	**  Combine any UTF-8 multibytes into Unicode
-	**  to check for special characters. - FM
-	*/
+	 * Combine any UTF-8 multibytes into Unicode to check for special
+	 * characters.  - FM
+	 */
 	if (me->T.decode_utf8) {
 	    /*
-	    **	Combine UTF-8 into Unicode.
-	    **	Incomplete characters silently ignored.
-	    **	from Linux kernel's console.c - KW
-	    */
-	    if (TOASCII(c_unsign) > 127) {  /* S/390 -- gil -- 0371 */
+	     * Combine UTF-8 into Unicode.  Incomplete characters silently
+	     * ignored.  from Linux kernel's console.c - KW
+	     */
+	    if (TOASCII(c_unsign) > 127) {	/* S/390 -- gil -- 0371 */
 		/*
-		**  We have an octet from a multibyte character. - FM
-		*/
+		 * We have an octet from a multibyte character.  - FM
+		 */
 		if (me->utf_count > 0 && (c & 0xc0) == 0x80) {
 		    /*
-		    **	Adjust the UCode_t value, add the octet
-		    **	to the buffer, and decrement the byte
-		    **	count. - FM
-		    */
+		     * Adjust the UCode_t value, add the octet to the buffer,
+		     * and decrement the byte count.  - FM
+		     */
 		    me->utf_char = (me->utf_char << 6) | (c & 0x3f);
 		    me->utf_count--;
 		    *(me->utf_buf_p) = c;
 		    (me->utf_buf_p)++;
 		    if (me->utf_count == 0) {
 			/*
-			**  Got a complete multibyte character.
-			*/
+			 * Got a complete multibyte character.
+			 */
 			*(me->utf_buf_p) = '\0';
 			code = me->utf_char;
 			if (code > 0 && code < 256) {
-			    c = FROMASCII((char)code);
+			    c = FROMASCII((char) code);
 			    c_unsign = UCH(c);
 			}
 		    } else {
 			/*
-			**  Get the next byte. - FM
-			*/
+			 * Get the next byte.  - FM
+			 */
 			continue;
 		    }
 		} else {
 		    /*
-		    **	Start handling a new multibyte character. - FM
-		    */
+		     * Start handling a new multibyte character.  - FM
+		     */
 		    me->utf_buf_p[0] = c;
 		    me->utf_buf_p = &me->utf_buf[1];
 		    if ((*p & 0xe0) == 0xc0) {
@@ -371,74 +359,72 @@
 			me->utf_char = (c & 0x01);
 		    } else {
 			/*
-			 *  We got garbage, so ignore it. - FM
+			 * We got garbage, so ignore it.  - FM
 			 */
 			me->utf_count = 0;
 			me->utf_buf_p[0] = '\0';
 			me->utf_buf_p = me->utf_buf;
 		    }
 		    /*
-		    **	Get the next byte. - FM
-		    */
+		     * Get the next byte.  - FM
+		     */
 		    continue;
 		}
 	    } else if (me->utf_count > 0) {
 		/*
-		**  Got an ASCII character when expecting
-		**  UTF-8 multibytes, so ignore the buffered
-		**  multibye characters and fall through with
-		**  the current ASCII character. - FM
-		*/
+		 * Got an ASCII character when expecting UTF-8 multibytes, so
+		 * ignore the buffered multibye characters and fall through
+		 * with the current ASCII character.  - FM
+		 */
 		me->utf_count = 0;
 		me->utf_buf[0] = '\0';
 		me->utf_buf_p = me->utf_buf;
-		code = (UCode_t)c_unsign;
+		code = (UCode_t) c_unsign;
 	    } else {
 		/*
-		**  Got a valid ASCII character, so fall
-		**  through with it. - FM
-		*/
-		code = (UCode_t)c_unsign;
+		 * Got a valid ASCII character, so fall through with it.  - FM
+		 */
+		code = (UCode_t) c_unsign;
 	    }
 	}
 	/*
-	**  Convert characters from non-UTF-8 charsets
-	**  to Unicode (if appropriate). - FM
-	*/
+	 * Convert characters from non-UTF-8 charsets to Unicode (if
+	 * appropriate).  - FM
+	 */
 	if (!(me->T.decode_utf8 &&
 	      UCH(*p) > 127)) {
 #ifdef NOTDEFINED
 	    if (me->T.strip_raw_char_in)
 		saved_char_in = c;
 #endif /* NOTDEFINED */
-	if (me->T.trans_to_uni &&
-	    (TOASCII(code) >= LYlowest_eightbit[me->inUCLYhndl] ||  /* S/390 -- gil -- 0389 */
-	     (code < ' ' && code != 0 &&
-	     me->T.trans_C0_to_uni))) {
-		/*
-		**  Convert the octet to Unicode. - FM
-		*/
-	    code = (UCode_t)UCTransToUni(c, me->inUCLYhndl);
-	    if (code > 0) {
+	    if (me->T.trans_to_uni &&
+		(TOASCII(code) >= LYlowest_eightbit[me->inUCLYhndl] ||	/* S/390 -- gil -- 0389 */
+		 (code < ' ' && code != 0 &&
+		  me->T.trans_C0_to_uni))) {
+		/*
+		 * Convert the octet to Unicode.  - FM
+		 */
+		code = (UCode_t) UCTransToUni(c, me->inUCLYhndl);
+		if (code > 0) {
 		    saved_char_in = c;
-		if (code < 256) {
-			c = FROMASCII((char)code);
+		    if (code < 256) {
+			c = FROMASCII((char) code);
 			c_unsign = UCH(c);
+		    }
 		}
-	    }
 	    } else if (code < 32 && code != 0 &&
 		       me->T.trans_C0_to_uni) {
 		/*
-		**  Quote from SGML.c:
-		**	"This else if may be too ugly to keep. - KW"
-		*/
+		 * Quote from SGML.c:
+		 * "This else if may be too ugly to keep.  - KW"
+		 */
 		if (me->T.trans_from_uni &&
 		    (((code = UCTransToUni(c, me->inUCLYhndl)) >= 32) ||
 		     (me->T.transp &&
 		      (code = UCTransToUni(c, me->inUCLYhndl)) > 0))) {
 		    saved_char_in = c;
 		    if (code < 256) {
-			c = FROMASCII((char)code);
+			c = FROMASCII((char) code);
 			c_unsign = UCH(c);
 		    }
 		} else {
@@ -467,23 +453,23 @@
 		    }
 		    me->utf_buf[0] = '\0';
 		    code = UCH(c);
-		} /*  Next line end of ugly stuff for C0. - KW */
+		}		/*  Next line end of ugly stuff for C0. - KW */
 	    } else {
 		me->utf_buf[0] = '\0';
 		code = UCH(c);
 	    }
 	}
 	/*
-	**  At this point we have either code in Unicode
-	**  (and c in latin1 if code is in the latin1 range),
-	**  or code and c will have to be passed raw.
-	*/
+	 * At this point we have either code in Unicode (and c in latin1 if
+	 * code is in the latin1 range), or code and c will have to be passed
+	 * raw.
+	 */
 
 	/*
-	**  If CJK mode is on, we'll assume the document matches
-	**  the user's display character set, and if not, the
-	**  user should toggle off raw/CJK mode to reload. - FM
-	*/
+	 * If CJK mode is on, we'll assume the document matches the user's
+	 * display character set, and if not, the user should toggle off
+	 * raw/CJK mode to reload.  - FM
+	 */
 	if (HTCJK != NOCJK) {
 	    HText_appendCharacter(me->text, c);
 
@@ -492,84 +478,85 @@
 #define PASS8859SPECL me->T.pass_160_173_raw
 #define PASSHI8BIT (HTPassEightBitRaw || \
 		    (me->T.do_8bitraw && !me->T.trans_from_uni))
-	/*
-	**  If HTPassHighCtrlRaw is set (e.g., for KOI8-R) assume the
-	**  document matches and pass 127-160 8-bit characters.  If it
-	**  doesn't match, the user should toggle raw/CJK mode off. - FM
-	*/
-	} else if (TOASCII(code) >= 127 && TOASCII(code) < 161 &&  /* S/390 -- gil -- 0427 */
+	    /*
+	     * If HTPassHighCtrlRaw is set (e.g., for KOI8-R) assume the
+	     * document matches and pass 127-160 8-bit characters.  If it
+	     * doesn't match, the user should toggle raw/CJK mode off.  - FM
+	     */
+	} else if (TOASCII(code) >= 127 && TOASCII(code) < 161 &&	/* S/390 -- gil -- 0427 */
 		   PASSHICTRL && PASS8859SPECL) {
 	    HText_appendCharacter(me->text, c);
 	} else if (code == CH_SHY && PASS8859SPECL) {
 	    HText_appendCharacter(me->text, c);
-	/*
-	**  If neither HTPassHighCtrlRaw nor CJK is set, play it safe
-	**  and treat 160 (nbsp) as an ASCII space (32). - FM
-	*/
+	    /*
+	     * If neither HTPassHighCtrlRaw nor CJK is set, play it safe and
+	     * treat 160 (nbsp) as an ASCII space (32).  - FM
+	     */
 	} else if (code == CH_NBSP) {
 	    HText_appendCharacter(me->text, ' ');
-	/*
-	**  If neither HTPassHighCtrlRaw nor CJK is set, play it safe
-	**  and ignore 173 (shy). - FM
-	**  Now only ignore it for color style, which doesn't handle it anyway.
-	**  Otherwise pass it on as LY_SOFT_HYPHEN and let HText deal with it.
-	**  It should be either ignored, or displayed as a hyphen if it was
-	**  indeed at the end of a line.  Well it should. - kw
-	*/
+	    /*
+	     * If neither HTPassHighCtrlRaw nor CJK is set, play it safe and
+	     * ignore 173 (shy).  - FM
+	     * Now only ignore it for color style, which doesn't handle it
+	     * anyway.  Otherwise pass it on as LY_SOFT_HYPHEN and let HText
+	     * deal with it.  It should be either ignored, or displayed as a
+	     * hyphen if it was indeed at the end of a line.  Well it should. 
+	     * - kw
+	     */
 	} else if (code == CH_SHY) {
 #ifndef USE_COLOR_STYLE
 	    HText_appendCharacter(me->text, LY_SOFT_HYPHEN);
 #endif
 	    continue;
-	/*
-	**  If we get to here, pass the displayable ASCII characters. - FM
-	*/
+	    /*
+	     * If we get to here, pass the displayable ASCII characters.  - FM
+	     */
 	} else if ((code >= ' ' && TOASCII(code) < 127) ||
 		   (PASSHI8BIT &&
 		    c >= LYlowest_eightbit[me->outUCLYhndl]) ||
 		   *p == '\n' || *p == '\t') {
 	    HText_appendCharacter(me->text, c);
-	/*
-	**  Use an ASCII space (32) for ensp, emsp or thinsp. - FM
-	*/
+	    /*
+	     * Use an ASCII space (32) for ensp, emsp or thinsp.  - FM
+	     */
 	} else if (code == 8194 || code == 8195 || code == 8201) {
 	    HText_appendCharacter(me->text, ' ');
-	/*
-	**  If we want the raw character, pass it now. - FM
-	*/
+	    /*
+	     * If we want the raw character, pass it now.  - FM
+	     */
 	} else if (me->T.use_raw_char_in && saved_char_in) {
 	    HText_appendCharacter(me->text, saved_char_in);
 /******************************************************************
- *   I. LATIN-1 OR UCS2  TO  DISPLAY CHARSET
+ * I.  LATIN-1 OR UCS2 TO DISPLAY CHARSET
  ******************************************************************/
 	} else if ((chk = (BOOL) (me->T.trans_from_uni && code >= 160)) &&
 		   (uck = UCTransUniChar(code,
-					 me->outUCLYhndl)) >= ' ' &&  /* S/390 -- gil -- 0464 */
+					 me->outUCLYhndl)) >= ' ' &&	/* S/390 -- gil -- 0464 */
 		   uck < 256) {
 	    CTRACE((tfp, "UCTransUniChar returned 0x%.2lX:'%c'.\n",
-			uck, FROMASCII((char)uck)));
-	    HText_appendCharacter(me->text, ((char)(uck & 0xff)));
+		    uck, FROMASCII((char) uck)));
+	    HText_appendCharacter(me->text, ((char) (uck & 0xff)));
 	} else if (chk &&
 		   (uck == -4 ||
-		    (me->T.repl_translated_C0 && uck > 0 && uck < ' ')) &&  /* S/390 -- gil -- 0481 */
-		   /*
-		   **  Not found; look for replacement string.
-		   */
+		    (me->T.repl_translated_C0 && uck > 0 && uck < ' ')) &&	/* S/390 -- gil -- 0481 */
+	    /*
+	     * Not found; look for replacement string.
+	     */
 		   (uck = UCTransUniCharStr(replace_buf, 60, code,
 					    me->outUCLYhndl, 0) >= 0)) {
 	    /*
-	    **	No further tests for valididy - assume that whoever
-	    **	defined replacement strings knew what she was doing.
-	    */
+	     * No further tests for valididy - assume that whoever defined
+	     * replacement strings knew what she was doing.
+	     */
 	    HText_appendText(me->text, replace_buf);
-	/*
-	**  If we get to here, and should have translated,
-	**  translation has failed so far.
-	*/
-	} else if (chk && TOASCII(code) > 127 && me->T.output_utf8) {  /* S/390 -- gil -- 0498 */
 	    /*
-	    **	We want UTF-8 output, so do it now. - FM
-	    */
+	     * If we get to here, and should have translated, translation has
+	     * failed so far.
+	     */
+	} else if (chk && TOASCII(code) > 127 && me->T.output_utf8) {	/* S/390 -- gil -- 0498 */
+	    /*
+	     * We want UTF-8 output, so do it now.  - FM
+	     */
 	    if (*me->utf_buf) {
 		HText_appendText(me->text, me->utf_buf);
 		me->utf_buf[0] = '\0';
@@ -578,8 +565,9 @@
 		HText_appendText(me->text, replace_buf);
 	    } else {
 		/*
-		**  Out of luck, so use the UHHH notation (ugh). - gil
-		*/  /* S/390 -- gil -- 0517 */
+		 * Out of luck, so use the UHHH notation (ugh).  - gil
+		 */
+		/* S/390 -- gil -- 0517 */
 		sprintf(replace_buf, "U%.2lX", TOASCII(code));
 		HText_appendText(me->text, replace_buf);
 	    }
@@ -588,33 +576,32 @@
 		   UCH(*p) >= 192 &&
 		   UCH(*p) < 255) {
 	    /*
-	    **	KOI special: strip high bit, gives
-	    **	(somewhat) readable ASCII.
-	    */
-	    HText_appendCharacter(me->text, (char)(*p & 0x7f));
+	     * KOI special:  strip high bit, gives (somewhat) readable ASCII.
+	     */
+	    HText_appendCharacter(me->text, (char) (*p & 0x7f));
 #endif /* NOTDEFINED */
 	    /*
-	    **  If we don't actually want the character,
-	    **  make it safe and output that now. - FM
-	    */
+	     * If we don't actually want the character, make it safe and output
+	     * that now.  - FM
+	     */
 	} else if ((c_unsign > 0 &&
-		      (int) c_unsign < LYlowest_eightbit[me->outUCLYhndl]) ||
-		      (me->T.trans_from_uni && !HTPassEightBitRaw)) {
+		    (int) c_unsign < LYlowest_eightbit[me->outUCLYhndl]) ||
+		   (me->T.trans_from_uni && !HTPassEightBitRaw)) {
 	    /*
-	    **	If we do not have the "7-bit approximations" as our
-	    **	output character set (in which case we did it already)
-	    **	seek a translation for that.  Otherwise, or if the
-	    **	translation fails, use UHHH notation. - FM
-	    */
+	     * If we do not have the "7-bit approximations" as our output
+	     * character set (in which case we did it already) seek a
+	     * translation for that.  Otherwise, or if the translation fails,
+	     * use UHHH notation.  - FM
+	     */
 	    if ((chk = (BOOL) (me->outUCLYhndl !=
-			UCGetLYhndl_byMIME("us-ascii"))) &&
-		   (uck = UCTransUniChar(code,
-					 UCGetLYhndl_byMIME("us-ascii")))
-				      >= ' ' && TOASCII(uck) < 127) {  /* S/390 -- gil -- 0535 */
-		/*
-		**  Got an ASCII character (yippey). - FM
-		*/
-		c = FROMASCII((char)uck);
+			       UCGetLYhndl_byMIME("us-ascii"))) &&
+		(uck = UCTransUniChar(code,
+				      UCGetLYhndl_byMIME("us-ascii")))
+		>= ' ' && TOASCII(uck) < 127) {		/* S/390 -- gil -- 0535 */
+		/*
+		 * Got an ASCII character (yippey).  - FM
+		 */
+		c = FROMASCII((char) uck);
 		HText_appendCharacter(me->text, c);
 	    } else if ((chk && uck == -4) &&
 		       (uck = UCTransUniCharStr(replace_buf,
@@ -622,32 +609,31 @@
 						UCGetLYhndl_byMIME("us-ascii"),
 						0) >= 0)) {
 		/*
-		**  Got a repacement string (yippey). - FM
-		*/
+		 * Got a repacement string (yippey).  - FM
+		 */
 		HText_appendText(me->text, replace_buf);
 	    } else if (code == 8204 || code == 8205) {
 		/*
-		**	Ignore 8204 (zwnj) or 8205 (zwj), if we get to here. - FM
-		*/
+		 * Ignore 8204 (zwnj) or 8205 (zwj), if we get to here.  - FM
+		 */
 		CTRACE((tfp, "HTPlain_write: Ignoring '%ld'.\n", code));
 	    } else if (code == 8206 || code == 8207) {
 		/*
-		**	Ignore 8206 (lrm) or 8207 (rlm), if we get to here. - FM
-		*/
+		 * Ignore 8206 (lrm) or 8207 (rlm), if we get to here.  - FM
+		 */
 		CTRACE((tfp, "HTPlain_write: Ignoring '%ld'.\n", code));
 	    } else {
 		/*
-		**  Out of luck, so use the UHHH notation (ugh). - FM
-		*/
-			/* do not print UHHH for now
-			sprintf(replace_buf, "U%.2lX", code);
-			HText_appendText(me->text, replace_buf);
-			*/
-		}
-		/*
-		**  If we get to here and have a monobyte character,
-		**  pass it. - FM
-		*/
+		 * Out of luck, so use the UHHH notation (ugh).  - FM
+		 */
+		/* do not print UHHH for now
+		   sprintf(replace_buf, "U%.2lX", code);
+		   HText_appendText(me->text, replace_buf);
+		 */
+	    }
+	    /*
+	     * If we get to here and have a monobyte character, pass it.  - FM
+	     */
 	} else if (c_unsign != 0 && c_unsign < 256) {
 	    HText_appendCharacter(me->text, c);
 	}
@@ -656,13 +642,12 @@
 }
 
 /*	Free an HTML object
-**	-------------------
-**
-**	Note that the SGML parsing context is freed, but the created object is
-**	not, as it takes on an existence of its own unless explicitly freed.
-*/
-PRIVATE void HTPlain_free ARGS1(
-	HTStream *,	me)
+ *	-------------------
+ *
+ *	Note that the SGML parsing context is freed, but the created object is
+ *	not, as it takes on an existence of its own unless explicitly freed.
+ */
+static void HTPlain_free(HTStream *me)
 {
     if (HTPlain_bs_pending >= 2)
 	HText_appendCharacter(me->text, '_');
@@ -671,34 +656,31 @@
 
 /*	End writing
 */
-PRIVATE void HTPlain_abort ARGS2(
-	HTStream *,	me,
-	HTError,	e GCC_UNUSED)
+static void HTPlain_abort(HTStream *me, HTError e GCC_UNUSED)
 {
     HTPlain_free(me);
 }
 
 /*		Structured Object Class
-**		-----------------------
-*/
-PUBLIC CONST HTStreamClass HTPlain =
+ *		-----------------------
+ */
+static const HTStreamClass HTPlain =
 {
-	"PlainPresenter",
-	HTPlain_free,
-	HTPlain_abort,
-	HTPlain_put_character,	HTPlain_put_string, HTPlain_write,
+    "PlainPresenter",
+    HTPlain_free,
+    HTPlain_abort,
+    HTPlain_put_character, HTPlain_put_string, HTPlain_write,
 };
 
 /*		New object
-**		----------
-*/
-PUBLIC HTStream* HTPlainPresent ARGS3(
-	HTPresentation *,	pres GCC_UNUSED,
-	HTParentAnchor *,	anchor,
-	HTStream *,		sink GCC_UNUSED)
+ *		----------
+ */
+HTStream *HTPlainPresent(HTPresentation *pres GCC_UNUSED, HTParentAnchor *anchor,
+			 HTStream *sink GCC_UNUSED)
 {
 
-    HTStream* me = (HTStream*)malloc(sizeof(*me));
+    HTStream *me = (HTStream *) malloc(sizeof(*me));
+
     if (me == NULL)
 	outofmem(__FILE__, "HTPlain_new");
     me->isa = &HTPlain;
@@ -707,19 +689,19 @@
 
     me->utf_count = 0;
     me->utf_char = 0;
-    me->utf_buf[0] = me->utf_buf[6] =me->utf_buf[7] = '\0';
+    me->utf_buf[0] = me->utf_buf[6] = me->utf_buf[7] = '\0';
     me->utf_buf_p = me->utf_buf;
-    me->outUCLYhndl = HTAnchor_getUCLYhndl(anchor,UCT_STAGE_HTEXT);
-    me->inUCLYhndl = HTAnchor_getUCLYhndl(anchor,UCT_STAGE_PARSER);
+    me->outUCLYhndl = HTAnchor_getUCLYhndl(anchor, UCT_STAGE_HTEXT);
+    me->inUCLYhndl = HTAnchor_getUCLYhndl(anchor, UCT_STAGE_PARSER);
     HTPlain_getChartransInfo(me, anchor);
     UCSetTransParams(&me->T,
 		     me->inUCLYhndl, me->inUCI,
 		     me->outUCLYhndl,
-		     HTAnchor_getUCInfoStage(anchor,UCT_STAGE_HTEXT));
+		     HTAnchor_getUCInfoStage(anchor, UCT_STAGE_HTEXT));
 
     me->text = HText_new(anchor);
-    HText_setStyle(me->text, LYstyles(HTML_XMP) );
+    HText_setStyle(me->text, LYstyles(HTML_XMP));
     HText_beginAppend(me->text);
 
-    return (HTStream*) me;
+    return (HTStream *) me;
 }
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/SGML.c
+++ lynx-cur-2.8.6/WWW/Library/Implementation/SGML.c
@@ -1,13 +1,13 @@
 /*			General SGML Parser code		SGML.c
-**			========================
-**
-**	This module implements an HTStream object.  To parse an
-**	SGML file, create this object which is a parser.  The object
-**	is (currently) created by being passed a DTD structure,
-**	and a target HTStructured object at which to throw the parsed stuff.
-**
-**	 6 Feb 93  Binary searches used. Interface modified.
-*/
+ *			========================
+ *
+ *	This module implements an HTStream object.  To parse an
+ *	SGML file, create this object which is a parser.  The object
+ *	is (currently) created by being passed a DTD structure,
+ *	and a target HTStructured object at which to throw the parsed stuff.
+ *
+ *	 6 Feb 93  Binary searches used. Interface modified.
+ */
 
 #include <HTUtils.h>
 
@@ -26,9 +26,10 @@
 #include <UCAux.h>
 
 #include <HTChunk.h>
+#include <HTUtils.h>
 
 #include <LYCharSets.h>
-#include <LYCharVals.h>	 /* S/390 -- gil -- 0635 */
+#include <LYCharVals.h>		/* S/390 -- gil -- 0635 */
 #include <LYGlobalDefs.h>
 #include <LYStrings.h>
 #include <LYLeaks.h>
@@ -44,12 +45,12 @@
 
 #ifdef USE_PRETTYSRC
 
-char* entity_string; /* this is used for printing entity name.
-    Unconditionally added since redundant assigments don't hurt much*/
+static char *entity_string;	/* this is used for printing entity name.
+
+				   Unconditionally added since redundant assigments don't hurt much */
 
-PRIVATE void fake_put_character ARGS2(
-		    void*, p GCC_UNUSED,
-		    char,  c GCC_UNUSED)
+static void fake_put_character(void *p GCC_UNUSED,
+			       char c GCC_UNUSED)
 {
 }
 
@@ -65,7 +66,6 @@
 			AS_casecomp(a,b) : \
 			(TOASCII(TOUPPER(*a)) - TOASCII(TOUPPER(*b))))
 
-#if ANSI_PREPRO
  /* will use partially inlined version */
 #define orig_HTChunkPutUtf8Char HTChunkPutUtf8Char
 #undef HTChunkPutUtf8Char
@@ -79,25 +79,6 @@
 	orig_HTChunkPutUtf8Char(ch,x); \
     }
 
-#if 0
-#define orig_HTChunkPutc HTChunkPutc
-#undef HTChunkPutc
-
-#define HTChunkPutc(ch,x) \
-    { \
-    if (ch->size < ch->allocated) \
-	ch->data[ch->size++] = x; \
-    else \
-	orig_HTChunkPutc(ch,x); \
-    }
-
-#undef HTChunkTerminate
-
-#define HTChunkTerminate(ch) \
-    HTChunkPutc(ch, (char)0)
-#endif /* */
-#endif	/* ANSI_PREPRO */
-
 #define PUTS(str) ((*context->actions->put_string)(context->target, str))
 #define PUTC(ch)  ((*context->actions->put_character)(context->target, ch))
 #define PUTUTF8(code) (UCPutUtf8_charstring((HTStream *)context->target, \
@@ -105,34 +86,32 @@
 
 #define OPT 1
 
-
 /*the following macros are used for pretty source view. */
 #define IS_C(attr) (attr.type == HTMLA_CLASS)
 
-PUBLIC HTCJKlang HTCJK = NOCJK;		/* CJK enum value.		*/
-PUBLIC BOOL HTPassEightBitRaw = FALSE;	/* Pass 161-172,174-255 raw.	*/
-PUBLIC BOOL HTPassEightBitNum = FALSE;	/* Pass ^ numeric entities raw. */
-PUBLIC BOOL HTPassHighCtrlRaw = FALSE;	/* Pass 127-160,173,&#127; raw. */
-PUBLIC BOOL HTPassHighCtrlNum = FALSE;	/* Pass &#128;-&#159; raw.	*/
+HTCJKlang HTCJK = NOCJK;	/* CJK enum value.              */
+BOOL HTPassEightBitRaw = FALSE;	/* Pass 161-172,174-255 raw.    */
+BOOL HTPassEightBitNum = FALSE;	/* Pass ^ numeric entities raw. */
+BOOL HTPassHighCtrlRaw = FALSE;	/* Pass 127-160,173,&#127; raw. */
+BOOL HTPassHighCtrlNum = FALSE;	/* Pass &#128;-&#159; raw.      */
 
 /*	The State (context) of the parser
-**
-**	This is passed with each call to make the parser reentrant
-**
-*/
+ *
+ *	This is passed with each call to make the parser reentrant
+ *
+ */
 
 #define MAX_ATTRIBUTES 36	/* Max number of attributes per element */
 
-
 /*		Element Stack
-**		-------------
-**	This allows us to return down the stack reselecting styles.
-**	As we return, attribute values will be garbage in general.
-*/
+ *		-------------
+ *	This allows us to return down the stack reselecting styles.
+ *	As we return, attribute values will be garbage in general.
+ */
 typedef struct _HTElement HTElement;
 struct _HTElement {
-	HTElement *	next;	/* Previously nested element or 0 */
-	HTTag*		tag;	/* The tag at this level  */
+    HTElement *next;		/* Previously nested element or 0 */
+    HTTag *tag;			/* The tag at this level  */
 };
 
 typedef enum {
@@ -182,73 +161,74 @@
 } sgml_state;
 
 /*	Internal Context Data Structure
-**	-------------------------------
-*/
+ *	-------------------------------
+ */
 struct _HTStream {
 
-    CONST HTStreamClass *	isa;		/* inherited from HTStream */
+    const HTStreamClass *isa;	/* inherited from HTStream */
 
-    CONST SGML_dtd		*dtd;
-    CONST HTStructuredClass	*actions;	/* target class	 */
-    HTStructured		*target;	/* target object */
-
-    HTTag			*current_tag;
-    HTTag			*slashedtag;
-    CONST HTTag			*unknown_tag;
-    BOOL			inSELECT;
-    BOOL			no_lynx_specialcodes;
-    int				current_attribute_number;
-    HTChunk			*string;
-    int				leading_spaces;
-    int				trailing_spaces;
-    HTElement			*element_stack;
-    sgml_state			state;
+    const SGML_dtd *dtd;
+    const HTStructuredClass *actions;	/* target class  */
+    HTStructured *target;	/* target object */
+
+    HTTag *current_tag;
+    HTTag *slashedtag;
+    const HTTag *unknown_tag;
+    BOOL inSELECT;
+    BOOL no_lynx_specialcodes;
+    int current_attribute_number;
+    HTChunk *string;
+    int leading_spaces;
+    int trailing_spaces;
+    HTElement *element_stack;
+    sgml_state state;
     unsigned char kanji_buf;
 #ifdef CALLERDATA
-    void *			callerData;
-#endif /* CALLERDATA */
+    void *callerData;
+#endif				/* CALLERDATA */
     BOOL present[MAX_ATTRIBUTES];	/* Flags: attribute is present? */
-    char * value[MAX_ATTRIBUTES];	/* NULL, or strings alloc'd with StrAllocCopy_extra() */
+    char *value[MAX_ATTRIBUTES];	/* NULL, or strings alloc'd with StrAllocCopy_extra() */
 
-    BOOL			lead_exclamation;
-    BOOL			first_dash;
-    BOOL			end_comment;
-    BOOL			doctype_bracket;
-    BOOL			first_bracket;
-    BOOL			second_bracket;
-    BOOL			isHex;
-
-    HTParentAnchor *		node_anchor;
-    LYUCcharset *		inUCI;		/* pointer to anchor UCInfo */
-    int				inUCLYhndl;	/* charset we are fed	    */
-    LYUCcharset *		outUCI;		/* anchor UCInfo for target */
-    int				outUCLYhndl;	/* charset for target	    */
-    char			utf_count;
-    UCode_t			utf_char;
-    char			utf_buf[8];
-    char *			utf_buf_p;
-    UCTransParams		T;
-    int				current_tag_charset; /* charset to pass attributes */
-
-    char *			recover;
-    int				recover_index;
-    char *			include;
-    char *			active_include;
-    int				include_index;
-    char *			url;
-    char *			csi;
-    int				csi_index;
-#ifdef USE_PRETTYSRC
-    BOOL			cur_attr_is_href;
-    BOOL			cur_attr_is_name;
-    BOOL			seen_nonwhite_in_junk_tag;
+    BOOL lead_exclamation;
+    BOOL first_dash;
+    BOOL end_comment;
+    BOOL doctype_bracket;
+    BOOL first_bracket;
+    BOOL second_bracket;
+    BOOL isHex;
+
+    HTParentAnchor *node_anchor;
+    LYUCcharset *inUCI;		/* pointer to anchor UCInfo */
+    int inUCLYhndl;		/* charset we are fed       */
+    LYUCcharset *outUCI;	/* anchor UCInfo for target */
+    int outUCLYhndl;		/* charset for target       */
+    char utf_count;
+    UCode_t utf_char;
+    char utf_buf[8];
+    char *utf_buf_p;
+    UCTransParams T;
+    int current_tag_charset;	/* charset to pass attributes */
+
+    char *recover;
+    int recover_index;
+    char *include;
+    char *active_include;
+    int include_index;
+    char *url;
+    char *csi;
+    int csi_index;
+#ifdef USE_PRETTYSRC
+    BOOL cur_attr_is_href;
+    BOOL cur_attr_is_name;
+    BOOL seen_nonwhite_in_junk_tag;
 #endif
 };
 
 #ifndef NO_LYNX_TRACE
-PRIVATE char *state_name ARGS1(sgml_state, n)
+static const char *state_name(sgml_state n)
 {
-    char *result = "?";
+    const char *result = "?";
+    /* *INDENT-OFF* */
     switch (n) {
     case S_attr:                result = "S_attr";              break;
     case S_attr_gap:            result = "S_attr_gap";          break;
@@ -294,6 +274,8 @@
     case S_text:                result = "S_text";              break;
     case S_value:               result = "S_value";             break;
     }
+    /* *INDENT-ON* */
+
     return result;
 }
 #endif
@@ -303,15 +285,15 @@
 static HTElement pool[DEPTH];
 static int depth = 0;
 
-PRIVATE HTElement* pool_alloc NOARGS
+static HTElement *pool_alloc(void)
 {
     depth++;
     if (depth > DEPTH)
-	return (HTElement*) malloc(sizeof(HTElement));
+	return (HTElement *) malloc(sizeof(HTElement));
     return (pool + depth - 1);
 }
 
-PRIVATE void pool_free ARGS1(HTElement*, e)
+static void pool_free(HTElement * e)
 {
     if (depth > DEPTH)
 	FREE(e);
@@ -321,12 +303,9 @@
 
 #ifdef USE_PRETTYSRC
 
-PRIVATE void HTMLSRC_apply_markup ARGS3(
-	    HTStream *,	      context,
-	    HTlexeme,	      lexeme,
-	    BOOL,	      start)
+static void HTMLSRC_apply_markup(HTStream *context, HTlexeme lexeme, BOOL start)
 {
-    HT_tagspec* ts = *( ( start ? lexeme_start : lexeme_end ) + lexeme);
+    HT_tagspec *ts = *((start ? lexeme_start : lexeme_end) + lexeme);
 
     while (ts) {
 #ifdef USE_COLOR_STYLE
@@ -337,64 +316,54 @@
 	    force_classname = TRUE;
 	}
 #endif
-	CTRACE((tfp,ts->start ? "SRCSTART %d\n" : "SRCSTOP %d\n",(int)lexeme));
+	CTRACE((tfp, ts->start ? "SRCSTART %d\n" : "SRCSTOP %d\n", (int) lexeme));
 	if (ts->start)
-	    (*context->actions->start_element)(
-		context->target,
-		ts->element,
-		ts->present,
-		(CONST char **)ts->value,
-		context->current_tag_charset,
-		(char **)&context->include);
+	    (*context->actions->start_element) (context->target,
+						ts->element,
+						ts->present,
+						(const char **) ts->value,
+						context->current_tag_charset,
+						&context->include);
 	else
-	    (*context->actions->end_element)(
-		context->target,
-		ts->element,
-		(char **)&context->include);
+	    (*context->actions->end_element) (context->target,
+					      ts->element,
+					      &context->include);
 	ts = ts->next;
     }
 }
 
-#if ANSI_PREPRO
-#  define PSRCSTART(x)	HTMLSRC_apply_markup(context,HTL_##x,START)
-#  define PSRCSTOP(x)   HTMLSRC_apply_markup(context,HTL_##x,STOP)
-#else
-#  define PSRCSTART(x)	HTMLSRC_apply_markup(context,HTL_/**/x,START)
-#  define PSRCSTOP(x)   HTMLSRC_apply_markup(context,HTL_/**/x,STOP)
-#endif
+#define PSRCSTART(x)	HTMLSRC_apply_markup(context,HTL_##x,START)
+#define PSRCSTOP(x)   HTMLSRC_apply_markup(context,HTL_##x,STOP)
 
 #define attr_is_href context->cur_attr_is_href
 #define attr_is_name context->cur_attr_is_name
 #endif
 
-PRIVATE void set_chartrans_handling ARGS3(
-	HTStream *,		context,
-	HTParentAnchor *,	anchor,
-	int,			chndl)
+static void set_chartrans_handling(HTStream *context, HTParentAnchor *anchor,
+				   int chndl)
 {
     if (chndl < 0) {
 	/*
-	**  Nothing was set for the parser in earlier stages,
-	**  so the HTML parser's UCLYhndl should still be its
-	**  default. - FM
-	*/
+	 * Nothing was set for the parser in earlier stages, so the HTML
+	 * parser's UCLYhndl should still be its default.  - FM
+	 */
 	chndl = HTAnchor_getUCLYhndl(anchor, UCT_STAGE_STRUCTURED);
 	if (chndl < 0)
 	    /*
-	    **	That wasn't set either, so seek the HText default. - FM
-	    */
+	     * That wasn't set either, so seek the HText default.  - FM
+	     */
 	    chndl = HTAnchor_getUCLYhndl(anchor, UCT_STAGE_HTEXT);
 	if (chndl < 0)
 	    /*
-	    **	That wasn't set either, so assume the current display
-	    **	character set. - FM
-	    */
+	     * That wasn't set either, so assume the current display character
+	     * set.  - FM
+	     */
 	    chndl = current_char_set;
 	/*
-	**  Try to set the HText and HTML stages' chartrans info
-	**  with the default lock level (will not be changed if
-	**  it was set previously with a higher lock level). - FM
-	*/
+	 * Try to set the HText and HTML stages' chartrans info with the
+	 * default lock level (will not be changed if it was set previously
+	 * with a higher lock level).  - FM
+	 */
 	HTAnchor_setUCInfoStage(anchor, chndl,
 				UCT_STAGE_HTEXT,
 				UCT_SETBY_DEFAULT);
@@ -402,30 +371,31 @@
 				UCT_STAGE_STRUCTURED,
 				UCT_SETBY_DEFAULT);
 	/*
-	**  Get the chartrans info for output to the HTML parser. - FM
-	*/
+	 * Get the chartrans info for output to the HTML parser.  - FM
+	 */
 	context->outUCI = HTAnchor_getUCInfoStage(anchor,
 						  UCT_STAGE_STRUCTURED);
 	context->outUCLYhndl = HTAnchor_getUCLYhndl(context->node_anchor,
 						    UCT_STAGE_STRUCTURED);
     }
     /*
-    **	Set the in->out transformation parameters. - FM
-    */
+     * Set the in->out transformation parameters.  - FM
+     */
     UCSetTransParams(&context->T,
 		     context->inUCLYhndl, context->inUCI,
 		     context->outUCLYhndl, context->outUCI);
     /*
-    **	This is intended for passing the SGML parser's input
-    **	charset as an argument in each call to the HTML
-    **	parser's start tag function, but it would be better
-    **	to call a Lynx_HTML_parser function to set an element
-    **	in its HTStructured object, itself, if this were
-    **	needed. - FM
-    */
+     * This is intended for passing the SGML parser's input charset as an
+     * argument in each call to the HTML parser's start tag function, but it
+     * would be better to call a Lynx_HTML_parser function to set an element in
+     * its HTStructured object, itself, if this were needed.  - FM
+     */
+#ifndef EXP_JAPANESEUTF8_SUPPORT
     if (HTCJK != NOCJK) {
 	context->current_tag_charset = -1;
-    } else if (context->T.transp) {
+    } else
+#endif
+    if (context->T.transp) {
 	context->current_tag_charset = context->inUCLYhndl;
     } else if (context->T.decode_utf8) {
 	context->current_tag_charset = context->inUCLYhndl;
@@ -440,25 +410,24 @@
     }
 }
 
-PRIVATE void change_chartrans_handling ARGS1(
-	HTStream *,		context)
+static void change_chartrans_handling(HTStream *context)
 {
     int new_LYhndl = HTAnchor_getUCLYhndl(context->node_anchor,
 					  UCT_STAGE_PARSER);
+
     if (new_LYhndl != context->inUCLYhndl &&
 	new_LYhndl >= 0) {
 	/*
-	 *  Something changed. but ignore if a META wants an unknown charset.
+	 * Something changed.  but ignore if a META wants an unknown charset.
 	 */
-	LYUCcharset * new_UCI = HTAnchor_getUCInfoStage(context->node_anchor,
-							UCT_STAGE_PARSER);
+	LYUCcharset *new_UCI = HTAnchor_getUCInfoStage(context->node_anchor,
+						       UCT_STAGE_PARSER);
+
 	if (new_UCI) {
-	    LYUCcharset * next_UCI = HTAnchor_getUCInfoStage(
-				    context->node_anchor, UCT_STAGE_STRUCTURED
-							    );
-	    int next_LYhndl = HTAnchor_getUCLYhndl(
-				    context->node_anchor, UCT_STAGE_STRUCTURED
-						  );
+	    LYUCcharset *next_UCI = HTAnchor_getUCInfoStage(context->node_anchor,
+							    UCT_STAGE_STRUCTURED);
+	    int next_LYhndl = HTAnchor_getUCLYhndl(context->node_anchor, UCT_STAGE_STRUCTURED);
+
 	    context->inUCI = new_UCI;
 	    context->inUCLYhndl = new_LYhndl;
 	    context->outUCI = next_UCI;
@@ -475,16 +444,14 @@
 #endif
 
 /*	Handle Attribute
-**	----------------
-*/
-/* PUBLIC CONST char * SGML_default = "";   ?? */
+ *	----------------
+ */
+/* PUBLIC const char * SGML_default = "";   ?? */
 
-PRIVATE void handle_attribute_name ARGS2(
-	HTStream *,	context,
-	CONST char *,	s)
+static void handle_attribute_name(HTStream *context, const char *s)
 {
-    HTTag * tag = context->current_tag;
-    attr * attributes = tag->attributes;
+    HTTag *tag = context->current_tag;
+    attr *attributes = tag->attributes;
     int high, low, i, diff;
 
 #ifdef USE_PRETTYSRC
@@ -494,25 +461,25 @@
     }
 #endif
     /*
-    **	Ignore unknown tag. - KW
-    */
+     * Ignore unknown tag.  - KW
+     */
     if (tag == context->unknown_tag) {
 #ifdef USE_PRETTYSRC
 	if (psrc_view)
-	    context->current_attribute_number = 1; /* anything !=INVALID */
+	    context->current_attribute_number = 1;	/* anything !=INVALID */
 #endif
 	return;
     }
 
     /*
-    **	Binary search for attribute name.
-    */
+     * Binary search for attribute name.
+     */
     for (low = 0, high = tag->number_of_attributes;
 	 high > low;
-	 diff < 0 ? (low = i+1) : (high = i)) {
-	i = (low + (high-low)/2);
+	 diff < 0 ? (low = i + 1) : (high = i)) {
+	i = (low + (high - low) / 2);
 	diff = my_casecomp(attributes[i].name, s);
-	if (diff == 0) {		/* success: found it */
+	if (diff == 0) {	/* success: found it */
 	    context->current_attribute_number = i;
 #ifdef USE_PRETTYSRC
 	    if (psrc_view) {
@@ -521,150 +488,141 @@
 	    } else
 #endif
 	    {
-	    context->present[i] = YES;
-	    Clear_extra(context->value[i]);
+		context->present[i] = YES;
+		Clear_extra(context->value[i]);
 #ifdef USE_COLOR_STYLE
 #   ifdef USE_PRETTYSRC
-	    current_is_class = IS_C(attributes[i]);
+		current_is_class = IS_C(attributes[i]);
 #   else
-	    current_is_class = (!strcasecomp("class", s));
+		current_is_class = (!strcasecomp("class", s));
 #   endif
-	    CTRACE((tfp, "SGML: found attribute %s, %d\n", s, current_is_class));
+		CTRACE((tfp, "SGML: found attribute %s, %d\n", s, current_is_class));
 #endif
 	    }
 	    return;
-	} /* if */
-
-    } /* for */
+	}
+	/* if */
+    }				/* for */
 
     CTRACE((tfp, "SGML: Unknown attribute %s for tag %s\n",
-		s, context->current_tag->name));
+	    s, context->current_tag->name));
     context->current_attribute_number = INVALID;	/* Invalid */
 }
 
-
 /*	Handle attribute value
-**	----------------------
-*/
-PRIVATE void handle_attribute_value ARGS2(
-	HTStream *,	context,
-	CONST char *,	s)
+ *	----------------------
+ */
+static void handle_attribute_value(HTStream *context, const char *s)
 {
     if (context->current_attribute_number != INVALID) {
 	StrAllocCopy_extra(context->value[context->current_attribute_number], s);
 #ifdef USE_COLOR_STYLE
-	if (current_is_class)
-	{
-	    strncpy (class_string, s, TEMPSTRINGSIZE);
+	if (current_is_class) {
+	    strncpy(class_string, s, TEMPSTRINGSIZE);
 	    CTRACE((tfp, "SGML: class is '%s'\n", s));
-	}
-	else
-	{
+	} else {
 	    CTRACE((tfp, "SGML: attribute value is '%s'\n", s));
 	}
 #endif
     } else {
 	CTRACE((tfp, "SGML: Attribute value %s ***ignored\n", s));
     }
-    context->current_attribute_number = INVALID; /* can't have two assignments! */
+    context->current_attribute_number = INVALID;	/* can't have two assignments! */
 }
 
-
 /*
-**  Translate some Unicodes to Lynx special codes and output them.
-**  Special codes - ones those output depend on parsing.
-**
-**  Additional issue, like handling bidirectional text if necessary
-**  may be called from here:  zwnj (8204), zwj (8205), lrm (8206), rlm (8207)
-**  - currently they are ignored in SGML.c and LYCharUtils.c
-**  but also in UCdomap.c because they are non printable...
-**
-*/
-PRIVATE BOOL put_special_unicodes ARGS2(
-	HTStream *,	context,
-	UCode_t,	code)
+ *  Translate some Unicodes to Lynx special codes and output them.
+ *  Special codes - ones those output depend on parsing.
+ *
+ *  Additional issue, like handling bidirectional text if necessary
+ *  may be called from here:  zwnj (8204), zwj (8205), lrm (8206), rlm (8207)
+ *  - currently they are ignored in SGML.c and LYCharUtils.c
+ *  but also in UCdomap.c because they are non printable...
+ *
+ */
+static BOOL put_special_unicodes(HTStream *context, UCode_t code)
 {
     /* (Tgf_nolyspcl) */
     if (context->no_lynx_specialcodes) {
 	/*
-	**  We were asked by a "DTD" flag to not generate lynx specials. - kw
-	*/
+	 * We were asked by a "DTD" flag to not generate lynx specials.  - kw
+	 */
 	return NO;
     }
 
-    if (code == CH_NBSP) {  /* S/390 -- gil -- 0657 */
+    if (code == CH_NBSP) {	/* S/390 -- gil -- 0657 */
 	/*
-	**  Use Lynx special character for nbsp.
-	*/
+	 * Use Lynx special character for nbsp.
+	 */
 #ifdef USE_PRETTYSRC
 	if (!psrc_view)
 #endif
-	PUTC(HT_NON_BREAK_SPACE);
-    } else  if (code == CH_SHY) {
+	    PUTC(HT_NON_BREAK_SPACE);
+    } else if (code == CH_SHY) {
 	/*
-	**  Use Lynx special character for shy.
-	*/
+	 * Use Lynx special character for shy.
+	 */
 #ifdef USE_PRETTYSRC
 	if (!psrc_view)
 #endif
-	PUTC(LY_SOFT_HYPHEN);
+	    PUTC(LY_SOFT_HYPHEN);
     } else if (code == 8194 || code == 8201) {
 	/*
-	**  Use Lynx special character for ensp or thinsp.
-	**
-	**  Originally, Lynx use space '32' as word delimiter and omits this
-	**  space at end of line if word is wrapped to the next line.  There
-	**  are several other spaces in the Unicode repertoire and we should
-	**  teach Lynx to understand them, not only as regular characters but
-	**  in the context of line wrapping.  Unfortunately, if we use
-	**  HT_EN_SPACE we override the chartrans tables for those spaces
-	**  with a single '32' for all (but do line wrapping more fancy).
-	**
-	**  We may treat emsp as one or two ensp (below).
-	*/
+	 * Use Lynx special character for ensp or thinsp.
+	 *
+	 * Originally, Lynx use space '32' as word delimiter and omits this
+	 * space at end of line if word is wrapped to the next line.  There are
+	 * several other spaces in the Unicode repertoire and we should teach
+	 * Lynx to understand them, not only as regular characters but in the
+	 * context of line wrapping.  Unfortunately, if we use HT_EN_SPACE we
+	 * override the chartrans tables for those spaces with a single '32'
+	 * for all (but do line wrapping more fancy).
+	 *
+	 * We may treat emsp as one or two ensp (below).
+	 */
 #ifdef USE_PRETTYSRC
 	if (!psrc_view)
 #endif
-	PUTC(HT_EN_SPACE);
+	    PUTC(HT_EN_SPACE);
     } else if (code == 8195) {
 	/*
-	**  Use Lynx special character for emsp.
-	*/
+	 * Use Lynx special character for emsp.
+	 */
 #ifdef USE_PRETTYSRC
 	if (!psrc_view) {
 #endif
-	/* PUTC(HT_EN_SPACE);  let's stay with a single space :) */
-	PUTC(HT_EN_SPACE);
+	    /* PUTC(HT_EN_SPACE);  let's stay with a single space :) */
+	    PUTC(HT_EN_SPACE);
 #ifdef USE_PRETTYSRC
 	}
 #endif
     } else {
 	/*
-	**  Return NO if nothing done.
-	*/
+	 * Return NO if nothing done.
+	 */
 	return NO;
     }
     /*
-    **	We have handled it.
-    */
+     * We have handled it.
+     */
     return YES;
 }
 
 #ifdef USE_PRETTYSRC
-PRIVATE void put_pretty_entity ARGS2(HTStream *, context, int, term)
+static void put_pretty_entity(HTStream *context, int term)
 {
     PSRCSTART(entity);
     PUTC('&');
     PUTS(entity_string);
     if (term)
-	PUTC((char)term);
+	PUTC((char) term);
     PSRCSTOP(entity);
 }
 
-PRIVATE void put_pretty_number ARGS1(HTStream *, context)
+static void put_pretty_number(HTStream *context)
 {
     PSRCSTART(entity);
-    PUTS( (context->isHex ? "&#x" : "&#") );
+    PUTS((context->isHex ? "&#x" : "&#"));
     PUTS(entity_string);
     PUTC(';');
     PSRCSTOP(entity);
@@ -672,39 +630,37 @@
 #endif /* USE_PRETTYSRC */
 
 /*	Handle entity
-**	-------------
-**
-** On entry,
-**	s	contains the entity name zero terminated
-** Bugs:
-**	If the entity name is unknown, the terminator is treated as
-**	a printable non-special character in all cases, even if it is '<'
-** Bug-fix:
-**	Modified SGML_character() so we only come here with terminator
-**	as '\0' and check a FoundEntity flag. -- Foteos Macrides
-**
-** Modified more (for use with Lynx character translation code):
-*/
-PRIVATE char replace_buf [64];	      /* buffer for replacement strings */
-PRIVATE BOOL FoundEntity = FALSE;
+ *	-------------
+ *
+ * On entry,
+ *	s	contains the entity name zero terminated
+ * Bugs:
+ *	If the entity name is unknown, the terminator is treated as
+ *	a printable non-special character in all cases, even if it is '<'
+ * Bug-fix:
+ *	Modified SGML_character() so we only come here with terminator
+ *	as '\0' and check a FoundEntity flag. -- Foteos Macrides
+ *
+ * Modified more (for use with Lynx character translation code):
+ */
+static char replace_buf[64];	/* buffer for replacement strings */
+static BOOL FoundEntity = FALSE;
 
-PRIVATE void handle_entity ARGS2(
-	HTStream *,	context,
-	char,		term)
+static void handle_entity(HTStream *context, char term)
 {
     UCode_t code;
     long uck = -1;
-    CONST char *s = context->string->data;
+    const char *s = context->string->data;
 
     /*
-    **	Handle all entities normally. - FM
-    */
+     * Handle all entities normally.  - FM
+     */
     FoundEntity = FALSE;
     if ((code = HTMLGetEntityUCValue(s)) != 0) {
 	/*
-	**  We got a Unicode value for the entity name.
-	**  Check for special Unicodes. - FM
-	*/
+	 * We got a Unicode value for the entity name.  Check for special
+	 * Unicodes.  - FM
+	 */
 	if (put_special_unicodes(context, code)) {
 #ifdef USE_PRETTYSRC
 	    if (psrc_view) {
@@ -715,8 +671,8 @@
 	    return;
 	}
 	/*
-	**  Seek a translation from the chartrans tables.
-	*/
+	 * Seek a translation from the chartrans tables.
+	 */
 	if ((uck = UCTransUniChar(code, context->outUCLYhndl)) >= 32 &&
 /* =============== work in ASCII below here ===============  S/390 -- gil -- 0672 */
 	    uck < 256 &&
@@ -727,15 +683,15 @@
 		put_pretty_entity(context, term);
 	    } else
 #endif
-	    PUTC(FROMASCII((char)uck));
+		PUTC(FROMASCII((char) uck));
 	    FoundEntity = TRUE;
 	    return;
 	} else if ((uck == -4 ||
 		    (context->T.repl_translated_C0 &&
 		     uck > 0 && uck < 32)) &&
-		   /*
-		   **  Not found; look for replacement string.
-		   */
+	    /*
+	     * Not found; look for replacement string.
+	     */
 		   (uck = UCTransUniCharStr(replace_buf, 60, code,
 					    context->outUCLYhndl, 0) >= 0)) {
 #ifdef USE_PRETTYSRC
@@ -743,22 +699,24 @@
 		put_pretty_entity(context, term);
 	    } else
 #endif
-	    PUTS(replace_buf);
+		PUTS(replace_buf);
 	    FoundEntity = TRUE;
 	    return;
 	}
 	/*
-	**  If we're displaying UTF-8, try that now. - FM
-	*/
+	 * If we're displaying UTF-8, try that now.  - FM
+	 */
 #ifndef USE_PRETTYSRC
 	if (context->T.output_utf8 && PUTUTF8(code)) {
 	    FoundEntity = TRUE;
 	    return;
 	}
 #else
-	if (context->T.output_utf8 && (psrc_view ?
-	      (UCPutUtf8_charstring((HTStream *)context->target,
-	      (putc_func_t*)(fake_put_character), code)): PUTUTF8(code) ) ) {
+	if (context->T.output_utf8 && (psrc_view
+				       ? (UCPutUtf8_charstring((HTStream *) context->target,
+							       (putc_func_t *) (fake_put_character),
+							       code))
+				       : PUTUTF8(code))) {
 
 	    if (psrc_view) {
 		put_pretty_entity(context, term);
@@ -769,8 +727,8 @@
 	}
 #endif
 	/*
-	**  If it's safe ASCII, use it. - FM
-	*/
+	 * If it's safe ASCII, use it.  - FM
+	 */
 	if (code >= 32 && code < 127) {
 #ifdef USE_PRETTYSRC
 	    if (psrc_view) {
@@ -778,16 +736,15 @@
 	    } else
 #endif
 
-	    PUTC(FROMASCII((char)code));
+		PUTC(FROMASCII((char) code));
 	    FoundEntity = TRUE;
 	    return;
 	}
 /* =============== work in ASCII above here ===============  S/390 -- gil -- 0682 */
 	/*
-	**  Ignore zwnj (8204) and zwj (8205), if we get to here.
-	**  Note that zwnj may have been handled as <WBR>
-	**  by the calling function. - FM
-	*/
+	 * Ignore zwnj (8204) and zwj (8205), if we get to here.  Note that
+	 * zwnj may have been handled as <WBR> by the calling function.  - FM
+	 */
 	if (!strcmp(s, "zwnj") ||
 	    !strcmp(s, "zwj")) {
 	    CTRACE((tfp, "handle_entity: Ignoring '%s'.\n", s));
@@ -800,8 +757,8 @@
 	    return;
 	}
 	/*
-	**  Ignore lrm (8206), and rln (8207), if we get to here. - FM
-	*/
+	 * Ignore lrm (8206), and rln (8207), if we get to here.  - FM
+	 */
 	if (!strcmp(s, "lrm") ||
 	    !strcmp(s, "rlm")) {
 	    CTRACE((tfp, "handle_entity: Ignoring '%s'.\n", s));
@@ -816,13 +773,13 @@
     }
 
     /*
-    **	If entity string not found, display as text.
-    */
+     * If entity string not found, display as text.
+     */
 #ifdef USE_PRETTYSRC
     if (psrc_view)
 	PSRCSTART(badseq);
 #endif
-    CTRACE((tfp, "SGML: Unknown entity '%s' %ld %ld\n", s, (long)code, uck)); /* S/390 -- gil -- 0695 */
+    CTRACE((tfp, "SGML: Unknown entity '%s' %ld %ld\n", s, (long) code, uck));	/* S/390 -- gil -- 0695 */
     PUTC('&');
     PUTS(s);
     if (term != '\0')
@@ -833,21 +790,19 @@
 #endif
 }
 
-
 /*	Handle comment
-**	--------------
-*/
-PRIVATE void handle_comment ARGS1(
-	HTStream *,		context)
+ *	--------------
+ */
+static void handle_comment(HTStream *context)
 {
-    CONST char *s = context->string->data;
+    const char *s = context->string->data;
 
     CTRACE((tfp, "SGML Comment:\n<%s>\n", s));
 
     if (context->csi == NULL &&
 	strncmp(s, "!--#", 4) == 0 &&
-	LYCheckForCSI(context->node_anchor, (char **)&context->url) == TRUE) {
-	LYDoCSI(context->url, s, (char **)&context->csi);
+	LYCheckForCSI(context->node_anchor, &context->url) == TRUE) {
+	LYDoCSI(context->url, s, &context->csi);
     } else {
 	LYCommentHacks(context->node_anchor, context->string->data);
     }
@@ -855,46 +810,39 @@
     return;
 }
 
-
 /*	Handle identifier
-**	-----------------
-*/
-PRIVATE void handle_identifier ARGS1(
-	HTStream *,		context)
+ *	-----------------
+ */
+static void handle_identifier(HTStream *context)
 {
-    CONST char *s = context->string->data;
+    const char *s = context->string->data;
 
     CTRACE((tfp, "SGML Identifier:\n<%s>\n", s));
 
     return;
 }
 
-
 /*	Handle doctype
-**	--------------
-*/
-PRIVATE void handle_doctype ARGS1(
-	HTStream *,		context)
+ *	--------------
+ */
+static void handle_doctype(HTStream *context)
 {
-    CONST char *s = context->string->data;
+    const char *s = context->string->data;
 
     CTRACE((tfp, "SGML Doctype:\n<%s>\n", s));
 
     return;
 }
 
-PRIVATE void SGML_write PARAMS((
-	HTStream *		me,
-	CONST char *		s,
-	int			l));
+static void SGML_write(HTStream *me, const char *s,
+		       int l);
 
 /*	Handle marked
-**	-------------
-*/
-PRIVATE void handle_marked ARGS1(
-	HTStream *,		context)
+ *	-------------
+ */
+static void handle_marked(HTStream *context)
 {
-    CONST char *s = context->string->data;
+    const char *s = context->string->data;
 
     CTRACE((tfp, "SGML Marked Section:\n<%s>\n", s));
 
@@ -906,50 +854,44 @@
 	   charset once it is in include - kw */
 
     } else if (!strncmp(context->string->data, "![CDATA[", 8)) {
-	(*context->actions->_write)(context->target,
-		   context->string->data + 8,
-		   context->string->size - 11);
+	(*context->actions->_write) (context->target,
+				     context->string->data + 8,
+				     context->string->size - 11);
 
     }
     return;
 }
 
-
 /*	Handle sgmlent
-**	--------------
-*/
-PRIVATE void handle_sgmlent ARGS1(
-	HTStream *,		context)
+ *	--------------
+ */
+static void handle_sgmlent(HTStream *context)
 {
-    CONST char *s = context->string->data;
+    const char *s = context->string->data;
 
     CTRACE((tfp, "SGML Entity Declaration:\n<%s>\n", s));
 
     return;
 }
 
-
 /*	Handle sgmlent
-**	--------------
-*/
-PRIVATE void handle_sgmlele ARGS1(
-	HTStream *,		context)
+ *	--------------
+ */
+static void handle_sgmlele(HTStream *context)
 {
-    CONST char *s = context->string->data;
+    const char *s = context->string->data;
 
     CTRACE((tfp, "SGML Element Declaration:\n<%s>\n", s));
 
     return;
 }
 
-
 /*	Handle sgmlatt
-**	--------------
-*/
-PRIVATE void handle_sgmlatt ARGS1(
-	HTStream *,		context)
+ *	--------------
+ */
+static void handle_sgmlatt(HTStream *context)
 {
-    CONST char *s = context->string->data;
+    const char *s = context->string->data;
 
     CTRACE((tfp, "SGML Attribute Declaration:\n<%s>\n", s));
 
@@ -957,17 +899,16 @@
 }
 
 /*
- *  Convenience macros - tags (elements) are identified sometimes
- *  by an int or enum value ('TAGNUM'), sometimes
- *  by a pointer to HTTag ('TAGP'). - kw
+ * Convenience macros - tags (elements) are identified sometimes by an int or
+ * enum value ('TAGNUM'), sometimes by a pointer to HTTag ('TAGP').  - kw
  */
-#define TAGNUM_OF_TAGP(t) (t - context->dtd->tags)
+#define TAGNUM_OF_TAGP(t) (HTMLElement) (t - context->dtd->tags)
 #define TAGP_OF_TAGNUM(e) (context->dtd->tags + e)
 
 /*
- *  The following implement special knowledge about OBJECT.
- *  As long as HTML_OBJECT is the only tag for which an alternative
- *  variant exist, they can be simple macros. - kw
+ * The following implement special knowledge about OBJECT.  As long as
+ * HTML_OBJECT is the only tag for which an alternative variant exist, they can
+ * be simple macros.  - kw
  */
 /* does 'TAGNUM' e have an alternative (variant) parsing mode? */
 #define HAS_ALT_TAGNUM(e) (e == HTML_OBJECT)
@@ -976,7 +917,7 @@
 #define ALT_TAGNUM(e) ((e == HTML_OBJECT) ? HTML_ALT_OBJECT : e)
 
 /* return 'TAGNUM' of the normal mode for 'TAGNUM' e which may be alt. */
-#define NORMAL_TAGNUM(e) ((e >= HTML_ELEMENTS) ? HTML_OBJECT : e)
+#define NORMAL_TAGNUM(e) (((int)(e) >= HTML_ELEMENTS) ? HTML_OBJECT : (HTMLElement)e)
 
 /* More convenience stuff. - kw */
 #define ALT_TAGP_OF_TAGNUM(e) TAGP_OF_TAGNUM(ALT_TAGNUM(e))
@@ -985,36 +926,31 @@
 #define ALT_TAGP(t) ALT_TAGP_OF_TAGNUM(TAGNUM_OF_TAGP(t))
 #define NORMAL_TAGP(t) NORMAL_TAGP_OF_TAGNUM(TAGNUM_OF_TAGP(t))
 
-
 #ifdef EXTENDED_HTMLDTD
 
-PRIVATE BOOL element_valid_within ARGS3(
-    HTTag *,	new_tag,
-    HTTag *,	stacked_tag,
-    BOOL,	direct)
+static BOOL element_valid_within(HTTag * new_tag, HTTag * stacked_tag, BOOL direct)
 {
     TagClass usecontains, usecontained;
+
     if (!stacked_tag || !new_tag)
 	return YES;
     usecontains = (direct ? stacked_tag->contains : stacked_tag->icontains);
     usecontained = (direct ? new_tag->contained : new_tag->icontained);
     if (new_tag == stacked_tag)
 	return (BOOL) ((Tgc_same & usecontains) &&
-		(Tgc_same & usecontained));
+		       (Tgc_same & usecontained));
     else
 	return (BOOL) ((new_tag->tagclass & usecontains) &&
-		(stacked_tag->tagclass & usecontained));
+		       (stacked_tag->tagclass & usecontained));
 }
 
 typedef enum {
-    close_NO	= 0,
+    close_NO = 0,
     close_error = 1,
     close_valid = 2
 } canclose_t;
 
-PRIVATE canclose_t can_close ARGS2(
-    HTTag *,	new_tag,
-    HTTag *,	stacked_tag)
+static canclose_t can_close(HTTag * new_tag, HTTag * stacked_tag)
 {
     if (!stacked_tag)
 	return close_NO;
@@ -1027,11 +963,11 @@
 		close_error : close_NO);
 }
 
-PRIVATE void do_close_stacked ARGS1(
-    HTStream *, context)
+static void do_close_stacked(HTStream *context)
 {
-    HTElement * stacked = context->element_stack;
+    HTElement *stacked = context->element_stack;
     HTMLElement e;
+
     if (!stacked)
 	return;			/* stack was empty */
     if (context->inSELECT && !strcasecomp(stacked->tag->name, "SELECT")) {
@@ -1039,24 +975,22 @@
     }
     e = NORMAL_TAGNUM(TAGNUM_OF_TAGP(stacked->tag));
 #ifdef USE_PRETTYSRC
-    if (!psrc_view) /* Don't actually pass call on if viewing psrc - kw */
+    if (!psrc_view)		/* Don't actually pass call on if viewing psrc - kw */
 #endif
-    (*context->actions->end_element)(
-	context->target,
-	e,
-	(char **)&context->include);
+	(*context->actions->end_element) (context->target,
+					  e,
+					  &context->include);
     context->element_stack = stacked->next;
     pool_free(stacked);
     context->no_lynx_specialcodes = context->element_stack ?
 	(context->element_stack->tag->flags & Tgf_nolyspcl) : NO;
 }
 
-PRIVATE int is_on_stack ARGS2(
-	HTStream *,	context,
-	HTTag *,	old_tag)
+static int is_on_stack(HTStream *context, HTTag * old_tag)
 {
-   HTElement * stacked = context->element_stack;
+    HTElement *stacked = context->element_stack;
     int i = 1;
+
     for (; stacked; stacked = stacked->next, i++) {
 	if (stacked->tag == old_tag ||
 	    stacked->tag == ALT_TAGP(old_tag))
@@ -1067,11 +1001,9 @@
 #endif /* EXTENDED_HTMLDTD */
 
 /*	End element
-**	-----------
-*/
-PRIVATE void end_element ARGS2(
-	HTStream *,	context,
-	HTTag *,	old_tag)
+ *	-----------
+ */
+static void end_element(HTStream *context, HTTag * old_tag)
 {
 #ifdef EXTENDED_HTMLDTD
 
@@ -1091,9 +1023,11 @@
 	    canclose_check = can_close(old_tag, context->element_stack->tag);
 	    if (canclose_check != close_NO) {
 		CTRACE((tfp, "SGML: End </%s> \t<- %s end </%s>\n",
-			    context->element_stack->tag->name,
-			    canclose_check == close_valid ? "supplied," : "***forced by",
-			    old_tag->name));
+			context->element_stack->tag->name,
+			((canclose_check == close_valid)
+			 ? "supplied,"
+			 : "***forced by"),
+			old_tag->name));
 		do_close_stacked(context);
 		extra_action_taken = YES;
 		stackpos = is_on_stack(context, old_tag);
@@ -1102,17 +1036,18 @@
 
 	if (stackpos == 0 && old_tag->contents != SGML_EMPTY) {
 	    CTRACE((tfp, "SGML: Still open %s, ***no open %s for </%s>\n",
-			context->element_stack ?
-			context->element_stack->tag->name : "none",
-			old_tag->name,
-			old_tag->name));
+		    context->element_stack ?
+		    context->element_stack->tag->name : "none",
+		    old_tag->name,
+		    old_tag->name));
 	    return;
 	}
 	if (stackpos > 1) {
-	    CTRACE((tfp, "SGML: Nesting <%s>...<%s> \t<- ***invalid end </%s>\n",
-			old_tag->name,
-			context->element_stack->tag->name,
-			old_tag->name));
+	    CTRACE((tfp,
+		    "SGML: Nesting <%s>...<%s> \t<- ***invalid end </%s>\n",
+		    old_tag->name,
+		    context->element_stack->tag->name,
+		    old_tag->name));
 	    return;
 	}
     }
@@ -1121,83 +1056,83 @@
 #endif /* EXTENDED_HTMLDTD */
 
     /*
-    **	If we are in a SELECT block, ignore anything
-    **	but a SELECT end tag. - FM
-    */
+     * If we are in a SELECT block, ignore anything but a SELECT end tag.  - FM
+     */
     if (context->inSELECT) {
 	if (!strcasecomp(old_tag->name, "SELECT")) {
 	    /*
-	    **	Turn off the inSELECT flag and fall through. - FM
-	    */
+	     * Turn off the inSELECT flag and fall through.  - FM
+	     */
 	    context->inSELECT = FALSE;
 	} else {
 	    /*
-	    **	Ignore the end tag. - FM
-	    */
+	     * Ignore the end tag.  - FM
+	     */
 	    CTRACE((tfp, "SGML: ***Ignoring end tag </%s> in SELECT block.\n",
-			old_tag->name));
+		    old_tag->name));
 	    return;
 	}
     }
     /*
-    **	Handle the end tag. - FM
-    */
+     * Handle the end tag.  - FM
+     */
     CTRACE((tfp, "SGML: End </%s>\n", old_tag->name));
     if (old_tag->contents == SGML_EMPTY) {
 	CTRACE((tfp, "SGML: ***Illegal end tag </%s> found.\n",
-		    old_tag->name));
+		old_tag->name));
 	return;
     }
 #ifdef WIND_DOWN_STACK
-    while (context->element_stack) /* Loop is error path only */
+    while (context->element_stack)	/* Loop is error path only */
 #else
-    if (context->element_stack) /* Substitute and remove one stack element */
+    if (context->element_stack)	/* Substitute and remove one stack element */
 #endif /* WIND_DOWN_STACK */
     {
 	int status = HT_OK;
 	HTMLElement e;
-	HTElement * N = context->element_stack;
-	HTTag * t = (N->tag != old_tag) ? NORMAL_TAGP(N->tag) : N->tag;
+	HTElement *N = context->element_stack;
+	HTTag *t = (N->tag != old_tag) ? NORMAL_TAGP(N->tag) : N->tag;
 
-	if (old_tag != t) {		/* Mismatch: syntax error */
-	    if (context->element_stack->next) { /* This is not the last level */
-		CTRACE((tfp, "SGML: Found </%s> when expecting </%s>. </%s> ***assumed.\n",
-			     old_tag->name, t->name, t->name));
-	    } else {			/* last level */
-		CTRACE((tfp, "SGML: Found </%s> when expecting </%s>. </%s> ***Ignored.\n",
-			    old_tag->name, t->name, old_tag->name));
-		return;			/* Ignore */
+	if (old_tag != t) {	/* Mismatch: syntax error */
+	    if (context->element_stack->next) {		/* This is not the last level */
+		CTRACE((tfp,
+			"SGML: Found </%s> when expecting </%s>. </%s> ***assumed.\n",
+			old_tag->name, t->name, t->name));
+	    } else {		/* last level */
+		CTRACE((tfp,
+			"SGML: Found </%s> when expecting </%s>. </%s> ***Ignored.\n",
+			old_tag->name, t->name, old_tag->name));
+		return;		/* Ignore */
 	    }
 	}
 
 	e = NORMAL_TAGNUM(TAGNUM_OF_TAGP(t));
-	CTRACE2(TRACE_SGML, (tfp, "tagnum(%p) = %d\n", t, e));
+	CTRACE2(TRACE_SGML, (tfp, "tagnum(%p) = %d\n", t, (int) e));
 #ifdef USE_PRETTYSRC
-	if (!psrc_view) /* Don't actually pass call on if viewing psrc - kw */
+	if (!psrc_view)		/* Don't actually pass call on if viewing psrc - kw */
 #endif
-	    status = (*context->actions->end_element)(context->target,
-						e, (char **)&context->include);
+	    status = (*context->actions->end_element) (context->target,
+						       e, &context->include);
 	if (status == HT_PARSER_REOPEN_ELT) {
 	    CTRACE((tfp, "SGML: Restart <%s>\n", t->name));
-	    (*context->actions->start_element)(
-		context->target,
-		e,
-		NULL,
-		NULL,
-		context->current_tag_charset,
-		(char **)&context->include);
+	    (*context->actions->start_element) (context->target,
+						e,
+						NULL,
+						NULL,
+						context->current_tag_charset,
+						&context->include);
 	} else if (status == HT_PARSER_OTHER_CONTENT) {
 	    CTRACE((tfp, "SGML: Continue with other content model for <%s>\n", t->name));
 	    context->element_stack->tag = ALT_TAGP_OF_TAGNUM(e);
 	} else {
-	    context->element_stack = N->next;		/* Remove from stack */
+	    context->element_stack = N->next;	/* Remove from stack */
 	    pool_free(N);
 	}
 	context->no_lynx_specialcodes = context->element_stack ?
 	    (context->element_stack->tag->flags & Tgf_nolyspcl) : NO;
 #ifdef WIND_DOWN_STACK
 	if (old_tag == t)
-	    return;  /* Correct sequence */
+	    return;		/* Correct sequence */
 #else
 	return;
 #endif /* WIND_DOWN_STACK */
@@ -1206,17 +1141,15 @@
 
     }
     CTRACE((tfp, "SGML: Extra end tag </%s> found and ignored.\n",
-		old_tag->name));
+	    old_tag->name));
 }
 
-
 /*	Start a element
 */
-PRIVATE void start_element ARGS1(
-	HTStream *,	context)
+static void start_element(HTStream *context)
 {
     int status;
-    HTTag * new_tag = context->current_tag;
+    HTTag *new_tag = context->current_tag;
     HTMLElement e = TAGNUM_OF_TAGP(new_tag);
     BOOL ok = FALSE;
 
@@ -1237,17 +1170,20 @@
 	    canclose_check = can_close(new_tag, context->element_stack->tag);
 	    if (canclose_check != close_NO) {
 		CTRACE((tfp, "SGML: End </%s> \t<- %s start <%s>\n",
-			    context->element_stack->tag->name,
-			    canclose_check == close_valid ? "supplied," : "***forced by",
-			    new_tag->name));
+			context->element_stack->tag->name,
+			((canclose_check == close_valid)
+			 ? "supplied,"
+			 : "***forced by"),
+			new_tag->name));
 		do_close_stacked(context);
 		extra_action_taken = YES;
-		if (canclose_check  == close_error)
+		if (canclose_check == close_error)
 		    direct_container = NO;
 	    } else {
-		CTRACE((tfp, "SGML: Still open %s \t<- ***invalid start <%s>\n",
-			    context->element_stack->tag->name,
-			    new_tag->name));
+		CTRACE((tfp,
+			"SGML: Still open %s \t<- ***invalid start <%s>\n",
+			context->element_stack->tag->name,
+			new_tag->name));
 	    }
 	}
 	if (context->element_stack && !valid &&
@@ -1255,36 +1191,39 @@
 	    !(valid = element_valid_within(new_tag, context->element_stack->tag,
 					   direct_container))) {
 	    CTRACE((tfp, "SGML: Still open %s \t<- ***ignoring start <%s>\n",
-			context->element_stack->tag->name,
-			new_tag->name));
+		    context->element_stack->tag->name,
+		    new_tag->name));
 	    return;
 	}
 
-	if (context->element_stack && !extra_action_taken &&
-	    canclose_check == close_NO && !valid && (new_tag->flags & Tgf_mafse)) {
+	if (context->element_stack &&
+	    !extra_action_taken &&
+	    (canclose_check == close_NO) &&
+	    !valid && (new_tag->flags & Tgf_mafse)) {
 	    BOOL has_attributes = NO;
 	    int i = 0;
-	    for (; i< new_tag->number_of_attributes && !has_attributes; i++)
+
+	    for (; i < new_tag->number_of_attributes && !has_attributes; i++)
 		has_attributes = context->present[i];
 	    if (!has_attributes) {
-		CTRACE((tfp, "SGML: Still open %s, ***converting invalid <%s> to </%s>\n",
-			    context->element_stack->tag->name,
-			    new_tag->name,
-			    new_tag->name));
+		CTRACE((tfp,
+			"SGML: Still open %s, ***converting invalid <%s> to </%s>\n",
+			context->element_stack->tag->name,
+			new_tag->name,
+			new_tag->name));
 		end_element(context, new_tag);
 		return;
 	    }
 	}
 
 	if (context->element_stack &&
-	    canclose_check == close_error && !(valid =
-					       element_valid_within(
-						   new_tag,
-						   context->element_stack->tag,
-						   direct_container))) {
+	    (canclose_check == close_error) &&
+	    !(valid = element_valid_within(new_tag,
+					   context->element_stack->tag,
+					   direct_container))) {
 	    CTRACE((tfp, "SGML: Still open %s \t<- ***invalid start <%s>\n",
-			context->element_stack->tag->name,
-			new_tag->name));
+		    context->element_stack->tag->name,
+		    new_tag->name));
 	}
     }
     /* Fall through to the non-extended code - kw */
@@ -1292,75 +1231,80 @@
 #endif /* EXTENDED_HTMLDTD */
 
     /*
-    **	If we are not in a SELECT block, check if this is
-    **	a SELECT start tag.  Otherwise (i.e., we are in a
-    **	SELECT block) accept only OPTION as valid, terminate
-    **	the SELECT block if it is any other form-related
-    **	element, and otherwise ignore it. - FM
-    */
+     * If we are not in a SELECT block, check if this is a SELECT start tag. 
+     * Otherwise (i.e., we are in a SELECT block) accept only OPTION as valid,
+     * terminate the SELECT block if it is any other form-related element, and
+     * otherwise ignore it.  - FM
+     */
     if (!context->inSELECT) {
 	/*
-	**  We are not in a SELECT block, so check if this starts one. - FM
-	**  (frequent case!)
-	*/
+	 * We are not in a SELECT block, so check if this starts one.  - FM
+	 * (frequent case!)
+	 */
 	/* my_casecomp() - optimized by the first character */
 	if (!my_casecomp(new_tag->name, "SELECT")) {
 	    /*
-	    **	Set the inSELECT flag and fall through. - FM
-	    */
+	     * Set the inSELECT flag and fall through.  - FM
+	     */
 	    context->inSELECT = TRUE;
 	}
     } else {
 	/*
-	**  We are in a SELECT block. - FM
-	*/
+	 * We are in a SELECT block.  - FM
+	 */
 	if (strcasecomp(new_tag->name, "OPTION")) {
 	    /*
-	    **	Ugh, it is not an OPTION. - FM
-	    */
+	     * Ugh, it is not an OPTION.  - FM
+	     */
 	    switch (e) {
-		case HTML_INPUT:  case HTML_TEXTAREA: case HTML_SELECT:
-		case HTML_BUTTON: case HTML_FIELDSET: case HTML_LABEL:
-		case HTML_LEGEND: case HTML_FORM:
-		    ok = TRUE;
-		    break;
-		default:
-		    break;
+	    case HTML_INPUT:
+	    case HTML_TEXTAREA:
+	    case HTML_SELECT:
+	    case HTML_BUTTON:
+	    case HTML_FIELDSET:
+	    case HTML_LABEL:
+	    case HTML_LEGEND:
+	    case HTML_FORM:
+		ok = TRUE;
+		break;
+	    default:
+		break;
 	    }
-	    if (ok)
-	    {
+	    if (ok) {
 		/*
-		**  It is another form-related start tag, so terminate
-		**  the current SELECT block and fall through. - FM
-		*/
-		CTRACE((tfp, "SGML: ***Faking SELECT end tag before <%s> start tag.\n",
-			    new_tag->name));
+		 * It is another form-related start tag, so terminate the
+		 * current SELECT block and fall through.  - FM
+		 */
+		CTRACE((tfp,
+			"SGML: ***Faking SELECT end tag before <%s> start tag.\n",
+			new_tag->name));
 		end_element(context, SGMLFindTag(context->dtd, "SELECT"));
 	    } else {
 		/*
-		**  Ignore the start tag. - FM
-		*/
-		CTRACE((tfp, "SGML: ***Ignoring start tag <%s> in SELECT block.\n",
-			    new_tag->name));
+		 * Ignore the start tag.  - FM
+		 */
+		CTRACE((tfp,
+			"SGML: ***Ignoring start tag <%s> in SELECT block.\n",
+			new_tag->name));
 		return;
 	    }
 	}
     }
     /*
-    **	Handle the start tag. - FM
-    */
+     * Handle the start tag.  - FM
+     */
     CTRACE((tfp, "SGML: Start <%s>\n", new_tag->name));
-    status = (*context->actions->start_element)(
-	context->target,
-	TAGNUM_OF_TAGP(new_tag),
-	context->present,
-	(CONST char**) context->value,	/* coerce type for think c */
-	context->current_tag_charset,
-	(char **)&context->include);
+    status = (*context->actions->start_element) (context->target,
+						 TAGNUM_OF_TAGP(new_tag),
+						 context->present,
+						 (const char **) context->value,	/* coerce type for think c */
+						 context->current_tag_charset,
+						 &context->include);
     if (status == HT_PARSER_OTHER_CONTENT)
 	new_tag = ALT_TAGP(new_tag);	/* this is only returned for OBJECT */
-    if (new_tag->contents != SGML_EMPTY) {		/* i.e., tag not empty */
-	HTElement * N = pool_alloc();
+    if (new_tag->contents != SGML_EMPTY) {	/* i.e., tag not empty */
+	HTElement *N = pool_alloc();
+
 	if (N == NULL)
 	    outofmem(__FILE__, "start_element");
 	N->next = context->element_stack;
@@ -1368,76 +1312,73 @@
 	context->element_stack = N;
 	context->no_lynx_specialcodes = (new_tag->flags & Tgf_nolyspcl);
 
-    } else if (e == HTML_META ) {
+    } else if (e == HTML_META) {
 	/*
-	**  Check for result of META tag. - KW & FM
-	*/
+	 * Check for result of META tag.  - KW & FM
+	 */
 	change_chartrans_handling(context);
     }
 }
 
-
 /*		Find Tag in DTD tag list
-**		------------------------
-**
-** On entry,
-**	dtd	points to dtd structure including valid tag list
-**	string	points to name of tag in question
-**
-** On exit,
-**	returns:
-**		NULL		tag not found
-**		else		address of tag structure in dtd
-*/
-PUBLIC HTTag * SGMLFindTag ARGS2(
-	CONST SGML_dtd*,	dtd,
-	CONST char *,		s)
+ *		------------------------
+ *
+ * On entry,
+ *	dtd	points to dtd structure including valid tag list
+ *	string	points to name of tag in question
+ *
+ * On exit,
+ *	returns:
+ *		NULL		tag not found
+ *		else		address of tag structure in dtd
+ */
+HTTag *SGMLFindTag(const SGML_dtd * dtd,
+		   const char *s)
 {
     int high, low, i, diff;
-    static HTTag* last[64] = {NULL};  /*optimize using the previous results*/
-    HTTag** res = last + (UCH(*s) % 64);     /*pointer arithmetic*/
+    static HTTag *last[64] =
+    {NULL};			/*optimize using the previous results */
+    HTTag **res = last + (UCH(*s) % 64);	/*pointer arithmetic */
 
     if (*res && !strcasecomp((*res)->name, s))
 	return *res;
 
-    for (low = 0, high=dtd->number_of_tags;
-	  high > low;
-	  diff < 0 ? (low = i+1) : (high = i)) {	/* Binary search */
-	i = (low + (high-low)/2);
+    for (low = 0, high = dtd->number_of_tags;
+	 high > low;
+	 diff < 0 ? (low = i + 1) : (high = i)) {	/* Binary search */
+	i = (low + (high - low) / 2);
 	/* my_casecomp() - optimized by the first character, NOT_ASCII ok */
 	diff = my_casecomp(dtd->tags[i].name, s);	/* Case insensitive */
-	if (diff == 0) {		/* success: found it */
+	if (diff == 0) {	/* success: found it */
 	    *res = &dtd->tags[i];
 	    return *res;
 	}
     }
     if (IsNmStart(*s)) {
 	/*
-	**  Unrecognized, but may be valid. - KW
-	*/
+	 * Unrecognized, but may be valid.  - KW
+	 */
 	return &HTTag_unrecognized;
     }
     return NULL;
 }
 
 /*________________________________________________________________________
-**			Public Methods
-*/
-
+ *			Public Methods
+ */
 
 /*	Could check that we are back to bottom of stack! @@  */
 /*	Do check! - FM					     */
 /*							     */
-PRIVATE void SGML_free ARGS1(
-	HTStream *,	context)
+static void SGML_free(HTStream *context)
 {
     int i;
-    HTElement * cur;
-    HTTag * t;
+    HTElement *cur;
+    HTTag *t;
 
     /*
-    **	Free the buffers. - FM
-    */
+     * Free the buffers.  - FM
+     */
     FREE(context->recover);
     FREE(context->url);
     FREE(context->csi);
@@ -1445,30 +1386,30 @@
     FREE(context->active_include);
 
     /*
-    **	Wind down stack if any elements are open. - FM
-    */
+     * Wind down stack if any elements are open.  - FM
+     */
     while (context->element_stack) {
 	cur = context->element_stack;
 	t = cur->tag;
 	context->element_stack = cur->next;	/* Remove from stack */
 	pool_free(cur);
 #ifdef USE_PRETTYSRC
-	if (!psrc_view) /* Don't actually call on target if viewing psrc - kw */
+	if (!psrc_view)		/* Don't actually call on target if viewing psrc - kw */
 #endif
-	    (*context->actions->end_element)(context->target,
-		    NORMAL_TAGNUM(TAGNUM_OF_TAGP(t)),
-		    (char **)&context->include);
+	    (*context->actions->end_element) (context->target,
+					      NORMAL_TAGNUM(TAGNUM_OF_TAGP(t)),
+					      &context->include);
 	FREE(context->include);
     }
 
     /*
-    **	Finish off the target. - FM
-    */
-    (*context->actions->_free)(context->target);
+     * Finish off the target.  - FM
+     */
+    (*context->actions->_free) (context->target);
 
     /*
-    **	Free the strings and context structure. - FM
-    */
+     * Free the strings and context structure.  - FM
+     */
     HTChunkFree(context->string);
     for (i = 0; i < MAX_ATTRIBUTES; i++)
 	FREE_extra(context->value[i]);
@@ -1479,21 +1420,19 @@
 #endif
 }
 
-PRIVATE void SGML_abort ARGS2(
-	HTStream *,	context,
-	HTError,	e)
+static void SGML_abort(HTStream *context, HTError e)
 {
     int i;
-    HTElement * cur;
+    HTElement *cur;
 
     /*
-    **	Abort the target. - FM
-    */
-    (*context->actions->_abort)(context->target, e);
+     * Abort the target.  - FM
+     */
+    (*context->actions->_abort) (context->target, e);
 
     /*
-    **	Free the buffers. - FM
-    */
+     * Free the buffers.  - FM
+     */
     FREE(context->recover);
     FREE(context->include);
     FREE(context->active_include);
@@ -1501,8 +1440,8 @@
     FREE(context->csi);
 
     /*
-    **	Free stack memory if any elements were left open. - KW
-    */
+     * Free stack memory if any elements were left open.  - KW
+     */
     while (context->element_stack) {
 	cur = context->element_stack;
 	context->element_stack = cur->next;	/* Remove from stack */
@@ -1510,8 +1449,8 @@
     }
 
     /*
-    **	Free the strings and context structure. - FM
-    */
+     * Free the strings and context structure.  - FM
+     */
     HTChunkFree(context->string);
     for (i = 0; i < MAX_ATTRIBUTES; i++)
 	FREE_extra(context->value[i]);
@@ -1522,68 +1461,62 @@
 #endif
 }
 
-
 /*	Read and write user callback handle
-**	-----------------------------------
-**
-**   The callbacks from the SGML parser have an SGML context parameter.
-**   These calls allow the caller to associate his own context with a
-**   particular SGML context.
-*/
+ *	-----------------------------------
+ *
+ *   The callbacks from the SGML parser have an SGML context parameter.
+ *   These calls allow the caller to associate his own context with a
+ *   particular SGML context.
+ */
 
 #ifdef CALLERDATA
-PUBLIC void* SGML_callerData ARGS1(
-	HTStream *,	context)
+void *SGML_callerData(HTStream *context)
 {
     return context->callerData;
 }
 
-PUBLIC void SGML_setCallerData ARGS2(
-	HTStream *,	context,
-	void*,		data)
+void SGML_setCallerData(HTStream *context, void *data)
 {
     context->callerData = data;
 }
 #endif /* CALLERDATA */
 
-PRIVATE void SGML_character ARGS2(
-	HTStream *,	context,
-	char,		c_in)
-{
-    CONST SGML_dtd *dtd =	context->dtd;
-    HTChunk	*string =	context->string;
-    CONST char * EntityName;
-    HTTag * testtag = NULL;
-    BOOLEAN chk;	/* Helps (?) walk through all the else ifs... */
-    UCode_t clong, uck = 0; /* Enough bits for UCS4 ... */
+static void SGML_character(HTStream *context, char c_in)
+{
+    const SGML_dtd *dtd = context->dtd;
+    HTChunk *string = context->string;
+    const char *EntityName;
+    HTTag *testtag = NULL;
+    BOOLEAN chk;		/* Helps (?) walk through all the else ifs... */
+    UCode_t clong, uck = 0;	/* Enough bits for UCS4 ... */
     int testlast;
+
 #ifdef CJK_EX
     unsigned char c;
+
 #else
     char c;
 #endif
     char saved_char_in = '\0';
 
     /*
-    **	Now some fun with the preprocessor.
-    **	Use copies for c and unsign_c == clong, so that
-    **	we can revert back to the unchanged c_in. - KW
-    */
+     * Now some fun with the preprocessor.  Use copies for c and unsign_c ==
+     * clong, so that we can revert back to the unchanged c_in.  - KW
+     */
 #define unsign_c clong
 
     c = c_in;
-    clong = UCH(c);	/* a.k.a. unsign_c */
+    clong = UCH(c);		/* a.k.a. unsign_c */
 
     if (context->T.decode_utf8) {
 	/*
-	**  Combine UTF-8 into Unicode.
-	**  Incomplete characters silently ignored.
-	**  From Linux kernel's console.c. - KW
-	*/
-	if (TOASCII(UCH(c)) > 127) { /* S/390 -- gil -- 0710 */
+	 * Combine UTF-8 into Unicode.  Incomplete characters silently ignored. 
+	 * From Linux kernel's console.c.  - KW
+	 */
+	if (TOASCII(UCH(c)) > 127) {	/* S/390 -- gil -- 0710 */
 	    /*
-	    **	We have an octet from a multibyte character. - FM
-	    */
+	     * We have an octet from a multibyte character.  - FM
+	     */
 	    if (context->utf_count > 0 && (TOASCII(c) & 0xc0) == 0x80) {
 		context->utf_char = (context->utf_char << 6) | (TOASCII(c) & 0x3f);
 		context->utf_count--;
@@ -1591,26 +1524,25 @@
 		(context->utf_buf_p)++;
 		if (context->utf_count == 0) {
 		    /*
-		    **	We have all of the bytes, so terminate
-		    **	the buffer and set 'clong' to the UCode_t
-		    **	value. - FM
-		    */
+		     * We have all of the bytes, so terminate the buffer and
+		     * set 'clong' to the UCode_t value.  - FM
+		     */
 		    *(context->utf_buf_p) = '\0';
 		    clong = context->utf_char;
 		    if (clong < 256) {
-			c = ((char)(clong & 0xff));
+			c = ((char) (clong & 0xff));
 		    }
 		    goto top1;
 		} else {
 		    /*
-		    **	Wait for more. - KW
-		    */
+		     * Wait for more.  - KW
+		     */
 		    return;
 		}
 	    } else {
 		/*
-		**  Start handling a new multibyte character. - FM
-		*/
+		 * Start handling a new multibyte character.  - FM
+		 */
 		context->utf_buf_p = context->utf_buf;
 		*(context->utf_buf_p) = c;
 		(context->utf_buf_p)++;
@@ -1631,70 +1563,68 @@
 		    context->utf_char = (c & 0x01);
 		} else {
 		    /*
-		    **	Garbage. - KW
-		    */
+		     * Garbage.  - KW
+		     */
 		    context->utf_count = 0;
 		    context->utf_buf_p = context->utf_buf;
 		    *(context->utf_buf_p) = '\0';
 		}
 		/*
-		**  Wait for more. - KW
-		*/
+		 * Wait for more.  - KW
+		 */
 		return;
 	    }
 	} else {
 	    /*
-	    **	Got an ASCII char. - KW
-	    */
+	     * Got an ASCII char.  - KW
+	     */
 	    context->utf_count = 0;
 	    context->utf_buf_p = context->utf_buf;
 	    *(context->utf_buf_p) = '\0';
-		    /*	goto top;  */
+	    /*  goto top;  */
 	}
-    } /* end of context->T.decode_utf8	S/390 -- gil -- 0726 */
-
+    }
+    /* end of context->T.decode_utf8      S/390 -- gil -- 0726 */
 #ifdef NOTDEFINED
     /*
-    **	If we have a koi8-r input and do not have
-    **	koi8-r as the output, save the raw input
-    **	in saved_char_in before we potentially
-    **	convert it to Unicode. - FM
-    */
+     * If we have a koi8-r input and do not have koi8-r as the output, save the
+     * raw input in saved_char_in before we potentially convert it to Unicode. 
+     * - FM
+     */
     if (context->T.strip_raw_char_in)
 	saved_char_in = c;
 #endif /* NOTDEFINED */
 
     /*
-    **	If we want the raw input converted
-    **	to Unicode, try that now. - FM
-    */
+     * If we want the raw input converted to Unicode, try that now.  - FM
+     */
     if (context->T.trans_to_uni &&
-	((TOASCII(unsign_c) >= LYlowest_eightbit[context->inUCLYhndl]) ||  /* S/390 -- gil -- 0744 */
+	((TOASCII(unsign_c) >= LYlowest_eightbit[context->inUCLYhndl]) ||	/* S/390 -- gil -- 0744 */
 	 (unsign_c < ' ' && unsign_c != 0 &&
 	  context->T.trans_C0_to_uni))) {
 	/*
-	**  Convert the octet to Unicode. - FM
-	*/
+	 * Convert the octet to Unicode.  - FM
+	 */
 	clong = UCTransToUni(c, context->inUCLYhndl);
 	if (clong > 0) {
 	    saved_char_in = c;
 	    if (clong < 256) {
-		c = FROMASCII((char)clong);
+		c = FROMASCII((char) clong);
 	    }
 	}
 	goto top1;
-    } else if (unsign_c < ' ' && unsign_c != 0 &&  /* S/390 -- gil -- 0768 */
+    } else if (unsign_c < ' ' && unsign_c != 0 &&	/* S/390 -- gil -- 0768 */
 	       context->T.trans_C0_to_uni) {
 	/*
-	**  This else if may be too ugly to keep. - KW
-	*/
+	 * This else if may be too ugly to keep.  - KW
+	 */
 	if (context->T.trans_from_uni &&
 	    (((clong = UCTransToUni(c, context->inUCLYhndl)) >= ' ') ||
 	     (context->T.transp &&
 	      (clong = UCTransToUni(c, context->inUCLYhndl)) > 0))) {
 	    saved_char_in = c;
 	    if (clong < 256) {
-		c = FROMASCII((char)clong);
+		c = FROMASCII((char) clong);
 	    }
 	    goto top1;
 	} else {
@@ -1723,80 +1653,78 @@
 		StrAllocCat(context->recover, replace_buf + 1);
 	    }
 	    goto top0a;
-	} /*  Next line end of ugly stuff for C0. - KW */
-    } else {  /* end of context->T.trans_to_uni	 S/390 -- gil -- 0791 */
+	}			/*  Next line end of ugly stuff for C0. - KW */
+    } else {			/* end of context->T.trans_to_uni  S/390 -- gil -- 0791 */
 	goto top0a;
     }
 
     /*
-    **	At this point we have either unsign_c a.k.a. clong in
-    **	Unicode (and c in latin1 if clong is in the latin1 range),
-    **	or unsign_c and c will have to be passed raw. - KW
-    */
+     * At this point we have either unsign_c a.k.a.  clong in Unicode (and c in
+     * latin1 if clong is in the latin1 range), or unsign_c and c will have to
+     * be passed raw.  - KW
+     */
 /*
-**  We jump up to here from below if we have
-**  stuff in the recover, insert, or csi buffers
-**  to process.	 We zero saved_char_in, in effect
-**  as a flag that the octet in not that of the
-**  actual call to this function.  This may be OK
-**  for now, for the stuff this function adds to
-**  its recover buffer, but it might not be for
-**  stuff other functions added to the insert or
-**  csi buffer, so bear that in mind. - FM
-**  Stuff from the recover buffer is now handled
-**  as UTF-8 if we can expect that's what it is,
-**  and in that case we don't come back up here. - kw
-*/
-top:
+ *  We jump up to here from below if we have
+ *  stuff in the recover, insert, or csi buffers
+ *  to process.	 We zero saved_char_in, in effect
+ *  as a flag that the octet in not that of the
+ *  actual call to this function.  This may be OK
+ *  for now, for the stuff this function adds to
+ *  its recover buffer, but it might not be for
+ *  stuff other functions added to the insert or
+ *  csi buffer, so bear that in mind. - FM
+ *  Stuff from the recover buffer is now handled
+ *  as UTF-8 if we can expect that's what it is,
+ *  and in that case we don't come back up here. - kw
+ */
+  top:
     saved_char_in = '\0';
 /*
-**  We jump to here from above when we don't have
-**  UTF-8 input, haven't converted to Unicode, and
-**  want clong set to the input octet (unsigned)
-**  without zeroing its saved_char_in copy (which
-**  is signed). - FM
-*/
-top0a:
+ *  We jump to here from above when we don't have
+ *  UTF-8 input, haven't converted to Unicode, and
+ *  want clong set to the input octet (unsigned)
+ *  without zeroing its saved_char_in copy (which
+ *  is signed). - FM
+ */
+  top0a:
     *(context->utf_buf) = '\0';
     clong = UCH(c);
 /*
-**  We jump to here from above if we have converted
-**  the input, or a multibyte sequence across calls,
-**  to a Unicode value and loaded it into clong (to
-**  which unsign_c has been defined), and from below
-**  when we are recycling a character (e.g., because
-**  it terminated an entity but is not the standard
-**  semi-colon).  The character will already have
-**  been put through the Unicode conversions. - FM
-*/
-top1:
+ *  We jump to here from above if we have converted
+ *  the input, or a multibyte sequence across calls,
+ *  to a Unicode value and loaded it into clong (to
+ *  which unsign_c has been defined), and from below
+ *  when we are recycling a character (e.g., because
+ *  it terminated an entity but is not the standard
+ *  semi-colon).  The character will already have
+ *  been put through the Unicode conversions. - FM
+ */
+  top1:
     /*
-    **	Ignore low ISO 646 7-bit control characters
-    **	if HTCJK is not set. - FM
-    */
+     * Ignore low ISO 646 7-bit control characters if HTCJK is not set.  - FM
+     */
     /*
-    ** Works for both ASCII and EBCDIC. -- gil
-    */	/* S/390 -- gil -- 0811 */
+     * Works for both ASCII and EBCDIC. -- gil
+ *//* S/390 -- gil -- 0811 */
     if (TOASCII(unsign_c) < 32 &&
 	c != '\t' && c != '\n' && c != '\r' &&
 	HTCJK == NOCJK)
 	goto after_switch;
 
     /*
-    **	Ignore 127 if we don't have HTPassHighCtrlRaw
-    **	or HTCJK set. - FM
-    */
+     * Ignore 127 if we don't have HTPassHighCtrlRaw or HTCJK set.  - FM
+     */
 #define PASSHICTRL (context->T.transp || \
 		    unsign_c >= LYlowest_eightbit[context->inUCLYhndl])
-    if (TOASCII(c) == 127 &&  /* S/390 -- gil -- 0830 */
+    if (TOASCII(c) == 127 &&	/* S/390 -- gil -- 0830 */
 	!(PASSHICTRL || HTCJK != NOCJK))
 	goto after_switch;
 
     /*
-    **	Ignore 8-bit control characters 128 - 159 if
-    **	neither HTPassHighCtrlRaw nor HTCJK is set. - FM
-    */
-    if (TOASCII(unsign_c) > 127 && TOASCII(unsign_c) < 160 &&  /* S/390 -- gil -- 0847 */
+     * Ignore 8-bit control characters 128 - 159 if neither HTPassHighCtrlRaw
+     * nor HTCJK is set.  - FM
+     */
+    if (TOASCII(unsign_c) > 127 && TOASCII(unsign_c) < 160 &&	/* S/390 -- gil -- 0847 */
 	!(PASSHICTRL || HTCJK != NOCJK))
 	goto after_switch;
 
@@ -1804,42 +1732,44 @@
      * JIS X0201 Kana is single byte. To prevent to fail SGML parsing
      * we have to care them here. -- TH
      */
-    if ((HTCJK==JAPANESE) && (context->state==S_in_kanji) &&
-	!IS_JAPANESE_2BYTE(context->kanji_buf, UCH(c))) {
+    if ((HTCJK == JAPANESE) && (context->state == S_in_kanji) &&
+	!IS_JAPANESE_2BYTE(context->kanji_buf, UCH(c))
+#ifdef EXP_JAPANESEUTF8_SUPPORT
+	&& !context->T.decode_utf8
+#endif
+	) {
 #ifdef CONV_JISX0201KANA_JISX0208KANA
 	if (IS_SJIS_X0201KANA(context->kanji_buf)) {
 	    unsigned char sjis_hi, sjis_lo;
+
 	    JISx0201TO0208_SJIS(context->kanji_buf, &sjis_hi, &sjis_lo);
 	    PUTC(sjis_hi);
 	    PUTC(sjis_lo);
-	}
-	else
+	} else
 #endif
 	    PUTC(context->kanji_buf);
 	context->state = S_text;
     }
 
     /*
-    **	Handle character based on context->state.
-    */
+     * Handle character based on context->state.
+     */
     CTRACE2(TRACE_SGML, (tfp, "SGML before %s|%.*s|%c|\n",
-	    state_name(context->state),
-	    string->size,
-	    NonNull(string->data),
-	    UCH(c)));
-    switch(context->state) {
+			 state_name(context->state),
+			 string->size,
+			 NonNull(string->data),
+			 UCH(c)));
+    switch (context->state) {
 
     case S_in_kanji:
 	/*
-	**  Note that if we don't have a CJK input, then this
-	**  is not the second byte of a CJK di-byte, and we're
-	**  trashing the input.	 That's why 8-bit characters
-	**  followed by, for example, '<' can cause the tag to
-	**  be treated as text, not markup.  We could try to deal
-	**  with it by holding each first byte and then checking
-	**  byte pairs, but that doesn't seem worth the overhead
-	**  (see below). - FM
-	*/
+	 * Note that if we don't have a CJK input, then this is not the second
+	 * byte of a CJK di-byte, and we're trashing the input.  That's why
+	 * 8-bit characters followed by, for example, '<' can cause the tag to
+	 * be treated as text, not markup.  We could try to deal with it by
+	 * holding each first byte and then checking byte pairs, but that
+	 * doesn't seem worth the overhead (see below).  - FM
+	 */
 	context->state = S_text;
 	PUTC(context->kanji_buf);
 	PUTC(c);
@@ -1847,36 +1777,38 @@
 
     case S_tagname_slash:
 	/*
-	 *  We had something link "<name/" so far, set state to S_text
-	 *  but keep context->slashedtag as as a flag; except if we get
-	 *  '>' directly after the "<name/", and really have a tag for
-	 *  that name in context->slashedtag, in which case keep state as
-	 *  is and let code below deal with it. - kw
+	 * We had something link "<name/" so far, set state to S_text but keep
+	 * context->slashedtag as as a flag; except if we get '>' directly
+	 * after the "<name/", and really have a tag for that name in
+	 * context->slashedtag, in which case keep state as is and let code
+	 * below deal with it.  - kw
 	 */
 	if (!(c == '>' && context->slashedtag && TOASCII(unsign_c) < 127)) {
 	    context->state = S_text;
-	} /* fall through in any case! */
-
+	}
+	/* fall through in any case! */
     case S_text:
-	if (HTCJK != NOCJK && (TOASCII(c) & 0200) != 0) {  /* S/390 -- gil -- 0864 */
-	    /*
-	    **	Setting up for Kanji multibyte handling (based on
-	    **	Takuya ASADA's (asada@three-a.co.jp) CJK Lynx).
-	    **	Note that if the input is not in fact CJK, the
-	    **	next byte also will be mishandled, as explained
-	    **	above.	Toggle raw mode off in such cases, or
-	    **	select the "7 bit approximations" display
-	    **	character set, which is largely equivalent
-	    **	to having raw mode off with CJK. - FM
-	    */
+	if ((HTCJK != NOCJK) && ((TOASCII(c) & 0200) != 0)
+#ifdef EXP_JAPANESEUTF8_SUPPORT
+	    && !context->T.decode_utf8
+#endif
+	    ) {			/* S/390 -- gil -- 0864 */
+	    /*
+	     * Setting up for Kanji multibyte handling (based on Takuya ASADA's
+	     * (asada@three-a.co.jp) CJK Lynx).  Note that if the input is not
+	     * in fact CJK, the next byte also will be mishandled, as explained
+	     * above.  Toggle raw mode off in such cases, or select the "7 bit
+	     * approximations" display character set, which is largely
+	     * equivalent to having raw mode off with CJK.  - FM
+	     */
 	    context->state = S_in_kanji;
 	    context->kanji_buf = c;
 	    break;
-	} else if (HTCJK != NOCJK && TOASCII(c) == '\033') {  /* S/390 -- gil -- 0881 */
+	} else if (HTCJK != NOCJK && TOASCII(c) == '\033') {	/* S/390 -- gil -- 0881 */
 	    /*
-	    **	Setting up for CJK escape sequence handling (based on
-	    **	Takuya ASADA's (asada@three-a.co.jp) CJK Lynx). - FM
-	    */
+	     * Setting up for CJK escape sequence handling (based on Takuya
+	     * ASADA's (asada@three-a.co.jp) CJK Lynx).  - FM
+	     */
 	    context->state = S_esc;
 	    PUTC(c);
 	    break;
@@ -1884,17 +1816,17 @@
 
 	if (c == '&' || c == '<') {
 #ifdef USE_PRETTYSRC
-	    if (psrc_view) { /*there is nothing useful in the element_stack*/
+	    if (psrc_view) {	/*there is nothing useful in the element_stack */
 		testtag = context->current_tag;
 	    } else
 #endif
 	    {
 		testtag = context->element_stack ?
-		     context->element_stack->tag : NULL;
+		    context->element_stack->tag : NULL;
 	    }
 	}
 
-	if (c == '&' && TOASCII(unsign_c) < 127	 &&  /* S/390 -- gil -- 0898 */
+	if (c == '&' && TOASCII(unsign_c) < 127 &&	/* S/390 -- gil -- 0898 */
 	    (!testtag ||
 	     (testtag->contents == SGML_MIXED ||
 	      testtag->contents == SGML_ELEMENT ||
@@ -1904,19 +1836,19 @@
 #endif
 	      testtag->contents == SGML_RCDATA))) {
 	    /*
-	    **	Setting up for possible entity, without the leading '&'. - FM
-	    */
+	     * Setting up for possible entity, without the leading '&'.  - FM
+	     */
 	    string->size = 0;
 	    context->state = S_ero;
-	} else if (c == '<' && TOASCII(unsign_c) < 127) {  /* S/390 -- gil -- 0915 */
+	} else if (c == '<' && TOASCII(unsign_c) < 127) {	/* S/390 -- gil -- 0915 */
 	    /*
-	    **	Setting up for possible tag. - FM
-	    */
+	     * Setting up for possible tag.  - FM
+	     */
 	    string->size = 0;
 	    if (testtag && testtag->contents == SGML_PCDATA) {
 		context->state = S_pcdata;
 	    } else if (testtag && (testtag->contents == SGML_LITTERAL
-				|| testtag->contents == SGML_CDATA)) {
+				   || testtag->contents == SGML_CDATA)) {
 		context->state = S_litteral;
 	    } else if (testtag && (testtag->contents == SGML_SCRIPT)) {
 		context->state = S_script;
@@ -1929,11 +1861,11 @@
 		    (c == '>' && context->state == S_tagname_slash)) &&
 		   TOASCII(unsign_c) < 127) {
 	    /*
-	    **	We got either the second slash of a pending "<NAME/blah blah/"
-	    **  shortref construct, or the '>' of a mere "<NAME/>".  In both
-	    **  cases generate a "</NAME>" end tag in the recover buffer for
-	    **  reparsing unless NAME is really an empty element. - kw
-	    */
+	     * We got either the second slash of a pending "<NAME/blah blah/"
+	     * shortref construct, or the '>' of a mere "<NAME/>".  In both
+	     * cases generate a "</NAME>" end tag in the recover buffer for
+	     * reparsing unless NAME is really an empty element.  - kw
+	     */
 #ifdef USE_PRETTYSRC
 	    if (psrc_view) {
 		PSRCSTART(abracket);
@@ -1941,8 +1873,8 @@
 		PSRCSTOP(abracket);
 	    } else
 #endif
-	    if (context->slashedtag != context->unknown_tag &&
-		!ReallyEmptyTag(context->slashedtag)) {
+		if (context->slashedtag != context->unknown_tag &&
+		    !ReallyEmptyTag(context->slashedtag)) {
 		if (context->recover == NULL) {
 		    StrAllocCopy(context->recover, "</");
 		    context->recover_index = 0;
@@ -1957,12 +1889,12 @@
 	} else if (context->element_stack &&
 		   (context->element_stack->tag->flags & Tgf_frecyc)) {
 	    /*
-	     *  The element stack says we are within the contents of an
-	     *  element that the next stage (HTML.c) may want to feed
-	     *  us back again (via the *include string).  So try to output
-	     *  text in UTF-8 if possible, using the same logic as for
-	     *  attribute values (which should be in line with what
-	     *  context->current_tag_charset indicates). - kw
+	     * The element stack says we are within the contents of an element
+	     * that the next stage (HTML.c) may want to feed us back again (via
+	     * the *include string).  So try to output text in UTF-8 if
+	     * possible, using the same logic as for attribute values (which
+	     * should be in line with what context->current_tag_charset
+	     * indicates).  - kw
 	     */
 	    if (context->T.decode_utf8 &&
 		*context->utf_buf) {
@@ -1975,9 +1907,9 @@
 		if (LYIsASCII(clong)) {
 		    PUTC(c);
 		} else if (clong == 0xfffd && saved_char_in &&
-		    HTPassEightBitRaw &&
-		    UCH(saved_char_in) >=
-		    LYlowest_eightbit[context->outUCLYhndl]) {
+			   HTPassEightBitRaw &&
+			   UCH(saved_char_in) >=
+			   LYlowest_eightbit[context->outUCLYhndl]) {
 		    PUTUTF8((0xf000 | UCH(saved_char_in)));
 		} else {
 		    PUTUTF8(clong);
@@ -1989,74 +1921,75 @@
 	    }
 
 #define PASS8859SPECL context->T.pass_160_173_raw
-	/*
-	**  Convert 160 (nbsp) to Lynx special character if
-	**  neither HTPassHighCtrlRaw nor HTCJK is set. - FM
-	*/
-	} else if (unsign_c == CH_NBSP &&  /* S/390 -- gil -- 0932 */
+	    /*
+	     * Convert 160 (nbsp) to Lynx special character if neither
+	     * HTPassHighCtrlRaw nor HTCJK is set.  - FM
+	     */
+	} else if (unsign_c == CH_NBSP &&	/* S/390 -- gil -- 0932 */
 		   !context->no_lynx_specialcodes &&
 		   !(PASS8859SPECL || HTCJK != NOCJK)) {
 	    PUTC(HT_NON_BREAK_SPACE);
-	/*
-	**  Convert 173 (shy) to Lynx special character if
-	**  neither HTPassHighCtrlRaw nor HTCJK is set. - FM
-	*/
-	} else if (unsign_c == CH_SHY &&  /* S/390 -- gil -- 0949 */
+	    /*
+	     * Convert 173 (shy) to Lynx special character if neither
+	     * HTPassHighCtrlRaw nor HTCJK is set.  - FM
+	     */
+	} else if (unsign_c == CH_SHY &&	/* S/390 -- gil -- 0949 */
 		   !context->no_lynx_specialcodes &&
 		   !(PASS8859SPECL || HTCJK != NOCJK)) {
 	    PUTC(LY_SOFT_HYPHEN);
-	/*
-	**  Handle the case in which we think we have a character
-	**  which doesn't need further processing (e.g., a koi8-r
-	**  input for a koi8-r output). - FM
-	*/
+	    /*
+	     * Handle the case in which we think we have a character which
+	     * doesn't need further processing (e.g., a koi8-r input for a
+	     * koi8-r output).  - FM
+	     */
 	} else if (context->T.use_raw_char_in && saved_char_in) {
 	    /*
-	    **	Only if the original character is still in saved_char_in,
-	    **	otherwise we may be iterating from a goto top. - KW
-	    */
+	     * Only if the original character is still in saved_char_in,
+	     * otherwise we may be iterating from a goto top.  - KW
+	     */
 	    PUTC(saved_char_in);
 	    saved_char_in = '\0';
 /******************************************************************
- *   I. LATIN-1 OR UCS2	 TO  DISPLAY CHARSET
+ * I.  LATIN-1 OR UCS2 TO DISPLAY CHARSET
  ******************************************************************/
-	} else if ((chk = (BOOL) (context->T.trans_from_uni && TOASCII(unsign_c) >= 160)) &&  /* S/390 -- gil -- 0968 */
+	} else if ((chk = (BOOL) (context->T.trans_from_uni &&
+				  TOASCII(unsign_c) >= 160)) &&		/* S/390 -- gil -- 0968 */
 		   (uck = UCTransUniChar(unsign_c,
 					 context->outUCLYhndl)) >= ' ' &&
 		   uck < 256) {
 	    CTRACE((tfp, "UCTransUniChar returned 0x%.2lX:'%c'.\n",
-			uck, FROMASCII((char)uck)));
+		    uck, FROMASCII((char) uck)));
 	    /*
-	    **	We got one octet from the conversions, so use it. - FM
-	    */
-	    PUTC(FROMASCII((char)uck));
+	     * We got one octet from the conversions, so use it.  - FM
+	     */
+	    PUTC(FROMASCII((char) uck));
 	} else if ((chk &&
-		   (uck == -4 ||
-		    (context->T.repl_translated_C0 &&
-		     uck > 0 && uck < 32))) &&
-		   /*
-		   **  Not found; look for replacement string. - KW
-		   */
+		    (uck == -4 ||
+		     (context->T.repl_translated_C0 &&
+		      uck > 0 && uck < 32))) &&
+	    /*
+	     * Not found; look for replacement string.  - KW
+	     */
 		   (uck = UCTransUniCharStr(replace_buf, 60, clong,
 					    context->outUCLYhndl,
 					    0) >= 0)) {
 	    /*
-	    **	Got a replacement string.
-	    **	No further tests for validity - assume that whoever
-	    **	defined replacement strings knew what she was doing. - KW
-	    */
+	     * Got a replacement string.  No further tests for validity -
+	     * assume that whoever defined replacement strings knew what she
+	     * was doing.  - KW
+	     */
 	    PUTS(replace_buf);
-	/*
-	**  If we're displaying UTF-8, try that now. - FM
-	*/
+	    /*
+	     * If we're displaying UTF-8, try that now.  - FM
+	     */
 	} else if (context->T.output_utf8 && PUTUTF8(clong)) {
-	    ; /* do nothing more */
-	/*
-	**  If it's any other (> 160) 8-bit character, and
-	**  we have not set HTPassEightBitRaw nor HTCJK, nor
-	**  have the "ISO Latin 1" character set selected,
-	**  back translate for our character set. - FM
-	*/
+	    ;			/* do nothing more */
+	    /*
+	     * If it's any other (> 160) 8-bit character, and we have not set
+	     * HTPassEightBitRaw nor HTCJK, nor have the "ISO Latin 1"
+	     * character set selected, back translate for our character set.  -
+	     * FM
+	     */
 #define IncludesLatin1Enc \
 		(context->outUCLYhndl == LATIN1 || \
 		 (context->outUCI && \
@@ -2073,18 +2006,19 @@
 #endif
 
 	    string->size = 0;
-	    EntityName = HTMLGetEntityName((int)(unsign_c - 160));
+	    EntityName = HTMLGetEntityName((int) (unsign_c - 160));
 	    HTChunkPuts(string, EntityName);
 	    HTChunkTerminate(string);
 #ifdef USE_PRETTYSRC
-	    /* we need to disable it temporary*/
+	    /* we need to disable it temporary */
 	    if (psrc_view) {
-		psrc_view_backup =1; psrc_view =0;
+		psrc_view_backup = 1;
+		psrc_view = 0;
 	    }
 #endif
 	    handle_entity(context, '\0');
 #ifdef USE_PRETTYSRC
-	    /* we need to disable it temporary*/
+	    /* we need to disable it temporary */
 	    if (psrc_view_backup)
 		psrc_view = TRUE;
 #endif
@@ -2092,72 +2026,71 @@
 	    string->size = 0;
 	    if (!FoundEntity)
 		PUTC(';');
-	/*
-	**  If we get to here and have an ASCII char,
-	**  pass the character. - KW
-	*/
-	} else if (TOASCII(unsign_c) < 127 && unsign_c > 0) {  /* S/390 -- gil -- 0987 */
+	    /*
+	     * If we get to here and have an ASCII char, pass the character.  -
+	     * KW
+	     */
+	} else if (TOASCII(unsign_c) < 127 && unsign_c > 0) {	/* S/390 -- gil -- 0987 */
 	    PUTC(c);
-	/*
-	**  If we get to here, and should have translated,
-	**  translation has failed so far. - KW
-	**
-	**  We should have sent UTF-8 output to the parser
-	**  already, but what the heck, try again. - FM
-	*/
+	    /*
+	     * If we get to here, and should have translated, translation has
+	     * failed so far.  - KW
+	     *
+	     * We should have sent UTF-8 output to the parser already, but what
+	     * the heck, try again.  - FM
+	     */
 	} else if (context->T.output_utf8 && *context->utf_buf) {
 	    PUTS(context->utf_buf);
 	    context->utf_buf_p = context->utf_buf;
 	    *(context->utf_buf_p) = '\0';
 #ifdef NOTDEFINED
-	/*
-	**  Check for a strippable koi8-r 8-bit character. - FM
-	*/
+	    /*
+	     * Check for a strippable koi8-r 8-bit character.  - FM
+	     */
 	} else if (context->T.strip_raw_char_in && saved_char_in &&
 		   (UCH(saved_char_in) >= 0xc0) &&
 		   (UCH(saved_char_in) < 255)) {
 	    /*
-	    **	KOI8 special: strip high bit, gives (somewhat) readable
-	    **	ASCII or KOI7 - it was constructed that way! - KW
-	    */
-	    PUTC(((char)(saved_char_in & 0x7f)));
+	     * KOI8 special:  strip high bit, gives (somewhat) readable ASCII
+	     * or KOI7 - it was constructed that way!  - KW
+	     */
+	    PUTC(((char) (saved_char_in & 0x7f)));
 	    saved_char_in = '\0';
 #endif /* NOTDEFINED */
-	/*
-	**  If we don't actually want the character,
-	**  make it safe and output that now. - FM
-	*/
-	} else if (TOASCII(UCH(c)) <	 /* S/390 -- gil -- 0997 */
-			LYlowest_eightbit[context->outUCLYhndl] ||
+	    /*
+	     * If we don't actually want the character, make it safe and output
+	     * that now.  - FM
+	     */
+	} else if (TOASCII(UCH(c)) <	/* S/390 -- gil -- 0997 */
+		   LYlowest_eightbit[context->outUCLYhndl] ||
 		   (context->T.trans_from_uni && !HTPassEightBitRaw)) {
-	/*
-	**  If we get to here, pass the character. - FM
-	*/
+	    /*
+	     * If we get to here, pass the character.  - FM
+	     */
 	} else {
 	    PUTC(c);
 	}
 	break;
 
-    /*
-    **	Found '<' in SGML_PCDATA content; treat this mode nearly like
-    **  S_litteral, but recognize '<!' and '<?' to filter out comments
-    **  and processing instructions. - kw
-    */
+	/*
+	 * Found '<' in SGML_PCDATA content; treat this mode nearly like
+	 * S_litteral, but recognize '<!' and '<?' to filter out comments and
+	 * processing instructions.  - kw
+	 */
     case S_pcdata:
-	if (!string->size && TOASCII(unsign_c) < 127) { /* first after '<' */
-	    if (c == '!') { /* <! */
+	if (!string->size && TOASCII(unsign_c) < 127) {		/* first after '<' */
+	    if (c == '!') {	/* <! */
 		/*
-		**	Terminate and set up for possible comment,
-		**	identifier, declaration, or marked section
-		**  as under S_tag. - kw
-		*/
+		 * Terminate and set up for possible comment, identifier,
+		 * declaration, or marked section as under S_tag.  - kw
+		 */
 		context->state = S_exclamation;
 		context->lead_exclamation = TRUE;
 		context->doctype_bracket = FALSE;
 		context->first_bracket = FALSE;
 		HTChunkPutc(string, c);
 		break;
-	    } else if (c == '?') { /* <? - ignore as a PI until '>' - kw */
+	    } else if (c == '?') {	/* <? - ignore as a PI until '>' - kw */
 		CTRACE((tfp,
 			"SGML: Found PI in PCDATA, junking it until '>'\n"));
 #ifdef USE_PRETTYSRC
@@ -2165,7 +2098,7 @@
 		    PSRCSTART(abracket);
 		    PUTS("<?");
 		    PSRCSTOP(abracket);
-		    context->seen_nonwhite_in_junk_tag = TRUE; /* show all */
+		    context->seen_nonwhite_in_junk_tag = TRUE;	/* show all */
 		}
 #endif
 		context->state = S_junk_pi;
@@ -2174,19 +2107,18 @@
 	}
 	goto case_S_litteral;
 
-    /*
-    **  Found '<' in SGML_SCRIPT content; treat this mode nearly like
-    **  S_litteral, but recognize '<!' to allow the content to be treated
-    **  as a comment by lynx.
-    */
+	/*
+	 * Found '<' in SGML_SCRIPT content; treat this mode nearly like
+	 * S_litteral, but recognize '<!' to allow the content to be treated as
+	 * a comment by lynx.
+	 */
     case S_script:
-	if (!string->size && TOASCII(unsign_c) < 127) { /* first after '<' */
-	    if (c == '!') { /* <! */
+	if (!string->size && TOASCII(unsign_c) < 127) {		/* first after '<' */
+	    if (c == '!') {	/* <! */
 		/*
-		**	Terminate and set up for possible comment,
-		**	identifier, declaration, or marked section
-		**  as under S_tag. - kw
-		*/
+		 * Terminate and set up for possible comment, identifier,
+		 * declaration, or marked section as under S_tag.  - kw
+		 */
 		context->state = S_exclamation;
 		context->lead_exclamation = TRUE;
 		context->doctype_bracket = FALSE;
@@ -2197,15 +2129,15 @@
 	}
 	goto case_S_litteral;
 
-    /*
-    **	In litteral mode, waits only for specific end tag (for
-    **	compatibility with old servers, and for Lynx). - FM
-    */
-    case_S_litteral:
-    case S_litteral: /*PSRC:this case not understood completely by HV, not done*/
+	/*
+	 * In litteral mode, waits only for specific end tag (for compatibility
+	 * with old servers, and for Lynx).  - FM
+	 */
+      case_S_litteral:
+    case S_litteral:		/*PSRC:this case not understood completely by HV, not done */
 	HTChunkPutc(string, c);
 #ifdef USE_PRETTYSRC
-	if (psrc_view) { /*there is nothing useful in the element_stack*/
+	if (psrc_view) {	/*there is nothing useful in the element_stack */
 	    testtag = context->current_tag;
 	} else
 #endif
@@ -2220,20 +2152,20 @@
 
 	/*
 	 * Normally when we get the closing ">",
-	 *	testtag contains something like "TITLE"
-	 *	string contains something like "/title>"
+	 *      testtag contains something like "TITLE"
+	 *      string contains something like "/title>"
 	 * so we decrement by 2 to compare the final character of each.
 	 */
 	testlast = string->size - 2 - context->trailing_spaces - context->leading_spaces;
 
 	if (TOUPPER(c) != ((testlast < 0)
-			    ? '/'
-			    : testtag->name[testlast])) {
+			   ? '/'
+			   : testtag->name[testlast])) {
 	    int i;
 
 	    /*
-	    **	If complete match, end litteral.
-	    */
+	     * If complete match, end litteral.
+	     */
 	    if ((c == '>') &&
 		testlast >= 0 && !testtag->name[testlast]) {
 #ifdef USE_PRETTYSRC
@@ -2242,7 +2174,7 @@
 		    PUTS("</");
 		    PSRCSTOP(abracket);
 		    PSRCSTART(tag);
-		    strcpy(string->data,context->current_tag->name);
+		    strcpy(string->data, context->current_tag->name);
 		    if (tagname_transform != 1) {
 			if (tagname_transform == 0)
 			    LYLowerCase(string->data);
@@ -2292,67 +2224,67 @@
 	    if (((testtag->contents != SGML_LITTERAL &&
 		  (testtag->flags & Tgf_strict)) ||
 		 (context->state == S_pcdata &&
-		  (testtag->flags & (Tgf_strict|Tgf_endO)))) &&
+		  (testtag->flags & (Tgf_strict | Tgf_endO)))) &&
 		(testlast > -1 &&
 		 (c == '>' || testlast > 0 || IsNmStart(c)))) {
 		context->state = S_end;
 		string->size--;
-		for (i = 0; i < string->size; i++)  /* remove '/' */
-		    string->data[i] = string->data[i+1];
+		for (i = 0; i < string->size; i++)	/* remove '/' */
+		    string->data[i] = string->data[i + 1];
 		if ((string->size == 1) ? IsNmStart(c) : IsNmChar(c))
 		    break;
 		string->size--;
 		goto top1;
 	    }
 	    if (context->state == S_pcdata &&
-		(testtag->flags & (Tgf_strict|Tgf_endO)) &&
+		(testtag->flags & (Tgf_strict | Tgf_endO)) &&
 		(testlast < 0 && IsNmStart(c))) {
 		context->state = S_tag;
 		break;
 	    }
 	    /*
-	    **	If Mismatch: recover string literally.
-	    */
+	     * If Mismatch:  recover string literally.
+	     */
 	    PUTC('<');
-	    for (i = 0; i < string->size-1; i++)  /* recover, except last c */
-	       PUTC(string->data[i]);
+	    for (i = 0; i < string->size - 1; i++)	/* recover, except last c */
+		PUTC(string->data[i]);
 	    string->size = 0;
 	    context->state = S_text;
 	    goto top1;		/* to recover last c */
 	}
 	break;
 
-    /*
-    **	Character reference (numeric entity) or named entity.
-    */
+	/*
+	 * Character reference (numeric entity) or named entity.
+	 */
     case S_ero:
 	if (c == '#') {
 	    /*
-	    **	Setting up for possible numeric entity.
-	    */
-	    context->state = S_cro;  /* &# is Char Ref Open */
+	     * Setting up for possible numeric entity.
+	     */
+	    context->state = S_cro;	/* &# is Char Ref Open */
 	    break;
 	}
-	context->state = S_entity;   /* Fall through! */
+	context->state = S_entity;	/* Fall through! */
 
-    /*
-    **	Handle possible named entity.
-    */
+	/*
+	 * Handle possible named entity.
+	 */
     case S_entity:
 	if (TOASCII(unsign_c) < 127 && (string->size ?	/* S/390 -- gil -- 1029 */
-		  isalnum(UCH(c)) : isalpha(UCH(c)))) {
+					isalnum(UCH(c)) : isalpha(UCH(c)))) {
 	    /* Should probably use IsNmStart/IsNmChar above (is that right?),
 	       but the world is not ready for that - there's &nbsp: (note
 	       colon!) and stuff around. */
 	    /*
-	    **	Accept valid ASCII character. - FM
-	    */
+	     * Accept valid ASCII character.  - FM
+	     */
 	    HTChunkPutc(string, c);
 	} else if (string->size == 0) {
 	    /*
-	    **	It was an ampersand that's just text, so output
-	    **	the ampersand and recycle this character. - FM
-	    */
+	     * It was an ampersand that's just text, so output the ampersand
+	     * and recycle this character.  - FM
+	     */
 #ifdef USE_PRETTYSRC
 	    if (psrc_view)
 		PSRCSTART(badseq);
@@ -2366,8 +2298,8 @@
 	    goto top1;
 	} else {
 	    /*
-	    **	Terminate entity name and try to handle it. - FM
-	    */
+	     * Terminate entity name and try to handle it.  - FM
+	     */
 	    HTChunkTerminate(string);
 #ifdef USE_PRETTYSRC
 	    entity_string = string->data;
@@ -2376,14 +2308,15 @@
 	    /* CTRACE((tfp, "%s: %d: %s\n", __FILE__, __LINE__, string->data)); */
 	    if (!strcmp(string->data, "zwnj") &&
 		(!context->element_stack ||
-		 (context->element_stack->tag  &&
+		 (context->element_stack->tag &&
 		  context->element_stack->tag->contents == SGML_MIXED))) {
 		/*
-		**  Handle zwnj (8204) as <WBR>. - FM
-		*/
+		 * Handle zwnj (8204) as <WBR>.  - FM
+		 */
 		char temp[8];
 
-		CTRACE((tfp, "SGML_character: Handling 'zwnj' entity as 'WBR' element.\n"));
+		CTRACE((tfp,
+			"SGML_character: Handling 'zwnj' entity as 'WBR' element.\n"));
 
 		if (c != ';') {
 		    sprintf(temp, "<WBR>%c", c);
@@ -2405,11 +2338,10 @@
 	    string->size = 0;
 	    context->state = S_text;
 	    /*
-	    **	Don't eat the terminator if we didn't find the
-	    **	entity name and therefore sent the raw string
-	    **	via handle_entity(), or if the terminator is
-	    **	not the "standard" semi-colon for HTML. - FM
-	    */
+	     * Don't eat the terminator if we didn't find the entity name and
+	     * therefore sent the raw string via handle_entity(), or if the
+	     * terminator is not the "standard" semi-colon for HTML.  - FM
+	     */
 #ifdef USE_PRETTYSRC
 	    if (psrc_view && FoundEntity && c == ';') {
 		PSRCSTART(entity);
@@ -2422,25 +2354,25 @@
 	}
 	break;
 
-    /*
-    **	Check for a numeric entity.
-    */
+	/*
+	 * Check for a numeric entity.
+	 */
     case S_cro:
-	if (TOASCII(unsign_c) < 127 && TOLOWER(UCH(c)) == 'x') {  /* S/390 -- gil -- 1060 */
+	if (TOASCII(unsign_c) < 127 && TOLOWER(UCH(c)) == 'x') {	/* S/390 -- gil -- 1060 */
 	    context->isHex = TRUE;
 	    context->state = S_incro;
 	} else if (TOASCII(unsign_c) < 127 && isdigit(UCH(c))) {
 	    /*
-	    **	Accept only valid ASCII digits. - FM
-	    */
+	     * Accept only valid ASCII digits.  - FM
+	     */
 	    HTChunkPutc(string, c);	/* accumulate a character NUMBER */
 	    context->isHex = FALSE;
 	    context->state = S_incro;
 	} else if (string->size == 0) {
 	    /*
-	    **	No 'x' or digit following the "&#" so recover
-	    **	them and recycle the character. - FM
-	    */
+	     * No 'x' or digit following the "&#" so recover them and recycle
+	     * the character.  - FM
+	     */
 #ifdef USE_PRETTYSRC
 	    if (psrc_view)
 		PSRCSTART(badseq);
@@ -2456,24 +2388,24 @@
 	}
 	break;
 
-    /*
-    **	Handle a numeric entity.
-    */
+	/*
+	 * Handle a numeric entity.
+	 */
     case S_incro:
-	/* S/390 -- gil -- 1075 */ /* CTRACE((tfp, "%s: %d: numeric %d %d\n",
-			    __FILE__, __LINE__, unsign_c, c)); */
+/* S/390 -- gil -- 1075 *//* CTRACE((tfp, "%s: %d: numeric %d %d\n",
+   __FILE__, __LINE__, unsign_c, c)); */
 	if ((TOASCII(unsign_c) < 127) &&
 	    (context->isHex ? isxdigit(UCH(c)) :
-			      isdigit(UCH(c)))) {
+	     isdigit(UCH(c)))) {
 	    /*
-	    **	Accept only valid hex or ASCII digits. - FM
-	    */
+	     * Accept only valid hex or ASCII digits.  - FM
+	     */
 	    HTChunkPutc(string, c);	/* accumulate a character NUMBER */
 	} else if (string->size == 0) {
 	    /*
-	    **	No hex digit following the "&#x" so recover
-	    **	them and recycle the character. - FM
-	    */
+	     * No hex digit following the "&#x" so recover them and recycle the
+	     * character.  - FM
+	     */
 #ifdef USE_PRETTYSRC
 	    if (psrc_view)
 		PSRCSTART(badseq);
@@ -2488,179 +2420,178 @@
 	    goto top1;
 	} else {
 	    /*
-	    **	Terminate the numeric entity and try to handle it. - FM
-	    */
+	     * Terminate the numeric entity and try to handle it.  - FM
+	     */
 	    UCode_t code;
 	    int i;
+
 	    HTChunkTerminate(string);
 #ifdef USE_PRETTYSRC
 	    entity_string = string->data;
 #endif
 	    if ((context->isHex ? sscanf(string->data, "%lx", &code) :
-				  sscanf(string->data, "%ld", &code)) == 1) {
+		 sscanf(string->data, "%ld", &code)) == 1) {
 /* =============== work in ASCII below here ===============  S/390 -- gil -- 1092 */
 		if ((code == 1) ||
 		    (code > 127 && code < 156)) {
 		    /*
-		    **	Assume these are Microsoft code points,
-		    **	inflicted on us by FrontPage. - FM
-		    **
-		    **	MS FrontPage uses syntax like &#153; in 128-159 range
-		    **	and doesn't follow Unicode standards for this area.
-		    **	Windows-1252 codepoints are assumed here.
-		    */
+		     * Assume these are Microsoft code points, inflicted on us
+		     * by FrontPage.  - FM
+		     *
+		     * MS FrontPage uses syntax like &#153; in 128-159 range
+		     * and doesn't follow Unicode standards for this area. 
+		     * Windows-1252 codepoints are assumed here.
+		     */
 		    switch (code) {
-			case 1:
-			    /*
-			    **	WHITE SMILING FACE
-			    */
-			    code = 0x263a;
-			    break;
-			case 128:
-			    /*
-			    **	EURO currency sign
-			    */
-			    code = 0x20ac;
-			    break;
-			case 130:
-			    /*
-			    **	SINGLE LOW-9 QUOTATION MARK (sbquo)
-			    */
-			    code = 0x201a;
-			    break;
-			case 132:
-			    /*
-			    **	DOUBLE LOW-9 QUOTATION MARK (bdquo)
-			    */
-			    code = 0x201e;
-			    break;
-			case 133:
-			    /*
-			    **	HORIZONTAL ELLIPSIS (hellip)
-			    */
-			    code = 0x2026;
-			    break;
-			case 134:
-			    /*
-			    **	DAGGER (dagger)
-			    */
-			    code = 0x2020;
-			    break;
-			case 135:
-			    /*
-			    **	DOUBLE DAGGER (Dagger)
-			    */
-			    code = 0x2021;
-			    break;
-			case 137:
-			    /*
-			    **	PER MILLE SIGN (permil)
-			    */
-			    code = 0x2030;
-			    break;
-			case 139:
-			    /*
-			    **	SINGLE LEFT-POINTING ANGLE QUOTATION MARK
-			    **	(lsaquo)
-			    */
-			    code = 0x2039;
-			    break;
-			case 145:
-			    /*
-			    **	LEFT SINGLE QUOTATION MARK (lsquo)
-			    */
-			    code = 0x2018;
-			    break;
-			case 146:
-			    /*
-			    **	RIGHT SINGLE QUOTATION MARK (rsquo)
-			    */
-			    code = 0x2019;
-			    break;
-			case 147:
-			    /*
-			    **	LEFT DOUBLE QUOTATION MARK (ldquo)
-			    */
-			    code = 0x201c;
-			    break;
-			case 148:
-			    /*
-			    **	RIGHT DOUBLE QUOTATION MARK (rdquo)
-			    */
-			    code = 0x201d;
-			    break;
-			case 149:
-			    /*
-			    **	BULLET (bull)
-			    */
-			    code = 0x2022;
-			    break;
-			case 150:
-			    /*
-			    **	EN DASH (ndash)
-			    */
-			    code = 0x2013;
-			    break;
-			case 151:
-			    /*
-			    **	EM DASH (mdash)
-			    */
-			    code = 0x2014;
-			    break;
-			case 152:
-			    /*
-			    **	SMALL TILDE (tilde)
-			    */
-			    code = 0x02dc;
-			    break;
-			case 153:
-			    /*
-			    **	TRADE MARK SIGN (trade)
-			    */
-			    code = 0x2122;
-			    break;
-			case 155:
-			    /*
-			    **	SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
-			    **	(rsaquo)
-			    */
-			    code = 0x203a;
-			    break;
-			default:
-			    /*
-			    **	Do not attempt a conversion
-			    **	to valid Unicode values.
-			    */
-			    break;
+		    case 1:
+			/*
+			 * WHITE SMILING FACE
+			 */
+			code = 0x263a;
+			break;
+		    case 128:
+			/*
+			 * EURO currency sign
+			 */
+			code = 0x20ac;
+			break;
+		    case 130:
+			/*
+			 * SINGLE LOW-9 QUOTATION MARK (sbquo)
+			 */
+			code = 0x201a;
+			break;
+		    case 132:
+			/*
+			 * DOUBLE LOW-9 QUOTATION MARK (bdquo)
+			 */
+			code = 0x201e;
+			break;
+		    case 133:
+			/*
+			 * HORIZONTAL ELLIPSIS (hellip)
+			 */
+			code = 0x2026;
+			break;
+		    case 134:
+			/*
+			 * DAGGER (dagger)
+			 */
+			code = 0x2020;
+			break;
+		    case 135:
+			/*
+			 * DOUBLE DAGGER (Dagger)
+			 */
+			code = 0x2021;
+			break;
+		    case 137:
+			/*
+			 * PER MILLE SIGN (permil)
+			 */
+			code = 0x2030;
+			break;
+		    case 139:
+			/*
+			 * SINGLE LEFT-POINTING ANGLE QUOTATION MARK (lsaquo)
+			 */
+			code = 0x2039;
+			break;
+		    case 145:
+			/*
+			 * LEFT SINGLE QUOTATION MARK (lsquo)
+			 */
+			code = 0x2018;
+			break;
+		    case 146:
+			/*
+			 * RIGHT SINGLE QUOTATION MARK (rsquo)
+			 */
+			code = 0x2019;
+			break;
+		    case 147:
+			/*
+			 * LEFT DOUBLE QUOTATION MARK (ldquo)
+			 */
+			code = 0x201c;
+			break;
+		    case 148:
+			/*
+			 * RIGHT DOUBLE QUOTATION MARK (rdquo)
+			 */
+			code = 0x201d;
+			break;
+		    case 149:
+			/*
+			 * BULLET (bull)
+			 */
+			code = 0x2022;
+			break;
+		    case 150:
+			/*
+			 * EN DASH (ndash)
+			 */
+			code = 0x2013;
+			break;
+		    case 151:
+			/*
+			 * EM DASH (mdash)
+			 */
+			code = 0x2014;
+			break;
+		    case 152:
+			/*
+			 * SMALL TILDE (tilde)
+			 */
+			code = 0x02dc;
+			break;
+		    case 153:
+			/*
+			 * TRADE MARK SIGN (trade)
+			 */
+			code = 0x2122;
+			break;
+		    case 155:
+			/*
+			 * SINGLE RIGHT-POINTING ANGLE QUOTATION MARK (rsaquo)
+			 */
+			code = 0x203a;
+			break;
+		    default:
+			/*
+			 * Do not attempt a conversion to valid Unicode values.
+			 */
+			break;
 		    }
 		}
 		/*
-		**  Check for special values. - FM
-		*/
+		 * Check for special values.  - FM
+		 */
 		if ((code == 8204) &&
 		    (!context->element_stack ||
-		     (context->element_stack->tag  &&
+		     (context->element_stack->tag &&
 		      context->element_stack->tag->contents == SGML_MIXED))) {
 		    /*
-		    **	Handle zwnj (8204) as <WBR>. - FM
-		    */
+		     * Handle zwnj (8204) as <WBR>.  - FM
+		     */
 		    char temp[8];
 
-		    CTRACE((tfp, "SGML_character: Handling '8204' (zwnj) reference as 'WBR' element.\n"));
+		    CTRACE((tfp,
+			    "SGML_character: Handling '8204' (zwnj) reference as 'WBR' element.\n"));
 
 		    /*
-		    **	Include the terminator if it is not
-		    **	the standard semi-colon. - FM
-		    */
+		     * Include the terminator if it is not the standard
+		     * semi-colon.  - FM
+		     */
 		    if (c != ';') {
 			sprintf(temp, "<WBR>%c", c);
 		    } else {
 			sprintf(temp, "<WBR>");
 		    }
 		    /*
-		    **	Add the replacement string to the
-		    **	recover buffer for processing. - FM
-		    */
+		     * Add the replacement string to the recover buffer for
+		     * processing.  - FM
+		     */
 		    if (context->recover == NULL) {
 			StrAllocCopy(context->recover, temp);
 			context->recover_index = 0;
@@ -2673,13 +2604,13 @@
 		    break;
 		} else if (put_special_unicodes(context, code)) {
 		    /*
-		    **	We handled the value as a special character,
-		    **	so recycle the terminator or break. - FM
-		    */
+		     * We handled the value as a special character, so recycle
+		     * the terminator or break.  - FM
+		     */
 #ifdef USE_PRETTYSRC
 		    if (psrc_view) {
 			PSRCSTART(entity);
-			PUTS( (context->isHex ? "&#x" : "&#") );
+			PUTS((context->isHex ? "&#x" : "&#"));
 			PUTS(entity_string);
 			if (c == ';')
 			    PUTC(';');
@@ -2694,8 +2625,8 @@
 		    break;
 		}
 		/*
-		**  Seek a translation from the chartrans tables.
-		*/
+		 * Seek a translation from the chartrans tables.
+		 */
 		if ((uck = UCTransUniChar(code,
 					  context->outUCLYhndl)) >= 32 &&
 		    uck < 256 &&
@@ -2704,7 +2635,7 @@
 #ifdef USE_PRETTYSRC
 		    if (!psrc_view) {
 #endif
-		    PUTC(FROMASCII((char)uck));
+			PUTC(FROMASCII((char) uck));
 #ifdef USE_PRETTYSRC
 		    } else {
 			put_pretty_number(context);
@@ -2713,9 +2644,9 @@
 		} else if ((uck == -4 ||
 			    (context->T.repl_translated_C0 &&
 			     uck > 0 && uck < 32)) &&
-			   /*
-			   **  Not found; look for replacement string.
-			   */
+		    /*
+		     * Not found; look for replacement string.
+		     */
 			   (uck = UCTransUniCharStr(replace_buf, 60, code,
 						    context->outUCLYhndl,
 						    0) >= 0)) {
@@ -2724,16 +2655,16 @@
 			put_pretty_number(context);
 		    } else
 #endif
-		    PUTS(replace_buf);
-		/*
-		**  If we're displaying UTF-8, try that now. - FM
-		*/
+			PUTS(replace_buf);
+		    /*
+		     * If we're displaying UTF-8, try that now.  - FM
+		     */
 		} else if (context->T.output_utf8 && PUTUTF8(code)) {
-		    ;  /* do nothing more */
-		/*
-		**  Ignore 8205 (zwj),
-		**  8206 (lrm), and 8207 (rln), if we get to here. - FM
-		*/
+		    ;		/* do nothing more */
+		    /*
+		     * Ignore 8205 (zwj), 8206 (lrm), and 8207 (rln), if we get
+		     * to here.  - FM
+		     */
 		} else if (code == 8205 ||
 			   code == 8206 ||
 			   code == 8207) {
@@ -2750,7 +2681,7 @@
 #ifdef USE_PRETTYSRC
 		    if (psrc_view) {
 			PSRCSTART(badseq);
-			PUTS( (context->isHex ? "&#x" : "&#") );
+			PUTS((context->isHex ? "&#x" : "&#"));
 			PUTS(entity_string);
 			if (c == ';')
 			    PUTC(';');
@@ -2763,71 +2694,69 @@
 		    if (c != ';')
 			goto top1;
 		    break;
-		/*
-		**  Show the numeric entity if we get to here
-		**  and the value:
-		**   (1) Is greater than 255 (but use ASCII characters
-		**	 for spaces or dashes).
-		**   (2) Is less than 32, and not valid or we don't
-		**	 have HTCJK set.
-		**   (3) Is 127 and we don't have HTPassHighCtrlRaw or
-		**	 HTCJK set.
-		**   (4) Is 128 - 159 and we don't have HTPassHighCtrlNum
-		**	 set.
-		**  - FM
-		*/
+		    /*
+		     * Show the numeric entity if we get to here and the value:
+		     * (1) Is greater than 255 (but use ASCII characters for
+		     * spaces or dashes).
+		     * (2) Is less than 32, and not valid or we don't have
+		     * HTCJK set.
+		     * (3) Is 127 and we don't have HTPassHighCtrlRaw or HTCJK
+		     * set.
+		     * (4) Is 128 - 159 and we don't have HTPassHighCtrlNum
+		     * set.
+		     * - FM
+		     */
 		} else if ((code > 255) ||
-			   (code < ' ' &&  /* S/390 -- gil -- 1140 */
+			   (code < ' ' &&	/* S/390 -- gil -- 1140 */
 			    code != '\t' && code != '\n' && code != '\r' &&
 			    HTCJK == NOCJK) ||
 			   (TOASCII(code) == 127 &&
 			    !(HTPassHighCtrlRaw || HTCJK != NOCJK)) ||
 			   (TOASCII(code) > 127 && code < 160 &&
 			    !HTPassHighCtrlNum)) {
-			/*
-			**  Unhandled or illegal value.	 Recover the
-			**  "&#" or "&#x" and digit(s), and recycle
-			**  the terminator. - FM
-			*/
+		    /*
+		     * Unhandled or illegal value.  Recover the "&#" or "&#x"
+		     * and digit(s), and recycle the terminator.  - FM
+		     */
 #ifdef USE_PRETTYSRC
-			if (psrc_view) {
-			    PSRCSTART(badseq);
-			}
+		    if (psrc_view) {
+			PSRCSTART(badseq);
+		    }
 #endif
-			if (context->isHex) {
-			    PUTS("&#x");
-			    context->isHex = FALSE;
-			} else {
-			    PUTS("&#");
-			}
-			string->size--;
-			for (i = 0; i < string->size; i++)	/* recover */
-			    PUTC(string->data[i]);
+		    if (context->isHex) {
+			PUTS("&#x");
+			context->isHex = FALSE;
+		    } else {
+			PUTS("&#");
+		    }
+		    string->size--;
+		    for (i = 0; i < string->size; i++)	/* recover */
+			PUTC(string->data[i]);
 #ifdef USE_PRETTYSRC
-			if (psrc_view) {
-			    PSRCSTOP(badseq);
-			}
+		    if (psrc_view) {
+			PSRCSTOP(badseq);
+		    }
 #endif
-			string->size = 0;
-			context->isHex = FALSE;
-			context->state = S_text;
-			goto top1;
-		} else if (TOASCII(code) < 161 ||  /* S/390 -- gil -- 1162 */
+		    string->size = 0;
+		    context->isHex = FALSE;
+		    context->state = S_text;
+		    goto top1;
+		} else if (TOASCII(code) < 161 ||	/* S/390 -- gil -- 1162 */
 			   HTPassEightBitNum ||
 			   IncludesLatin1Enc) {
 		    /*
-		    **	No conversion needed. - FM
-		    */
+		     * No conversion needed.  - FM
+		     */
 #ifdef USE_PRETTYSRC
 		    if (psrc_view) {
 			put_pretty_number(context);
 		    } else
 #endif
-		    PUTC(FROMASCII((char)code));
+			PUTC(FROMASCII((char) code));
 		} else {
 		    /*
-		    **	Handle as named entity. - FM
-		    */
+		     * Handle as named entity.  - FM
+		     */
 		    code -= 160;
 		    EntityName = HTMLGetEntityName(code);
 		    if (EntityName && EntityName[0] != '\0') {
@@ -2836,17 +2765,17 @@
 			HTChunkTerminate(string);
 			handle_entity(context, '\0');
 			/*
-			**  Add a semi-colon if something went wrong
-			**  and handle_entity() sent the string. - FM
-			*/
+			 * Add a semi-colon if something went wrong and
+			 * handle_entity() sent the string.  - FM
+			 */
 			if (!FoundEntity) {
 			    PUTC(';');
 			}
 		    } else {
 			/*
-			**  Our conversion failed, so recover the "&#"
-			**  and digit(s), and recycle the terminator. - FM
-			*/
+			 * Our conversion failed, so recover the "&#" and
+			 * digit(s), and recycle the terminator.  - FM
+			 */
 #ifdef USE_PRETTYSRC
 			if (psrc_view)
 			    PSRCSTART(badseq);
@@ -2871,25 +2800,24 @@
 		    }
 		}
 		/*
-		**  If we get to here, we succeeded.  Hoorah!!! - FM
-		*/
+		 * If we get to here, we succeeded.  Hoorah!!!  - FM
+		 */
 		string->size = 0;
 		context->isHex = FALSE;
 		context->state = S_text;
 		/*
-		**  Don't eat the terminator if it's not
-		**  the "standard" semi-colon for HTML. - FM
-		*/
+		 * Don't eat the terminator if it's not the "standard"
+		 * semi-colon for HTML.  - FM
+		 */
 		if (c != ';') {
 		    goto top1;
 		}
 	    } else {
 		/*
-		**  Not an entity, and don't know why not, so add
-		**  the terminator to the string, output the "&#"
-		**  or "&#x", and process the string via the recover
-		**  element. - FM
-		*/
+		 * Not an entity, and don't know why not, so add the terminator
+		 * to the string, output the "&#" or "&#x", and process the
+		 * string via the recover element.  - FM
+		 */
 		string->size--;
 		HTChunkPutc(string, c);
 		HTChunkTerminate(string);
@@ -2921,21 +2849,21 @@
 	}
 	break;
 
-    /*
-    **	Tag
-    */
-    case S_tag:					/* new tag */
+	/*
+	 * Tag
+	 */
+    case S_tag:		/* new tag */
 	if (TOASCII(unsign_c) < 127 && (string->size ?	/* S/390 -- gil -- 1179 */
-		  IsNmChar(c) : IsNmStart(c))) {
+					IsNmChar(c) : IsNmStart(c))) {
 	    /*
-	    **	Add valid ASCII character. - FM
-	    */
+	     * Add valid ASCII character.  - FM
+	     */
 	    HTChunkPutc(string, c);
-	} else if (c == '!' && !string->size) { /* <! */
+	} else if (c == '!' && !string->size) {		/* <! */
 	    /*
-	    **	Terminate and set up for possible comment,
-	    **	identifier, declaration, or marked section. - FM
-	    */
+	     * Terminate and set up for possible comment, identifier,
+	     * declaration, or marked section.  - FM
+	     */
 	    context->state = S_exclamation;
 	    context->lead_exclamation = TRUE;
 	    context->doctype_bracket = FALSE;
@@ -2943,16 +2871,16 @@
 	    HTChunkPutc(string, c);
 	    break;
 	} else if (!string->size &&
-		   (TOASCII(unsign_c) <= 160 &&	 /* S/390 -- gil -- 1196 */
+		   (TOASCII(unsign_c) <= 160 &&		/* S/390 -- gil -- 1196 */
 		    (c != '/' && c != '?' && c != '_' && c != ':'))) {
 	    /*
-	    **	'<' must be followed by an ASCII letter to be a valid
-	    **	start tag.  Here it isn't, nor do we have a '/' for an
-	    **	end tag, nor one of some other characters with a
-	    **	special meaning for SGML or which are likely to be legal
-	    **	Name Start characters in XML or some other extension.
-	    **	So recover the '<' and following character as data. - FM & KW
-	    */
+	     * '<' must be followed by an ASCII letter to be a valid start tag. 
+	     * Here it isn't, nor do we have a '/' for an end tag, nor one of
+	     * some other characters with a special meaning for SGML or which
+	     * are likely to be legal Name Start characters in XML or some
+	     * other extension.  So recover the '<' and following character as
+	     * data.  - FM & KW
+	     */
 	    context->state = S_text;
 #ifdef USE_PRETTYSRC
 	    if (psrc_view)
@@ -2964,19 +2892,20 @@
 		PSRCSTOP(badseq);
 #endif
 	    goto top1;
-	} else {				/* End of tag name */
+	} else {		/* End of tag name */
 	    /*
-	    **	Try to handle tag. - FM
-	    */
-	    HTTag * t;
+	     * Try to handle tag.  - FM
+	     */
+	    HTTag *t;
+
 	    if (c == '/') {
 		if (string->size == 0) {
 		    context->state = S_end;
 		    break;
 		}
-		CTRACE((tfp,"SGML: `<%.*s/' found!\n", string->size, string->data));
+		CTRACE((tfp, "SGML: `<%.*s/' found!\n", string->size, string->data));
 	    }
-	    HTChunkTerminate(string) ;
+	    HTChunkTerminate(string);
 
 	    t = SGMLFindTag(dtd, string->data);
 	    if (t == context->unknown_tag &&
@@ -2984,32 +2913,32 @@
 		  string->size == 4 && 0 == strcasecomp(string->data, "URL")) ||
 		 (string->size > 4 && 0 == strncasecomp(string->data, "URL:", 4)))) {
 		/*
-		**  Treat <URL: as text rather than a junk tag,
-		**  so we display it and the URL (Lynxism 8-). - FM
-		*/
+		 * Treat <URL:  as text rather than a junk tag, so we display
+		 * it and the URL (Lynxism 8-).  - FM
+		 */
 #ifdef USE_PRETTYSRC
 		if (psrc_view)
 		    PSRCSTART(badseq);
 #endif
 		PUTC('<');
-		PUTS(string->data); /* recover */
+		PUTS(string->data);	/* recover */
 		PUTC(c);
 #ifdef USE_PRETTYSRC
 		if (psrc_view)
 		    PSRCSTOP(badseq);
 #endif
 		CTRACE((tfp, "SGML: Treating <%s%c as text\n",
-			    string->data, c));
+			string->data, c));
 		string->size = 0;
 		context->state = S_text;
 		break;
 	    }
 	    if (c == '/' && t) {
 		/*
-		 *  Element name was ended by '/'.  Remember the tag that
-		 *  ended thusly, we'll interpret this as either an indication
-		 *  of an empty element (if '>' follows directly) or do
-		 *  some SGMLshortref-ish treatment. - kw
+		 * Element name was ended by '/'.  Remember the tag that ended
+		 * thusly, we'll interpret this as either an indication of an
+		 * empty element (if '>' follows directly) or do some
+		 * SGMLshortref-ish treatment.  - kw
 		 */
 		context->slashedtag = t;
 	    }
@@ -3021,14 +2950,14 @@
 			PSRCSTART(abracket);
 			PUTS("<?");
 			PSRCSTOP(abracket);
-			context->seen_nonwhite_in_junk_tag = TRUE; /*show all*/
+			context->seen_nonwhite_in_junk_tag = TRUE;	/*show all */
 		    }
 #endif
 		    context->state = S_junk_pi;
 		    break;
 		}
 		CTRACE((tfp, "SGML: *** Invalid element %s\n",
-			    string->data));
+			string->data));
 
 #ifdef USE_PRETTYSRC
 		if (psrc_view) {
@@ -3043,7 +2972,7 @@
 			    LYUpperCase(string->data);
 		    }
 		    PUTS(string->data);
-		    if (c == '>' ) {
+		    if (c == '>') {
 			PSRCSTOP(badtag);
 			PSRCSTART(abracket);
 			PUTC('>');
@@ -3057,11 +2986,11 @@
 		break;
 	    } else if (t == context->unknown_tag) {
 		CTRACE((tfp, "SGML: *** Unknown element %s\n",
-			    string->data));
+			string->data));
 		/*
-		**  Fall through and treat like valid
-		**  tag for attribute parsing. - KW
-		*/
+		 * Fall through and treat like valid tag for attribute parsing. 
+		 * - KW
+		 */
 
 	    }
 	    context->current_tag = t;
@@ -3087,14 +3016,14 @@
 		else
 		    PSRCSTOP(badtag);
 	    }
-	    if (!psrc_view) /*don't waste time */
+	    if (!psrc_view)	/*don't waste time */
 #endif
 	    {
-	    /*
-	    **	Clear out attributes.
-	    */
-		memset( (void*)context->present, 0 , sizeof(BOOL)*
-				context->current_tag->number_of_attributes);
+		/*
+		 * Clear out attributes.
+		 */
+		memset((void *) context->present, 0, sizeof(BOOL) *
+		       context->current_tag->number_of_attributes);
 	    }
 
 	    string->size = 0;
@@ -3131,8 +3060,8 @@
     case S_exclamation:
 	if (context->lead_exclamation && c == '-') {
 	    /*
-	    **	Set up for possible comment. - FM
-	    */
+	     * Set up for possible comment.  - FM
+	     */
 	    context->lead_exclamation = FALSE;
 	    context->first_dash = TRUE;
 	    HTChunkPutc(string, c);
@@ -3140,8 +3069,8 @@
 	}
 	if (context->lead_exclamation && c == '[') {
 	    /*
-	    **	Set up for possible marked section. - FM
-	    */
+	     * Set up for possible marked section.  - FM
+	     */
 	    context->lead_exclamation = FALSE;
 	    context->first_bracket = TRUE;
 	    context->second_bracket = FALSE;
@@ -3151,8 +3080,8 @@
 	}
 	if (context->first_dash && c == '-') {
 	    /*
-	    **	Set up to handle comment. - FM
-	    */
+	     * Set up to handle comment.  - FM
+	     */
 	    context->lead_exclamation = FALSE;
 	    context->first_dash = FALSE;
 	    context->end_comment = FALSE;
@@ -3164,8 +3093,8 @@
 	context->first_dash = FALSE;
 	if (c == '>') {
 	    /*
-	    **	Try to handle identifier. - FM
-	    */
+	     * Try to handle identifier.  - FM
+	     */
 	    HTChunkTerminate(string);
 #ifdef USE_PRETTYSRC
 	    if (psrc_view) {
@@ -3176,7 +3105,7 @@
 		PSRCSTOP(sgmlspecial);
 	    } else
 #endif
-	    handle_identifier(context);
+		handle_identifier(context);
 	    string->size = 0;
 	    context->state = S_text;
 	    break;
@@ -3185,8 +3114,8 @@
 	    if (string->size == 8 &&
 		!strncasecomp(string->data, "!DOCTYPE", 8)) {
 		/*
-		**  Set up for DOCTYPE declaration. - FM
-		*/
+		 * Set up for DOCTYPE declaration.  - FM
+		 */
 		HTChunkPutc(string, c);
 		context->doctype_bracket = FALSE;
 		context->state = S_doctype;
@@ -3195,8 +3124,8 @@
 	    if (string->size == 7 &&
 		!strncasecomp(string->data, "!ENTITY", 7)) {
 		/*
-		**  Set up for ENTITY declaration. - FM
-		*/
+		 * Set up for ENTITY declaration.  - FM
+		 */
 		HTChunkPutc(string, c);
 		context->first_dash = FALSE;
 		context->end_comment = TRUE;
@@ -3206,8 +3135,8 @@
 	    if (string->size == 8 &&
 		!strncasecomp(string->data, "!ELEMENT", 8)) {
 		/*
-		**  Set up for ELEMENT declaration. - FM
-		*/
+		 * Set up for ELEMENT declaration.  - FM
+		 */
 		HTChunkPutc(string, c);
 		context->first_dash = FALSE;
 		context->end_comment = TRUE;
@@ -3217,8 +3146,8 @@
 	    if (string->size == 8 &&
 		!strncasecomp(string->data, "!ATTLIST", 8)) {
 		/*
-		**  Set up for ATTLIST declaration. - FM
-		*/
+		 * Set up for ATTLIST declaration.  - FM
+		 */
 		HTChunkPutc(string, c);
 		context->first_dash = FALSE;
 		context->end_comment = TRUE;
@@ -3232,8 +3161,8 @@
     case S_comment:		/* Expecting comment. - FM */
 	if (historical_comments) {
 	    /*
-	    **	Any '>' terminates. - FM
-	    */
+	     * Any '>' terminates.  - FM
+	     */
 	    if (c == '>') {
 		HTChunkTerminate(string);
 #ifdef USE_PRETTYSRC
@@ -3245,7 +3174,7 @@
 		    PSRCSTOP(comm);
 		} else
 #endif
-		handle_comment(context);
+		    handle_comment(context);
 		string->size = 0;
 		context->end_comment = FALSE;
 		context->first_dash = FALSE;
@@ -3266,16 +3195,16 @@
 		context->end_comment = TRUE;
 	    else if (!minimal_comments)
 		/*
-		**  Validly treat '--' pairs as successive comments
-		**  (for minimal, any "--WHITE>" terminates). - FM
-		*/
+		 * Validly treat '--' pairs as successive comments (for
+		 * minimal, any "--WHITE>" terminates).  - FM
+		 */
 		context->end_comment = FALSE;
 	    break;
 	}
 	if (context->end_comment && c == '>') {
 	    /*
-	    **	Terminate and handle the comment. - FM
-	    */
+	     * Terminate and handle the comment.  - FM
+	     */
 	    HTChunkTerminate(string);
 #ifdef USE_PRETTYSRC
 	    if (psrc_view) {
@@ -3297,9 +3226,9 @@
 	if (context->end_comment && !isspace(UCH(c)))
 	    context->end_comment = FALSE;
 
-    S_comment_put_c:
+      S_comment_put_c:
 	if (context->T.decode_utf8 &&
-		   *context->utf_buf) {
+	    *context->utf_buf) {
 	    HTChunkPuts(string, context->utf_buf);
 	    context->utf_buf_p = context->utf_buf;
 	    *(context->utf_buf_p) = '\0';
@@ -3345,7 +3274,7 @@
 		PSRCSTOP(sgmlspecial);
 	    } else
 #endif
-	    handle_doctype(context);
+		handle_doctype(context);
 	    string->size = 0;
 	    context->state = S_text;
 	    break;
@@ -3377,7 +3306,7 @@
 		PSRCSTOP(sgmlspecial);
 	    } else
 #endif
-	    handle_marked(context);
+		handle_marked(context);
 	    string->size = 0;
 	    context->state = S_text;
 	    break;
@@ -3411,7 +3340,7 @@
 		PSRCSTOP(sgmlspecial);
 	    } else
 #endif
-	    handle_sgmlent(context);
+		handle_sgmlent(context);
 	    string->size = 0;
 	    context->end_comment = FALSE;
 	    context->first_dash = FALSE;
@@ -3448,7 +3377,7 @@
 		PSRCSTOP(sgmlspecial);
 	    } else
 #endif
-	    handle_sgmlele(context);
+		handle_sgmlele(context);
 	    string->size = 0;
 	    context->end_comment = FALSE;
 	    context->first_dash = FALSE;
@@ -3485,7 +3414,7 @@
 		PSRCSTOP(sgmlspecial);
 	    } else
 #endif
-	    handle_sgmlatt(context);
+		handle_sgmlatt(context);
 	    string->size = 0;
 	    context->end_comment = FALSE;
 	    context->first_dash = FALSE;
@@ -3503,8 +3432,8 @@
 #ifdef USE_PRETTYSRC
 	    if (!psrc_view)
 #endif
-	    if (context->current_tag->name)
-		start_element(context);
+		if (context->current_tag->name)
+		    start_element(context);
 #ifdef USE_PRETTYSRC
 	    if (psrc_view) {
 		PSRCSTART(abracket);
@@ -3516,10 +3445,10 @@
 	    break;
 	}
 	HTChunkPutc(string, c);
-	context->state = S_attr; /* Get attribute */
+	context->state = S_attr;	/* Get attribute */
 	break;
 
-				/* accumulating value */
+	/* accumulating value */
     case S_attr:
 	if (WHITE(c) || (c == '>') || (c == '=')) {	/* End of word */
 	    HTChunkTerminate(string);
@@ -3527,13 +3456,13 @@
 #ifdef USE_PRETTYSRC
 	    if (!psrc_view) {
 #endif
-	    string->size = 0;
-	    if (c == '>') {				/* End of tag */
-		if (context->current_tag->name)
-		    start_element(context);
-		context->state = S_text;
-		break;
-	    }
+		string->size = 0;
+		if (c == '>') {	/* End of tag */
+		    if (context->current_tag->name)
+			start_element(context);
+		    context->state = S_text;
+		    break;
+		}
 #ifdef USE_PRETTYSRC
 	    } else {
 		PUTC(' ');
@@ -3548,7 +3477,8 @@
 			LYUpperCase(string->data);
 		}
 		PUTS(string->data);
-		if (c == '=' ) PUTC('=');
+		if (c == '=')
+		    PUTC('=');
 		if (c == '=' || c == '>') {
 		    if (context->current_attribute_number == INVALID)
 			PSRCSTOP(badattr);
@@ -3565,7 +3495,7 @@
 		string->size = 0;
 	    }
 #endif
-	    context->state = (c == '=' ?  S_equals: S_attr_gap);
+	    context->state = (c == '=' ? S_equals : S_attr_gap);
 	} else {
 	    HTChunkPutc(string, c);
 	}
@@ -3606,7 +3536,7 @@
 	    break;
 	}
 	HTChunkPutc(string, c);
-	context->state = S_attr; /* Get next attribute */
+	context->state = S_attr;	/* Get next attribute */
 	break;
 
     case S_equals:		/* After attr = */
@@ -3651,49 +3581,50 @@
 	    PSRCSTART(attrval);
 #endif
 	context->state = S_value;
-	/*  no break!  fall through to S_value and process current `c`	 */
+	/*  no break!  fall through to S_value and process current `c`   */
 
     case S_value:
-	if (WHITE(c) || (c == '>')) {		/* End of word */
-	    HTChunkTerminate(string) ;
+	if (WHITE(c) || (c == '>')) {	/* End of word */
+	    HTChunkTerminate(string);
 #ifdef USE_PRETTYSRC
 	    if (psrc_view) {
-		/*PSRCSTART(attrval);*/
+		/*PSRCSTART(attrval); */
 		if (attr_is_name) {
 		    HTStartAnchor(context->target, string->data, NULL);
-		    (*context->actions->end_element)(
-			context->target,
-			HTML_A,
-			(char **)&context->include);
+		    (*context->actions->end_element) (context->target,
+						      HTML_A,
+						      &context->include);
 		} else if (attr_is_href) {
 		    PSRCSTART(href);
-		    HTStartAnchor(context->target,NULL,string->data);
+		    HTStartAnchor(context->target, NULL, string->data);
 		}
 		PUTS_TR(string->data);
 		if (attr_is_href) {
-		    (*context->actions->end_element)(
-			context->target,
-			HTML_A,
-			(char **)&context->include);
+		    (*context->actions->end_element) (context->target,
+						      HTML_A,
+						      &context->include);
 		    PSRCSTOP(href);
 		}
 		PSRCSTOP(attrval);
 	    } else
 #endif
-#ifdef CJK_EX	/* Quick hack. - JH7AYN */
-	    {   char jis_buf[512];
+#ifdef CJK_EX			/* Quick hack. - JH7AYN */
+	    {
+		char jis_buf[512];
+
 		if (string->data[0] == '$') {
-		  if (string->data[1] == 'B' || string->data[1] == '@') {
-		    jis_buf[0] = '\033';
-		    strcpy(jis_buf + 1, string->data);
-		    TO_EUC((CONST unsigned char *)jis_buf, (unsigned char *)string->data);
-		  }
+		    if (string->data[1] == 'B' || string->data[1] == '@') {
+			jis_buf[0] = '\033';
+			strcpy(jis_buf + 1, string->data);
+			TO_EUC((const unsigned char *) jis_buf,
+			       (unsigned char *) string->data);
+		    }
 		}
 	    }
 #endif
 	    handle_attribute_value(context, string->data);
 	    string->size = 0;
-	    if (c == '>') {		/* End of tag */
+	    if (c == '>') {	/* End of tag */
 #ifdef USE_PRETTYSRC
 		if (psrc_view) {
 		    PSRCSTART(abracket);
@@ -3705,8 +3636,8 @@
 		    start_element(context);
 		context->state = S_text;
 		break;
-	    }
-	    else context->state = S_tag_gap;
+	    } else
+		context->state = S_tag_gap;
 	} else if (context->T.decode_utf8 &&
 		   *context->utf_buf) {
 	    HTChunkPuts(string, context->utf_buf);
@@ -3733,40 +3664,38 @@
 
     case S_squoted:		/* Quoted attribute value */
 	if (c == '\'') {	/* End of attribute value */
-	    HTChunkTerminate(string) ;
+	    HTChunkTerminate(string);
 #ifdef USE_PRETTYSRC
 	    if (psrc_view) {
-		/*PSRCSTART(attrval);*/
+		/*PSRCSTART(attrval); */
 		if (attr_is_name) {
-		    HTStartAnchor(context->target,string->data, NULL);
-		    (*context->actions->end_element)(
-			context->target,
-			HTML_A,
-			(char **)&context->include);
+		    HTStartAnchor(context->target, string->data, NULL);
+		    (*context->actions->end_element) (context->target,
+						      HTML_A,
+						      &context->include);
 		} else if (attr_is_href) {
 		    PSRCSTART(href);
-		    HTStartAnchor(context->target,NULL,string->data);
+		    HTStartAnchor(context->target, NULL, string->data);
 		}
 		PUTS_TR(string->data);
 		if (attr_is_href) {
-		    (*context->actions->end_element)(
-			context->target,
-			HTML_A,
-			(char **)&context->include);
+		    (*context->actions->end_element) (context->target,
+						      HTML_A,
+						      &context->include);
 		    PSRCSTOP(href);
 		}
 		PUTC('\'');
 		PSRCSTOP(attrval);
 	    } else
 #endif
-	    handle_attribute_value(context, string->data);
+		handle_attribute_value(context, string->data);
 	    string->size = 0;
 	    context->state = S_tag_gap;
-	} else if (TOASCII(c) == '\033') {  /* S/390 -- gil -- 1213 */
+	} else if (TOASCII(c) == '\033') {	/* S/390 -- gil -- 1213 */
 	    /*
-	    **	Setting up for possible single quotes in CJK escape
-	    **	sequences. - Takuya ASADA (asada@three-a.co.jp)
-	    */
+	     * Setting up for possible single quotes in CJK escape sequences. 
+	     * - Takuya ASADA (asada@three-a.co.jp)
+	     */
 	    context->state = S_esc_sq;
 	    HTChunkPutc(string, c);
 	} else if (context->T.decode_utf8 &&
@@ -3797,26 +3726,24 @@
 	if (c == '"' ||		/* Valid end of attribute value */
 	    (soft_dquotes &&	/*  If emulating old Netscape bug, treat '>' */
 	     c == '>')) {	/*  as a co-terminator of dquoted and tag    */
-	    HTChunkTerminate(string) ;
+	    HTChunkTerminate(string);
 #ifdef USE_PRETTYSRC
 	    if (psrc_view) {
-		/*PSRCSTART(attrval);*/
+		/*PSRCSTART(attrval); */
 		if (attr_is_name) {
-		    HTStartAnchor(context->target,string->data, NULL);
-		    (*context->actions->end_element)(
-			context->target,
-			HTML_A,
-			(char **)&context->include);
+		    HTStartAnchor(context->target, string->data, NULL);
+		    (*context->actions->end_element) (context->target,
+						      HTML_A,
+						      &context->include);
 		} else if (attr_is_href) {
 		    PSRCSTART(href);
-		    HTStartAnchor(context->target,NULL,string->data);
+		    HTStartAnchor(context->target, NULL, string->data);
 		}
 		PUTS_TR(string->data);
 		if (attr_is_href) {
-		    (*context->actions->end_element)(
-			context->target,
-			HTML_A,
-			(char **)&context->include);
+		    (*context->actions->end_element) (context->target,
+						      HTML_A,
+						      &context->include);
 		    PSRCSTOP(href);
 		}
 		PUTC(c);
@@ -3824,16 +3751,16 @@
 	    } else
 #endif
 
-	    handle_attribute_value(context, string->data);
+		handle_attribute_value(context, string->data);
 	    string->size = 0;
 	    context->state = S_tag_gap;
 	    if (c == '>')	/* We emulated the Netscape bug, so we go  */
 		goto top1;	/* back and treat it as the tag terminator */
-	} else if (TOASCII(c) == '\033') {  /* S/390 -- gil -- 1230 */
+	} else if (TOASCII(c) == '\033') {	/* S/390 -- gil -- 1230 */
 	    /*
-	    **	Setting up for possible double quotes in CJK escape
-	    **	sequences. - Takuya ASADA (asada@three-a.co.jp)
-	    */
+	     * Setting up for possible double quotes in CJK escape sequences. 
+	     * - Takuya ASADA (asada@three-a.co.jp)
+	     */
 	    context->state = S_esc_dq;
 	    HTChunkPutc(string, c);
 	} else if (context->T.decode_utf8 &&
@@ -3860,12 +3787,13 @@
 	}
 	break;
 
-    case S_end:					/* </ */
+    case S_end:		/* </ */
 	if (TOASCII(unsign_c) < 127 && (string->size ?	/* S/390 -- gil -- 1247 */
-		  IsNmChar(c) : IsNmStart(c))) {
+					IsNmChar(c) : IsNmStart(c))) {
 	    HTChunkPutc(string, c);
-	} else {				/* End of end tag name */
-	    HTTag * t = 0;
+	} else {		/* End of end tag name */
+	    HTTag *t = 0;
+
 #ifdef USE_PRETTYSRC
 	    BOOL psrc_tagname_processed = FALSE;
 #endif
@@ -3900,15 +3828,16 @@
 			PUTC('>');
 			PSRCSTOP(abracket);
 		    }
-		    psrc_tagname_processed=TRUE;
+		    psrc_tagname_processed = TRUE;
 		}
 	    } else if (psrc_view) {
 #endif
 	    } else {
 		BOOL tag_OK = (BOOL) (c == '>' || WHITE(c));
+
 #if OPT
 		HTMLElement e = TAGNUM_OF_TAGP(t);
-		int branch = 2; /* it can be 0,1,2*/
+		int branch = 2;	/* it can be 0,1,2 */
 #endif
 		context->current_tag = t;
 		if (HAS_ALT_TAGNUM(TAGNUM_OF_TAGP(t)) &&
@@ -3918,19 +3847,36 @@
 #if OPT
 		if (tag_OK
 #ifdef EXTENDED_HTMLDTD
-		 && Old_DTD
+		    && Old_DTD
 #endif
-		 ) {
-		   switch (e) {
-		     case HTML_DD: case HTML_DT: case HTML_LI: case HTML_LH :
-		     case HTML_TD: case HTML_TH: case HTML_TR: case HTML_THEAD:
-		     case HTML_TFOOT : case HTML_TBODY : case HTML_COLGROUP:
+		    ) {
+		    switch (e) {
+		    case HTML_DD:
+		    case HTML_DT:
+		    case HTML_LI:
+		    case HTML_LH:
+		    case HTML_TD:
+		    case HTML_TH:
+		    case HTML_TR:
+		    case HTML_THEAD:
+		    case HTML_TFOOT:
+		    case HTML_TBODY:
+		    case HTML_COLGROUP:
 			branch = 0;
 			break;
 
-		     case HTML_A:  case HTML_B: case HTML_BLINK: case HTML_CITE:
-		     case HTML_EM: case HTML_FONT: case HTML_FORM: case HTML_I:
-		     case HTML_P:  case HTML_STRONG: case HTML_TT: case HTML_U:
+		    case HTML_A:
+		    case HTML_B:
+		    case HTML_BLINK:
+		    case HTML_CITE:
+		    case HTML_EM:
+		    case HTML_FONT:
+		    case HTML_FORM:
+		    case HTML_I:
+		    case HTML_P:
+		    case HTML_STRONG:
+		    case HTML_TT:
+		    case HTML_U:
 			branch = 1;
 			break;
 		    default:
@@ -3941,36 +3887,36 @@
 
 #ifdef EXTENDED_HTMLDTD
 		/*
-		**  Just handle ALL end tags normally :-) - kw
-		*/
+		 * Just handle ALL end tags normally :-) - kw
+		 */
 		if (!Old_DTD) {
-		    end_element( context, context->current_tag);
+		    end_element(context, context->current_tag);
 		} else
 #endif /* EXTENDED_HTMLDTD */
 
-		if (tag_OK &&
+		    if (tag_OK &&
 #if OPT
-		    (branch == 0)
+			(branch == 0)
 #else
-		    (!strcasecomp(string->data, "DD") ||
-		     !strcasecomp(string->data, "DT") ||
-		     !strcasecomp(string->data, "LI") ||
-		     !strcasecomp(string->data, "LH") ||
-		     !strcasecomp(string->data, "TD") ||
-		     !strcasecomp(string->data, "TH") ||
-		     !strcasecomp(string->data, "TR") ||
-		     !strcasecomp(string->data, "THEAD") ||
-		     !strcasecomp(string->data, "TFOOT") ||
-		     !strcasecomp(string->data, "TBODY") ||
-		     !strcasecomp(string->data, "COLGROUP"))
+			(!strcasecomp(string->data, "DD") ||
+			 !strcasecomp(string->data, "DT") ||
+			 !strcasecomp(string->data, "LI") ||
+			 !strcasecomp(string->data, "LH") ||
+			 !strcasecomp(string->data, "TD") ||
+			 !strcasecomp(string->data, "TH") ||
+			 !strcasecomp(string->data, "TR") ||
+			 !strcasecomp(string->data, "THEAD") ||
+			 !strcasecomp(string->data, "TFOOT") ||
+			 !strcasecomp(string->data, "TBODY") ||
+			 !strcasecomp(string->data, "COLGROUP"))
 #endif
-		 ) {
+		    ) {
 		    /*
-		    **	Don't treat these end tags as invalid,
-		    **	nor act on them. - FM
-		    */
+		     * Don't treat these end tags as invalid, nor act on them. 
+		     * - FM
+		     */
 		    CTRACE((tfp, "SGML: `</%s%c' found!  Ignoring it.\n",
-				string->data, c));
+			    string->data, c));
 		    string->size = 0;
 		    context->current_attribute_number = INVALID;
 		    if (c != '>') {
@@ -3997,52 +3943,56 @@
 			    !strcasecomp(string->data, "TT") ||
 			    !strcasecomp(string->data, "U"))
 #endif
-		) {
+		    ) {
 		    /*
-		    **	Handle end tags for container elements declared
-		    **	as SGML_EMPTY to prevent "expected tag substitution"
-		    **	but still processed via HTML_end_element() in HTML.c
-		    **	with checks there to avoid throwing the HTML.c stack
-		    **	out of whack (Ugh, what a hack! 8-). - FM
-		    */
+		     * Handle end tags for container elements declared as
+		     * SGML_EMPTY to prevent "expected tag substitution" but
+		     * still processed via HTML_end_element() in HTML.c with
+		     * checks there to avoid throwing the HTML.c stack out of
+		     * whack (Ugh, what a hack!  8-).  - FM
+		     */
 		    if (context->inSELECT) {
 			/*
-			**  We are in a SELECT block. - FM
-			*/
+			 * We are in a SELECT block.  - FM
+			 */
 			if (strcasecomp(string->data, "FORM")) {
 			    /*
-			    **	It is not at FORM end tag, so ignore it. - FM
-			    */
-			    CTRACE((tfp, "SGML: ***Ignoring end tag </%s> in SELECT block.\n",
-					string->data));
+			     * It is not at FORM end tag, so ignore it.  - FM
+			     */
+			    CTRACE((tfp,
+				    "SGML: ***Ignoring end tag </%s> in SELECT block.\n",
+				    string->data));
 			} else {
 			    /*
-			    **	End the SELECT block and then
-			    **	handle the FORM end tag. - FM
-			    */
-			    CTRACE((tfp, "SGML: ***Faking SELECT end tag before </%s> end tag.\n",
-					string->data));
+			     * End the SELECT block and then handle the FORM
+			     * end tag.  - FM
+			     */
+			    CTRACE((tfp,
+				    "SGML: ***Faking SELECT end tag before </%s> end tag.\n",
+				    string->data));
 			    end_element(context,
 					SGMLFindTag(context->dtd, "SELECT"));
 			    CTRACE((tfp, "SGML: End </%s>\n", string->data));
 
 #ifdef USE_PRETTYSRC
-			    if (!psrc_view) /* Don't actually call if viewing psrc - kw */
+			    if (!psrc_view)	/* Don't actually call if viewing psrc - kw */
 #endif
-			    (*context->actions->end_element)
-				(context->target,
-				 TAGNUM_OF_TAGP(context->current_tag),
-				 (char **)&context->include);
+				(*context->actions->end_element)
+				    (context->target,
+				     TAGNUM_OF_TAGP(context->current_tag),
+				     &context->include);
 			}
 		    } else if (!strcasecomp(string->data, "P")) {
 			/*
-			**  Treat a P end tag like a P start tag (Ugh,
-			**  what a hack! 8-). - FM
-			*/
-			CTRACE((tfp, "SGML: `</%s%c' found!  Treating as '<%s%c'.\n",
-				    string->data, c, string->data, c));
+			 * Treat a P end tag like a P start tag (Ugh, what a
+			 * hack!  8-).  - FM
+			 */
+			CTRACE((tfp,
+				"SGML: `</%s%c' found!  Treating as '<%s%c'.\n",
+				string->data, c, string->data, c));
 			{
 			    int i;
+
 			    for (i = 0;
 				 i < context->current_tag->number_of_attributes;
 				 i++) {
@@ -4055,12 +4005,12 @@
 			CTRACE((tfp, "SGML: End </%s>\n", string->data));
 
 #ifdef USE_PRETTYSRC
-			if (!psrc_view) /* Don't actually call if viewing psrc - kw */
+			if (!psrc_view)		/* Don't actually call if viewing psrc - kw */
 #endif
-			(*context->actions->end_element)
-			    (context->target,
-			     TAGNUM_OF_TAGP(context->current_tag),
-			     (char **)&context->include);
+			    (*context->actions->end_element)
+				(context->target,
+				 TAGNUM_OF_TAGP(context->current_tag),
+				 &context->include);
 		    }
 		    string->size = 0;
 		    context->current_attribute_number = INVALID;
@@ -4073,9 +4023,9 @@
 		    break;
 		} else {
 		    /*
-		    **	Handle all other end tags normally. - FM
-		    */
-		    end_element( context, context->current_tag);
+		     * Handle all other end tags normally.  - FM
+		     */
+		    end_element(context, context->current_tag);
 		}
 	    }
 
@@ -4093,7 +4043,7 @@
 		}
 		PUTS(string->data);
 		PSRCSTOP(tag);
-		if ( c != '>' ) {
+		if (c != '>') {
 		    PSRCSTART(badtag);
 		    PUTC(c);
 		} else {
@@ -4108,7 +4058,7 @@
 	    context->current_attribute_number = INVALID;
 	    if (c != '>') {
 		if (!WHITE(c))
-		    CTRACE((tfp,"SGML: `</%s%c' found!\n", string->data, c));
+		    CTRACE((tfp, "SGML: `</%s%c' found!\n", string->data, c));
 		context->state = S_junk_tag;
 	    } else {
 		context->current_tag = NULL;
@@ -4117,7 +4067,6 @@
 	}
 	break;
 
-
     case S_esc:		/* Expecting '$'or '(' following CJK ESC. */
 	if (c == '$') {
 	    context->state = S_dollar;
@@ -4129,7 +4078,7 @@
 	PUTC(c);
 	break;
 
-    case S_dollar:	/* Expecting '@', 'B', 'A' or '(' after CJK "ESC$". */
+    case S_dollar:		/* Expecting '@', 'B', 'A' or '(' after CJK "ESC$". */
 	if (c == '@' || c == 'B' || c == 'A') {
 	    context->state = S_nonascii_text;
 	} else if (c == '(') {
@@ -4138,7 +4087,7 @@
 	PUTC(c);
 	break;
 
-    case S_dollar_paren: /* Expecting 'C' after CJK "ESC$(". */
+    case S_dollar_paren:	/* Expecting 'C' after CJK "ESC$(". */
 	if (c == 'C') {
 	    context->state = S_nonascii_text;
 	} else {
@@ -4147,7 +4096,7 @@
 	PUTC(c);
 	break;
 
-    case S_paren:	/* Expecting 'B', 'J', 'T' or 'I' after CJK "ESC(". */
+    case S_paren:		/* Expecting 'B', 'J', 'T' or 'I' after CJK "ESC(". */
 	if (c == 'B' || c == 'J' || c == 'T') {
 	    context->state = S_text;
 	} else if (c == 'I') {
@@ -4158,8 +4107,8 @@
 	PUTC(c);
 	break;
 
-    case S_nonascii_text: /* Expecting CJK ESC after non-ASCII text. */
-	if (TOASCII(c) == '\033') {  /* S/390 -- gil -- 1264 */
+    case S_nonascii_text:	/* Expecting CJK ESC after non-ASCII text. */
+	if (TOASCII(c) == '\033') {	/* S/390 -- gil -- 1264 */
 	    context->state = S_esc;
 	}
 	PUTC(c);
@@ -4167,7 +4116,7 @@
 	    context->state = S_text;
 	break;
 
-    case S_esc_sq:	/* Expecting '$'or '(' following CJK ESC. */
+    case S_esc_sq:		/* Expecting '$'or '(' following CJK ESC. */
 	if (c == '$') {
 	    context->state = S_dollar_sq;
 	} else if (c == '(') {
@@ -4178,7 +4127,7 @@
 	HTChunkPutc(string, c);
 	break;
 
-    case S_dollar_sq:	/* Expecting '@', 'B', 'A' or '(' after CJK "ESC$". */
+    case S_dollar_sq:		/* Expecting '@', 'B', 'A' or '(' after CJK "ESC$". */
 	if (c == '@' || c == 'B' || c == 'A') {
 	    context->state = S_nonascii_text_sq;
 	} else if (c == '(') {
@@ -4187,7 +4136,7 @@
 	HTChunkPutc(string, c);
 	break;
 
-    case S_dollar_paren_sq: /* Expecting 'C' after CJK "ESC$(". */
+    case S_dollar_paren_sq:	/* Expecting 'C' after CJK "ESC$(". */
 	if (c == 'C') {
 	    context->state = S_nonascii_text_sq;
 	} else {
@@ -4196,7 +4145,7 @@
 	HTChunkPutc(string, c);
 	break;
 
-    case S_paren_sq:	/* Expecting 'B', 'J', 'T' or 'I' after CJK "ESC(". */
+    case S_paren_sq:		/* Expecting 'B', 'J', 'T' or 'I' after CJK "ESC(". */
 	if (c == 'B' || c == 'J' || c == 'T') {
 	    context->state = S_squoted;
 	} else if (c == 'I') {
@@ -4207,8 +4156,8 @@
 	HTChunkPutc(string, c);
 	break;
 
-    case S_nonascii_text_sq: /* Expecting CJK ESC after non-ASCII text. */
-	if (TOASCII(c) == '\033') {  /* S/390 -- gil -- 1281 */
+    case S_nonascii_text_sq:	/* Expecting CJK ESC after non-ASCII text. */
+	if (TOASCII(c) == '\033') {	/* S/390 -- gil -- 1281 */
 	    context->state = S_esc_sq;
 	}
 	HTChunkPutc(string, c);
@@ -4225,7 +4174,7 @@
 	HTChunkPutc(string, c);
 	break;
 
-    case S_dollar_dq:	/* Expecting '@', 'B', 'A' or '(' after CJK "ESC$". */
+    case S_dollar_dq:		/* Expecting '@', 'B', 'A' or '(' after CJK "ESC$". */
 	if (c == '@' || c == 'B' || c == 'A') {
 	    context->state = S_nonascii_text_dq;
 	} else if (c == '(') {
@@ -4234,7 +4183,7 @@
 	HTChunkPutc(string, c);
 	break;
 
-    case S_dollar_paren_dq: /* Expecting 'C' after CJK "ESC$(". */
+    case S_dollar_paren_dq:	/* Expecting 'C' after CJK "ESC$(". */
 	if (c == 'C') {
 	    context->state = S_nonascii_text_dq;
 	} else {
@@ -4243,7 +4192,7 @@
 	HTChunkPutc(string, c);
 	break;
 
-    case S_paren_dq:	/* Expecting 'B', 'J', 'T' or 'I' after CJK "ESC(". */
+    case S_paren_dq:		/* Expecting 'B', 'J', 'T' or 'I' after CJK "ESC(". */
 	if (c == 'B' || c == 'J' || c == 'T') {
 	    context->state = S_dquoted;
 	} else if (c == 'I') {
@@ -4254,8 +4203,8 @@
 	HTChunkPutc(string, c);
 	break;
 
-    case S_nonascii_text_dq: /* Expecting CJK ESC after non-ASCII text. */
-	if (TOASCII(c) == '\033') {  /* S/390 -- gil -- 1298 */
+    case S_nonascii_text_dq:	/* Expecting CJK ESC after non-ASCII text. */
+	if (TOASCII(c) == '\033') {	/* S/390 -- gil -- 1298 */
 	    context->state = S_esc_dq;
 	}
 	HTChunkPutc(string, c);
@@ -4280,7 +4229,7 @@
 	}
 #ifdef USE_PRETTYSRC
 	else if (psrc_view) {
-	    /*pack spaces until first non-space is seen*/
+	    /*pack spaces until first non-space is seen */
 	    if (!context->seen_nonwhite_in_junk_tag) {
 		if (!WHITE(c)) {
 		    context->seen_nonwhite_in_junk_tag = TRUE;
@@ -4291,19 +4240,19 @@
 	}
 #endif
 
-    } /* switch on context->state */
+    }				/* switch on context->state */
     CTRACE2(TRACE_SGML, (tfp, "SGML after  %s|%.*s|%c|\n",
-	    state_name(context->state),
-	    string->size,
-	    NonNull(string->data),
-	    UCH(c)));
+			 state_name(context->state),
+			 string->size,
+			 NonNull(string->data),
+			 UCH(c)));
 
-after_switch:
+  after_switch:
     /*
-    **	Check whether an external function has added
-    **	anything to the include buffer.  If so, move the
-    **	new stuff to the beginning of active_include. - kw
-    */
+     * Check whether an external function has added anything to the include
+     * buffer.  If so, move the new stuff to the beginning of active_include. 
+     * - kw
+     */
     if (context->include != NULL) {
 	if (context->include[0] == '\0') {
 	    FREE(context->include);
@@ -4320,8 +4269,8 @@
     }
 
     /*
-    **	Check whether we've added anything to the recover buffer. - FM
-    */
+     * Check whether we've added anything to the recover buffer.  - FM
+     */
     if (context->recover != NULL) {
 	if (context->recover[context->recover_index] == '\0') {
 	    FREE(context->recover);
@@ -4334,10 +4283,9 @@
     }
 
     /*
-    **	Check whether an external function had added
-    **	anything to the include buffer; it should now be
-    **  in active_include. - FM / kw
-    */
+     * Check whether an external function had added anything to the include
+     * buffer; it should now be in active_include.  - FM / kw
+     */
     if (context->active_include != NULL) {
 	if (context->active_include[context->include_index] == '\0') {
 	    FREE(context->active_include);
@@ -4346,25 +4294,25 @@
 	    if (context->current_tag_charset == UTF8_handle ||
 		context->T.trans_from_uni) {
 		/*
-		 *  If it looks like we would have fed UTF-8 to the
-		 *  next processing stage, assume that whatever we were
-		 *  fed back is in UTF-8 form, too.  This won't be always
-		 *  true for all uses of the include buffer, but it's a
-		 *  start. - kw
+		 * If it looks like we would have fed UTF-8 to the next
+		 * processing stage, assume that whatever we were fed back is
+		 * in UTF-8 form, too.  This won't be always true for all uses
+		 * of the include buffer, but it's a start.  - kw
 		 */
 		char *puni = context->active_include + context->include_index;
+
 		c = *puni;
 		clong = UCGetUniFromUtf8String(&puni);
 		if (clong < 256 && clong >= 0) {
-			c = ((char)(clong & 0xff));
+		    c = ((char) (clong & 0xff));
 		}
 		saved_char_in = '\0';
 		context->include_index = puni - context->active_include + 1;
 		goto top1;
 	    } else {
 		/*
-		 *  Otherwise assume no UTF-8 - do charset-naive processing
-		 *  and hope for the best. - kw
+		 * Otherwise assume no UTF-8 - do charset-naive processing and
+		 * hope for the best.  - kw
 		 */
 		c = context->active_include[context->include_index];
 		context->include_index++;
@@ -4374,9 +4322,9 @@
     }
 
     /*
-    **	Check whether an external function has added
-    **	anything to the csi buffer. - FM
-    */
+     * Check whether an external function has added anything to the csi buffer. 
+     * - FM
+     */
     if (context->csi != NULL) {
 	if (context->csi[context->csi_index] == '\0') {
 	    FREE(context->csi);
@@ -4387,26 +4335,22 @@
 	    goto top;
 	}
     }
-}  /* SGML_character */
-
+}				/* SGML_character */
 
-PRIVATE void SGML_string ARGS2(
-	HTStream *,	context,
-	CONST char*,	str)
+static void SGML_string(HTStream *context, const char *str)
 {
-    CONST char *p;
+    const char *p;
+
     for (p = str; *p; p++)
 	SGML_character(context, *p);
 }
 
-
-PRIVATE void SGML_write ARGS3(
-	HTStream *,	context,
-	CONST char*,	str,
-	int,		l)
+static void SGML_write(HTStream *context, const char *str,
+		       int l)
 {
-    CONST char *p;
-    CONST char *e = str+l;
+    const char *p;
+    const char *e = str + l;
+
     for (p = str; p < e; p++)
 	SGML_character(context, *p);
 }
@@ -4415,34 +4359,34 @@
 */
 
 /*	Structured Object Class
-**	-----------------------
-*/
-PUBLIC CONST HTStreamClass SGMLParser =
+ *	-----------------------
+ */
+const HTStreamClass SGMLParser =
 {
-	"SGMLParser",
-	SGML_free,
-	SGML_abort,
-	SGML_character,
-	SGML_string,
-	SGML_write,
+    "SGMLParser",
+    SGML_free,
+    SGML_abort,
+    SGML_character,
+    SGML_string,
+    SGML_write,
 };
 
 /*	Create SGML Engine
-**	------------------
-**
-** On entry,
-**	dtd		represents the DTD, along with
-**	actions		is the sink for the data as a set of routines.
-**
-*/
+ *	------------------
+ *
+ * On entry,
+ *	dtd		represents the DTD, along with
+ *	actions		is the sink for the data as a set of routines.
+ *
+ */
 
-PUBLIC HTStream* SGML_new  ARGS3(
-	CONST SGML_dtd *,	dtd,
-	HTParentAnchor *,	anchor,
-	HTStructured *,		target)
+HTStream *SGML_new(const SGML_dtd * dtd,
+		   HTParentAnchor *anchor,
+		   HTStructured * target)
 {
     int i;
-    HTStream* context = (HTStream *) malloc(sizeof(*context));
+    HTStream *context = (HTStream *) malloc(sizeof(*context));
+
     if (!context)
 	outofmem(__FILE__, "SGML_begin");
 
@@ -4452,17 +4396,17 @@
     context->trailing_spaces = 0;
     context->dtd = dtd;
     context->target = target;
-    context->actions = (CONST HTStructuredClass*)(((HTStream*)target)->isa);
-					/* Ugh: no OO */
+    context->actions = (const HTStructuredClass *) (((HTStream *) target)->isa);
+    /* Ugh: no OO */
     context->unknown_tag = &HTTag_unrecognized;
     context->current_tag = context->slashedtag = NULL;
     context->state = S_text;
     context->kanji_buf = '\0';
-    context->element_stack = 0;			/* empty */
+    context->element_stack = 0;	/* empty */
     context->inSELECT = FALSE;
-    context->no_lynx_specialcodes = NO;	/* special codes normally generated */
+    context->no_lynx_specialcodes = NO;		/* special codes normally generated */
 #ifdef CALLERDATA
-    context->callerData = (void*) callerData;
+    context->callerData = (void *) callerData;
 #endif /* CALLERDATA */
     for (i = 0; i < MAX_ATTRIBUTES; i++)
 	context->value[i] = 0;
@@ -4475,7 +4419,7 @@
     context->second_bracket = FALSE;
     context->isHex = FALSE;
 
-    context->node_anchor = anchor; /* Could be NULL? */
+    context->node_anchor = anchor;	/* Could be NULL? */
     context->utf_count = 0;
     context->utf_char = 0;
     context->utf_buf[0] = context->utf_buf[6] = '\0';
@@ -4491,15 +4435,15 @@
 	context->inUCLYhndl = HTAnchor_getUCLYhndl(anchor,
 						   UCT_STAGE_PARSER);
     }
-#ifdef CAN_SWITCH_DISPLAY_CHARSET /* Allow a switch to a more suitable display charset */
+#ifdef CAN_SWITCH_DISPLAY_CHARSET	/* Allow a switch to a more suitable display charset */
     else if (anchor->UCStages
 	     && anchor->UCStages->s[UCT_STAGE_PARSER].LYhndl >= 0
-	     && anchor->UCStages->s[UCT_STAGE_PARSER].LYhndl != current_char_set ) {
+	     && anchor->UCStages->s[UCT_STAGE_PARSER].LYhndl != current_char_set) {
 	int o = anchor->UCStages->s[UCT_STAGE_PARSER].LYhndl;
 
-	anchor->UCStages->s[UCT_STAGE_PARSER].LYhndl = -1; /* Force reset */
+	anchor->UCStages->s[UCT_STAGE_PARSER].LYhndl = -1;	/* Force reset */
 	HTAnchor_resetUCInfoStage(anchor, o, UCT_STAGE_PARSER,
-				  /* Preserve change this: */
+	/* Preserve change this: */
 				  anchor->UCStages->s[UCT_STAGE_PARSER].lock);
     }
 #endif
@@ -4534,11 +4478,11 @@
 }
 
 /*		Asian character conversion functions
-**		====================================
-**
-**	Added 24-Mar-96 by FM, based on:
-**
-////////////////////////////////////////////////////////////////////////
+ *		====================================
+ *
+ *	Added 24-Mar-96 by FM, based on:
+ *
+ ////////////////////////////////////////////////////////////////////////
 Copyright (c) 1993 Electrotechnical Laboratory (ETL)
 
 Permission to use, copy, modify, and distribute this material
@@ -4561,78 +4505,78 @@
 ///////////////////////////////////////////////////////////////////////
 */
 
-PUBLIC int TREAT_SJIS = 1;
+static int TREAT_SJIS = 1;
 
-PUBLIC void JISx0201TO0208_EUC ARGS4(
-	register unsigned char,		IHI,
-	register unsigned char,		ILO,
-	register unsigned char *,	OHI,
-	register unsigned char *,	OLO)
-{
-    static char *table[] = {
-	"\241\243",	/* A1,A3 */
-	"\241\326",	/* A1,D6 */
-	"\241\327",	/* A1,D7 */
-	"\241\242",	/* A1,A2 */
-	"\241\246",	/* A1,A6 */
-	"\245\362",	/* A5,F2 */
-	"\245\241",	/* A5,A1 */
-	"\245\243",	/* A5,A3 */
-	"\245\245",	/* A5,A5 */
-	"\245\247",	/* A5,A7 */
-	"\245\251",	/* A5,A9 */
-	"\245\343",	/* A5,E3 */
-	"\245\345",	/* A5,E5 */
-	"\245\347",	/* A5,E7 */
-	"\245\303",	/* A5,C3 */
-	"\241\274",	/* A1,BC */
-	"\245\242",	/* A5,A2 */
-	"\245\244",	/* A5,A4 */
-	"\245\246",	/* A5,A6 */
-	"\245\250",	/* A5,A8 */
-	"\245\252",	/* A5,AA */
-	"\245\253",	/* A5,AB */
-	"\245\255",	/* A5,AD */
-	"\245\257",	/* A5,AF */
-	"\245\261",	/* A5,B1 */
-	"\245\263",	/* A5,B3 */
-	"\245\265",	/* A5,B5 */
-	"\245\267",	/* A5,B7 */
-	"\245\271",	/* A5,B9 */
-	"\245\273",	/* A5,BB */
-	"\245\275",	/* A5,BD */
-	"\245\277",	/* A5,BF */
-	"\245\301",	/* A5,C1 */
-	"\245\304",	/* A5,C4 */
-	"\245\306",	/* A5,C6 */
-	"\245\310",	/* A5,C8 */
-	"\245\312",	/* A5,CA */
-	"\245\313",	/* A5,CB */
-	"\245\314",	/* A5,CC */
-	"\245\315",	/* A5,CD */
-	"\245\316",	/* A5,CE */
-	"\245\317",	/* A5,CF */
-	"\245\322",	/* A5,D2 */
-	"\245\325",	/* A5,D5 */
-	"\245\330",	/* A5,D8 */
-	"\245\333",	/* A5,DB */
-	"\245\336",	/* A5,DE */
-	"\245\337",	/* A5,DF */
-	"\245\340",	/* A5,E0 */
-	"\245\341",	/* A5,E1 */
-	"\245\342",	/* A5,E2 */
-	"\245\344",	/* A5,E4 */
-	"\245\346",	/* A5,E6 */
-	"\245\350",	/* A5,E8 */
-	"\245\351",	/* A5,E9 */
-	"\245\352",	/* A5,EA */
-	"\245\353",	/* A5,EB */
-	"\245\354",	/* A5,EC */
-	"\245\355",	/* A5,ED */
-	"\245\357",	/* A5,EF */
-	"\245\363",	/* A5,F3 */
-	"\241\253",	/* A1,AB */
-	"\241\254"	/* A1,AC */
+void JISx0201TO0208_EUC(unsigned char IHI,
+			unsigned char ILO,
+			unsigned char *OHI,
+			unsigned char *OLO)
+{
+    static const char *table[] =
+    {
+	"\241\243",		/* A1,A3 */
+	"\241\326",		/* A1,D6 */
+	"\241\327",		/* A1,D7 */
+	"\241\242",		/* A1,A2 */
+	"\241\246",		/* A1,A6 */
+	"\245\362",		/* A5,F2 */
+	"\245\241",		/* A5,A1 */
+	"\245\243",		/* A5,A3 */
+	"\245\245",		/* A5,A5 */
+	"\245\247",		/* A5,A7 */
+	"\245\251",		/* A5,A9 */
+	"\245\343",		/* A5,E3 */
+	"\245\345",		/* A5,E5 */
+	"\245\347",		/* A5,E7 */
+	"\245\303",		/* A5,C3 */
+	"\241\274",		/* A1,BC */
+	"\245\242",		/* A5,A2 */
+	"\245\244",		/* A5,A4 */
+	"\245\246",		/* A5,A6 */
+	"\245\250",		/* A5,A8 */
+	"\245\252",		/* A5,AA */
+	"\245\253",		/* A5,AB */
+	"\245\255",		/* A5,AD */
+	"\245\257",		/* A5,AF */
+	"\245\261",		/* A5,B1 */
+	"\245\263",		/* A5,B3 */
+	"\245\265",		/* A5,B5 */
+	"\245\267",		/* A5,B7 */
+	"\245\271",		/* A5,B9 */
+	"\245\273",		/* A5,BB */
+	"\245\275",		/* A5,BD */
+	"\245\277",		/* A5,BF */
+	"\245\301",		/* A5,C1 */
+	"\245\304",		/* A5,C4 */
+	"\245\306",		/* A5,C6 */
+	"\245\310",		/* A5,C8 */
+	"\245\312",		/* A5,CA */
+	"\245\313",		/* A5,CB */
+	"\245\314",		/* A5,CC */
+	"\245\315",		/* A5,CD */
+	"\245\316",		/* A5,CE */
+	"\245\317",		/* A5,CF */
+	"\245\322",		/* A5,D2 */
+	"\245\325",		/* A5,D5 */
+	"\245\330",		/* A5,D8 */
+	"\245\333",		/* A5,DB */
+	"\245\336",		/* A5,DE */
+	"\245\337",		/* A5,DF */
+	"\245\340",		/* A5,E0 */
+	"\245\341",		/* A5,E1 */
+	"\245\342",		/* A5,E2 */
+	"\245\344",		/* A5,E4 */
+	"\245\346",		/* A5,E6 */
+	"\245\350",		/* A5,E8 */
+	"\245\351",		/* A5,E9 */
+	"\245\352",		/* A5,EA */
+	"\245\353",		/* A5,EB */
+	"\245\354",		/* A5,EC */
+	"\245\355",		/* A5,ED */
+	"\245\357",		/* A5,EF */
+	"\245\363",		/* A5,F3 */
+	"\241\253",		/* A1,AB */
+	"\241\254"		/* A1,AC */
     };
 
     if ((IHI == 0x8E) && (ILO >= 0xA1) && (ILO <= 0xDF)) {
@@ -4644,9 +4588,9 @@
     }
 }
 
-PRIVATE int IS_SJIS_STR ARGS1(CONST unsigned char *, str)
+static int IS_SJIS_STR(const unsigned char *str)
 {
-    CONST unsigned char *s;
+    const unsigned char *s;
     unsigned char ch;
     int is_sjis = 0;
 
@@ -4659,10 +4603,9 @@
     return 0;
 }
 
-PUBLIC unsigned char * SJIS_TO_JIS1 ARGS3(
-	register unsigned char,		HI,
-	register unsigned char,		LO,
-	register unsigned char *,	JCODE)
+unsigned char *SJIS_TO_JIS1(register unsigned char HI,
+			    register unsigned char LO,
+			    register unsigned char *JCODE)
 {
     HI -= UCH((HI <= 0x9F) ? 0x71 : 0xB1);
     HI = UCH((HI << 1) + 1);
@@ -4679,10 +4622,9 @@
     return JCODE;
 }
 
-PUBLIC unsigned char * JIS_TO_SJIS1 ARGS3(
-	register unsigned char,		HI,
-	register unsigned char,		LO,
-	register unsigned char *,	SJCODE)
+unsigned char *JIS_TO_SJIS1(register unsigned char HI,
+			    register unsigned char LO,
+			    register unsigned char *SJCODE)
 {
     if (HI & 1)
 	LO += UCH(0x1F);
@@ -4699,10 +4641,9 @@
     return SJCODE;
 }
 
-PUBLIC unsigned char * EUC_TO_SJIS1 ARGS3(
-	unsigned char,			HI,
-	unsigned char,			LO,
-	register unsigned char *,	SJCODE)
+unsigned char *EUC_TO_SJIS1(unsigned char HI,
+			    unsigned char LO,
+			    register unsigned char *SJCODE)
 {
     if (HI == 0x8E)
 	JISx0201TO0208_EUC(HI, LO, &HI, &LO);
@@ -4710,10 +4651,9 @@
     return SJCODE;
 }
 
-PUBLIC void JISx0201TO0208_SJIS ARGS3(
-	register unsigned char,		I,
-	register unsigned char *,	OHI,
-	register unsigned char *,	OLO)
+void JISx0201TO0208_SJIS(register unsigned char I,
+			 register unsigned char *OHI,
+			 register unsigned char *OLO)
 {
     unsigned char SJCODE[2];
 
@@ -4723,10 +4663,9 @@
     *OLO = SJCODE[1];
 }
 
-PUBLIC unsigned char * SJIS_TO_EUC1 ARGS3(
-	unsigned char,		HI,
-	unsigned char,		LO,
-	unsigned char *,	data)
+unsigned char *SJIS_TO_EUC1(unsigned char HI,
+			    unsigned char LO,
+			    unsigned char *data)
 {
     SJIS_TO_JIS1(HI, LO, data);
     data[0] |= 0x80;
@@ -4734,9 +4673,8 @@
     return data;
 }
 
-PUBLIC unsigned char * SJIS_TO_EUC ARGS2(
-	unsigned char *,	src,
-	unsigned char *,	dst)
+unsigned char *SJIS_TO_EUC(unsigned char *src,
+			   unsigned char *dst)
 {
     register unsigned char hi, lo, *sp, *dp;
     register int in_sjis = 0;
@@ -4757,9 +4695,8 @@
     return dst;
 }
 
-PUBLIC unsigned char * EUC_TO_SJIS ARGS2(
-	unsigned char *,	src,
-	unsigned char *,	dst)
+unsigned char *EUC_TO_SJIS(unsigned char *src,
+			   unsigned char *dst)
 {
     register unsigned char *sp, *dp;
 
@@ -4780,13 +4717,12 @@
     return dst;
 }
 
-#define Strcpy(a,b)	(strcpy((char*)a,(CONST char*)b),&a[strlen((CONST char*)a)])
+#define Strcpy(a,b)	(strcpy((char*)a,(const char*)b),&a[strlen((const char*)a)])
 
-PUBLIC unsigned char *EUC_TO_JIS ARGS4(
-	unsigned char *,	src,
-	unsigned char *,	dst,
-	CONST char *,		toK,
-	CONST char *,		toA)
+unsigned char *EUC_TO_JIS(unsigned char *src,
+			  unsigned char *dst,
+			  const char *toK,
+			  const char *toA)
 {
     register unsigned char kana_mode = 0;
     register unsigned char cch;
@@ -4831,13 +4767,12 @@
 #define SO		('N'-0x40)
 #define SI		('O'-0x40)
 
-PUBLIC int repair_JIS = 0;
+static int repair_JIS = 0;
 
-PRIVATE CONST unsigned char *repairJIStoEUC ARGS2(
-	CONST unsigned char *,	src,
-	unsigned char **,	dstp)
+static const unsigned char *repairJIStoEUC(const unsigned char *src,
+					   unsigned char **dstp)
 {
-    CONST unsigned char *s;
+    const unsigned char *s;
     unsigned char *d, ch1, ch2;
 
     d = *dstp;
@@ -4858,11 +4793,10 @@
     return 0;
 }
 
-PUBLIC unsigned char *TO_EUC ARGS2(
-	CONST unsigned char *,	jis,
-	unsigned char *,	euc)
+unsigned char *TO_EUC(const unsigned char *jis,
+		      unsigned char *euc)
 {
-    register CONST unsigned char *s;
+    register const unsigned char *s;
     register unsigned char c, jis_stat;
     unsigned char *d;
     register int to1B, to2B;
@@ -4889,7 +4823,8 @@
 
 	if (c == to2B && jis_stat == 0 && repair_JIS) {
 	    if (*s == 'B' || *s == '@') {
-		CONST unsigned char *ts;
+		const unsigned char *ts;
+
 		if ((ts = repairJIStoEUC(s + 1, &d)) != NULL) {
 		    s = ts;
 		    continue;
@@ -4948,7 +4883,7 @@
 
 #define non94(ch) ((ch) <= 0x20 || (ch) == 0x7F)
 
-PRIVATE int is_EUC_JP ARGS1(unsigned char *, euc)
+static int is_EUC_JP(unsigned char *euc)
 {
     unsigned char *cp;
     int ch1, ch2;
@@ -4970,41 +4905,40 @@
     return 1;
 }
 
-PUBLIC void TO_SJIS ARGS2(
-	CONST unsigned char *,	any,
-	unsigned char *,	sjis)
+void TO_SJIS(const unsigned char *arg,
+	     unsigned char *sjis)
 {
     unsigned char *euc;
 
-    euc = malloc(strlen((CONST char *) any) + 1);
+    euc = typeMallocn(unsigned char, strlen((const char *) arg) + 1);
+
 #ifdef CJK_EX
     if (!euc)
 	outofmem(__FILE__, "TO_SJIS");
 #endif
-    TO_EUC(any, euc);
+    TO_EUC(arg, euc);
     if (is_EUC_JP(euc))
 	EUC_TO_SJIS(euc, sjis);
     else
-	strcpy((char *) sjis, (CONST char *) any);
+	strcpy((char *) sjis, (const char *) arg);
     free(euc);
 }
 
-PUBLIC void TO_JIS ARGS2(
-	CONST unsigned char *,	any,
-	unsigned char *,	jis)
+void TO_JIS(const unsigned char *arg,
+	    unsigned char *jis)
 {
     unsigned char *euc;
 
-    if (any[0] == 0) {
+    if (arg[0] == 0) {
 	jis[0] = 0;
 	return;
     }
-    euc = malloc(strlen((CONST char *) any) + 1);
+    euc = typeMallocn(unsigned char, strlen((const char *)arg) + 1);
 #ifdef CJK_EX
     if (!euc)
 	outofmem(__FILE__, "TO_JIS");
 #endif
-    TO_EUC(any, euc);
+    TO_EUC(arg, euc);
     is_EUC_JP(euc);
     EUC_TO_JIS(euc, jis, TO_KANJI, TO_ASCII);
 
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/HTTCP.c
+++ lynx-cur-2.8.6/WWW/Library/Implementation/HTTCP.c
@@ -1,20 +1,20 @@
 /*			Generic Communication Code		HTTCP.c
-**			==========================
-**
-**	This code is in common between client and server sides.
-**
-**	16 Jan 92  TBL	Fix strtol() undefined on CMU Mach.
-**	25 Jun 92  JFG	Added DECNET option through TCP socket emulation.
-**	13 Sep 93  MD	Added correct return of vmserrorno for HTInetStatus.
-**			Added decoding of vms error message for MULTINET.
-**	7-DEC-1993 Bjorn S. Nilsson, ALEPH, CERN, VMS UCX ioctl() changes
-**			(done of Mosaic)
-**	19 Feb 94  Danny Mayer	Added Bjorn Fixes to Lynx version
-**	 7 Mar 94  Danny Mayer	Added Fix UCX version for full domain name
-**	20 May 94  Andy Harper	Added support for CMU TCP/IP transport
-**	17 Nov 94  Andy Harper	Added support for SOCKETSHR transport
-**	16 Jul 95  S. Bjorndahl added kluge to deal with LIBCMU bug
-*/
+ *			==========================
+ *
+ *	This code is in common between client and server sides.
+ *
+ *	16 Jan 92  TBL	Fix strtol() undefined on CMU Mach.
+ *	25 Jun 92  JFG	Added DECNET option through TCP socket emulation.
+ *	13 Sep 93  MD	Added correct return of vmserrorno for HTInetStatus.
+ *			Added decoding of vms error message for MULTINET.
+ *	7-DEC-1993 Bjorn S. Nilsson, ALEPH, CERN, VMS UCX ioctl() changes
+ *			(done of Mosaic)
+ *	19 Feb 94  Danny Mayer	Added Bjorn Fixes to Lynx version
+ *	 7 Mar 94  Danny Mayer	Added Fix UCX version for full domain name
+ *	20 May 94  Andy Harper	Added support for CMU TCP/IP transport
+ *	17 Nov 94  Andy Harper	Added support for SOCKETSHR transport
+ *	16 Jul 95  S. Bjorndahl added kluge to deal with LIBCMU bug
+ */
 
 #include <HTUtils.h>
 #include <HTParse.h>
@@ -36,15 +36,18 @@
 #include <netdb.h>
 #endif /* __DJGPP__ */
 
+#define LYNX_ADDRINFO	struct addrinfo
+#define LYNX_HOSTENT	struct hostent
+
 #define OK_HOST(p) ((p) != 0 && ((p)->h_length) != 0)
 
 #ifdef SVR4_BSDSELECT
-PUBLIC int BSDselect PARAMS((
-	int		 nfds,
-	fd_set *	 readfds,
-	fd_set *	 writefds,
-	fd_set *	 exceptfds,
-	struct timeval * select_timeout));
+int BSDselect(int nfds,
+	      fd_set * readfds,
+	      fd_set * writefds,
+	      fd_set * exceptfds,
+	      struct timeval *select_timeout);
+
 #ifdef select
 #undef select
 #endif /* select */
@@ -60,40 +63,40 @@
 #include <LYLeaks.h>
 
 /*
-**  Module-Wide variables
-*/
-PRIVATE char *hostname = NULL;		/* The name of this host */
+ *  Module-Wide variables
+ */
+static char *hostname = NULL;	/* The name of this host */
 
 /*
-**  PUBLIC VARIABLES
-*/
+ *  PUBLIC VARIABLES
+ */
 #ifdef SOCKS
-PUBLIC unsigned long socks_bind_remoteAddr; /* for long Rbind */
+unsigned long socks_bind_remoteAddr;	/* for long Rbind */
 #endif /* SOCKS */
 
-/* PUBLIC SockA HTHostAddress; */	/* The internet address of the host */
+/* PUBLIC SockA HTHostAddress; *//* The internet address of the host */
 					/* Valid after call to HTHostName() */
 
 /*	Encode INET status (as in sys/errno.h)			  inet_status()
-**	------------------
-**
-**  On entry,
-**	where		gives a description of what caused the error
-**	global errno	gives the error number in the Unix way.
-**
-**  On return,
-**	returns		a negative status in the Unix way.
-*/
+ *	------------------
+ *
+ *  On entry,
+ *	where		gives a description of what caused the error
+ *	global errno	gives the error number in the Unix way.
+ *
+ *  On return,
+ *	returns		a negative status in the Unix way.
+ */
 
 #ifdef DECL_SYS_ERRLIST
-extern char *sys_errlist[];		/* see man perror on cernvax */
+extern char *sys_errlist[];	/* see man perror on cernvax */
 extern int sys_nerr;
 #endif /* DECL_SYS_ERRLIST */
 
 #ifdef __DJGPP__
-static int ResolveYield (void)
+static int ResolveYield(void)
 {
-    return HTCheckForInterrupt() ? 0 : 1;
+    return HTCheckForInterrupt()? 0 : 1;
 }
 #endif
 
@@ -101,38 +104,39 @@
  * This chunk of code is used in both win32 and cygwin.
  */
 #if defined(_WINDOWS_NSL)
-static char host[512];
-static struct hostent *phost; /* Pointer to host - See netdb.h */
+static LYNX_HOSTENT *phost;	/* Pointer to host - See netdb.h */
 static int donelookup;
 
-static unsigned long _fork_func (void *arglist GCC_UNUSED)
+static unsigned long __stdcall _fork_func(void *arg)
 {
+    const char *host = (const char *) arg;
+
 #ifdef SH_EX
     unsigned long addr;
-    addr = (unsigned long)inet_addr(host);
-    if ((int)addr != -1)
-	phost = gethostbyaddr((char *)&addr, sizeof (addr), AF_INET);
+
+    addr = (unsigned long) inet_addr(host);
+    if (addr != INADDR_NONE)
+	phost = gethostbyaddr((char *) &addr, sizeof(addr), AF_INET);
     else
 	phost = gethostbyname(host);
 #else
     phost = gethostbyname(host);
 #endif
     donelookup = TRUE;
-    return (unsigned long)(phost);
+    return (unsigned long) (phost);
 }
 #endif /* _WINDOWS_NSL */
 
 #if defined(VMS) && defined(UCX)
 /*
-**  A routine to mimic the ioctl function for UCX.
-**  Bjorn S. Nilsson, 25-Nov-1993. Based on an example in the UCX manual.
-*/
+ *  A routine to mimic the ioctl function for UCX.
+ *  Bjorn S. Nilsson, 25-Nov-1993. Based on an example in the UCX manual.
+ */
 #include <HTioctl.h>
 
-PUBLIC int HTioctl ARGS3(
-	int,		d,
-	int,		request,
-	int *,		argp)
+int HTioctl(int d,
+	    int request,
+	    int *argp)
 {
     int sdc, status;
     unsigned short fun, iosb[4];
@@ -147,25 +151,26 @@
 	struct comm *addr;
     } ioctl_desc;
 
-    if ((sdc = vaxc$get_sdc (d)) == 0) {
+    if ((sdc = vaxc$get_sdc(d)) == 0) {
 	set_errno(EBADF);
 	return -1;
     }
-    ioctl_desc.opt  = UCX$C_IOCTL;
-    ioctl_desc.len  = sizeof(struct comm);
+    ioctl_desc.opt = UCX$C_IOCTL;
+    ioctl_desc.len = sizeof(struct comm);
+
     ioctl_desc.addr = &ioctl_comm;
     if (request & IOC_OUT) {
 	fun = IO$_SENSEMODE;
 	p5 = 0;
-	p6 = (char *)&ioctl_desc;
+	p6 = (char *) &ioctl_desc;
     } else {
 	fun = IO$_SETMODE;
-	p5 = (char *)&ioctl_desc;
+	p5 = (char *) &ioctl_desc;
 	p6 = 0;
     }
     ioctl_comm.command = request;
-    ioctl_comm.addr = (char *)argp;
-    status = sys$qiow (0, sdc, fun, iosb, 0, 0, 0, 0, 0, 0, p5, p6);
+    ioctl_comm.addr = (char *) argp;
+    status = sys$qiow(0, sdc, fun, iosb, 0, 0, 0, 0, 0, 0, p5, p6);
     if (!(status & 01)) {
 	set_errno(status);
 	return -1;
@@ -182,13 +187,13 @@
 	   /* third arg is transport/platform specific */
 
 /*	Report Internet Error
-**	---------------------
-*/
-PUBLIC int HTInetStatus ARGS1(
-	char *,		where)
+ *	---------------------
+ */
+int HTInetStatus(const char *where)
 {
     int status;
     int saved_errno = errno;
+
 #ifdef VMS
 #ifdef MULTINET
     SOCKET_ERRNO = vmserrno;
@@ -196,43 +201,43 @@
 #endif /* VMS */
 
 #ifdef VM
-    CTRACE((tfp, MY_FORMAT, SOCKET_ERRNO,  where,
-	   "(Error number not translated)"));	/* What Is the VM equiv? */
+    CTRACE((tfp, MY_FORMAT, SOCKET_ERRNO, where,
+	    "(Error number not translated)"));	/* What Is the VM equiv? */
 #define ER_NO_TRANS_DONE
 #endif /* VM */
 
 #ifdef VMS
 #ifdef MULTINET
-    CTRACE((tfp, MY_FORMAT, SOCKET_ERRNO,  where,
-	   vms_errno_string()));
+    CTRACE((tfp, MY_FORMAT, SOCKET_ERRNO, where,
+	    vms_errno_string()));
 #else
-    CTRACE((tfp, MY_FORMAT, SOCKET_ERRNO,  where,
-	   ((SOCKET_ERRNO > 0 && SOCKET_ERRNO <= 65) ?
-	    strerror(SOCKET_ERRNO) : "(Error number not translated)")));
+    CTRACE((tfp, MY_FORMAT, SOCKET_ERRNO, where,
+	    ((SOCKET_ERRNO > 0 && SOCKET_ERRNO <= 65) ?
+	     strerror(SOCKET_ERRNO) : "(Error number not translated)")));
 #endif /* MULTINET */
 #define ER_NO_TRANS_DONE
 #endif /* VMS */
 
 #ifdef HAVE_STRERROR
-    CTRACE((tfp, MY_FORMAT, SOCKET_ERRNO,  where,
-	   strerror(SOCKET_ERRNO)));
+    CTRACE((tfp, MY_FORMAT, SOCKET_ERRNO, where,
+	    strerror(SOCKET_ERRNO)));
 #define ER_NO_TRANS_DONE
 #endif /* HAVE_STRERROR */
 
 #ifndef ER_NO_TRANS_DONE
-    CTRACE((tfp, MY_FORMAT, SOCKET_ERRNO,  where,
-	   (SOCKET_ERRNO < sys_nerr ?
-	    sys_errlist[SOCKET_ERRNO] : "Unknown error" )));
+    CTRACE((tfp, MY_FORMAT, SOCKET_ERRNO, where,
+	    (SOCKET_ERRNO < sys_nerr ?
+	     sys_errlist[SOCKET_ERRNO] : "Unknown error")));
 #endif /* !ER_NO_TRANS_DONE */
 
 #ifdef VMS
 #ifndef MULTINET
     CTRACE((tfp,
-	   "         Unix error number (SOCKET_ERRNO) = %ld dec\n",
-	   SOCKET_ERRNO));
+	    "         Unix error number (SOCKET_ERRNO) = %ld dec\n",
+	    SOCKET_ERRNO));
     CTRACE((tfp,
-	   "         VMS error (vaxc$errno)    = %lx hex\n",
-	   vaxc$errno));
+	    "         VMS error (vaxc$errno)    = %lx hex\n",
+	    vaxc$errno));
 #endif /* MULTINET */
 #endif /* VMS */
 
@@ -240,8 +245,8 @@
 
 #ifdef VMS
     /*
-    **	uerrno and errno happen to be zero if vmserrno <> 0
-    */
+     * uerrno and errno happen to be zero if vmserrno <> 0
+     */
 #ifdef MULTINET
     status = -vmserrno;
 #else
@@ -254,95 +259,96 @@
 }
 
 /*	Parse a cardinal value				       parse_cardinal()
-**	----------------------
-**
-** On entry,
-**	*pp	    points to first character to be interpreted, terminated by
-**		    non 0:9 character.
-**	*pstatus    points to status already valid
-**	maxvalue    gives the largest allowable value.
-**
-** On exit,
-**	*pp	    points to first unread character
-**	*pstatus    points to status updated iff bad
-*/
-PUBLIC unsigned int HTCardinal ARGS3(
-	int *,		pstatus,
-	char **,	pp,
-	unsigned int,	max_value)
+ *	----------------------
+ *
+ * On entry,
+ *	*pp	    points to first character to be interpreted, terminated by
+ *		    non 0:9 character.
+ *	*pstatus    points to status already valid
+ *	maxvalue    gives the largest allowable value.
+ *
+ * On exit,
+ *	*pp	    points to first unread character
+ *	*pstatus    points to status updated iff bad
+ */
+unsigned int HTCardinal(int *pstatus,
+			char **pp,
+			unsigned int max_value)
 {
     unsigned int n;
-    if ((**pp<'0') || (**pp>'9')) {	    /* Null string is error */
-	*pstatus = -3;	/* No number where one expected */
+
+    if ((**pp < '0') || (**pp > '9')) {		/* Null string is error */
+	*pstatus = -3;		/* No number where one expected */
 	return 0;
     }
 
     n = 0;
     while ((**pp >= '0') && (**pp <= '9'))
-	n = n*10 + *((*pp)++) - '0';
+	n = n * 10 + *((*pp)++) - '0';
 
     if (n > max_value) {
-	*pstatus = -4;	/* Cardinal outside range */
+	*pstatus = -4;		/* Cardinal outside range */
 	return 0;
     }
 
     return n;
 }
 
-#ifndef DECNET	/* Function only used below for a trace message */
+#ifndef DECNET			/* Function only used below for a trace message */
 /*	Produce a string for an Internet address
-**	----------------------------------------
-**
-**  On exit,
-**	returns a pointer to a static string which must be copied if
-**		it is to be kept.
-*/
-PUBLIC CONST char * HTInetString ARGS1(
-	SockA*,		soc_in)
+ *	----------------------------------------
+ *
+ *  On exit,
+ *	returns a pointer to a static string which must be copied if
+ *		it is to be kept.
+ */
+const char *HTInetString(SockA * soc_in)
 {
 #ifdef INET6
     static char hostbuf[MAXHOSTNAMELEN];
-    getnameinfo((struct sockaddr *)soc_in,
-	    SOCKADDR_LEN(soc_in),
-	    hostbuf, sizeof(hostbuf), NULL, 0, NI_NUMERICHOST);
+
+    getnameinfo((struct sockaddr *) soc_in,
+		SOCKADDR_LEN(soc_in),
+		hostbuf, sizeof(hostbuf), NULL, 0, NI_NUMERICHOST);
     return hostbuf;
 #else
     static char string[20];
+
     sprintf(string, "%d.%d.%d.%d",
-	    (int)*((unsigned char *)(&soc_in->sin_addr)+0),
-	    (int)*((unsigned char *)(&soc_in->sin_addr)+1),
-	    (int)*((unsigned char *)(&soc_in->sin_addr)+2),
-	    (int)*((unsigned char *)(&soc_in->sin_addr)+3));
+	    (int) *((unsigned char *) (&soc_in->sin_addr) + 0),
+	    (int) *((unsigned char *) (&soc_in->sin_addr) + 1),
+	    (int) *((unsigned char *) (&soc_in->sin_addr) + 2),
+	    (int) *((unsigned char *) (&soc_in->sin_addr) + 3));
     return string;
 #endif /* INET6 */
 }
 #endif /* !DECNET */
 
 /*	Check whether string is a valid Internet hostname - kw
-**	-------------------------------------------------
-**
-**  Checks whether
-**  - contains only valid chars for domain names (actually, the
-**    restrictions are somewhat relaxed),
-**  - no leading dots or empty segments,
-**  - no segment starts with '-' or '+' [this protects telnet command],
-**  - max. length of dot-separated segment <= 63 (RFC 1034,1035),
-**  - total length <= 254 (if it ends with dot) or 253 (otherwise)
-**     [an interpretation of RFC 1034,1035, although RFC 1123
-**      suggests 255 as limit - kw].
-**
-**  Note: user (before '@') and port (after ':') components from
-**      host part of URL should be already stripped (if appropriate)
-**      from the input string.
-**
-**  On exit,
-**	returns 1 if valid, otherwise 0.
-*/
-PUBLIC BOOL valid_hostname ARGS1(
-	char *,	name)
+ *	-------------------------------------------------
+ *
+ *  Checks whether
+ *  - contains only valid chars for domain names (actually, the
+ *    restrictions are somewhat relaxed),
+ *  - no leading dots or empty segments,
+ *  - no segment starts with '-' or '+' [this protects telnet command],
+ *  - max. length of dot-separated segment <= 63 (RFC 1034,1035),
+ *  - total length <= 254 (if it ends with dot) or 253 (otherwise)
+ *     [an interpretation of RFC 1034,1035, although RFC 1123
+ *      suggests 255 as limit - kw].
+ *
+ *  Note: user (before '@') and port (after ':') components from
+ *      host part of URL should be already stripped (if appropriate)
+ *      from the input string.
+ *
+ *  On exit,
+ *	returns 1 if valid, otherwise 0.
+ */
+BOOL valid_hostname(char *name)
 {
-    int i=1, iseg = 0;
+    int i = 1, iseg = 0;
     char *cp = name;
+
     if (!(name && *name))
 	return NO;
     for (; (*cp && i <= 253); cp++, i++) {
@@ -369,70 +375,69 @@
 
 #ifdef NSL_FORK
 /*
-**  Function to allow us to be killed with a normal signal (not
-**  SIGKILL), but don't go through normal libc exit() processing, which
-**  would screw up parent's stdio.  -BL
-*/
-PRIVATE void quench ARGS1(
-	int,	sig GCC_UNUSED)
+ *  Function to allow us to be killed with a normal signal (not
+ *  SIGKILL), but don't go through normal libc exit() processing, which
+ *  would screw up parent's stdio.  -BL
+ */
+static void quench(int sig GCC_UNUSED)
 {
     _exit(2);
 }
 #endif /* NSL_FORK */
 
-PUBLIC int lynx_nsl_status = HT_OK;
+int lynx_nsl_status = HT_OK;
 
 #define DEBUG_HOSTENT		/* disable in case of problems */
-#define DEBUG_HOSTENT_CHILD  /* for NSL_FORK, may screw up trace file */
+#define DEBUG_HOSTENT_CHILD	/* for NSL_FORK, may screw up trace file */
 
 /*
-**  Two auxiliary functions for name lookup and struct hostent.
-**
-**  dump_hostent - dumps the contents of a struct hostent to the
-**  trace log or stderr, including all pointer values, strings, and
-**  addresses, in a format inspired by gdb's print format. - kw
-*/
-PRIVATE void dump_hostent ARGS2(
-    CONST char *,		msgprefix,
-    CONST struct hostent *,	phost)
+ *  Two auxiliary functions for name lookup and LYNX_HOSTENT.
+ *
+ *  dump_hostent - dumps the contents of a LYNX_HOSTENT to the
+ *  trace log or stderr, including all pointer values, strings, and
+ *  addresses, in a format inspired by gdb's print format. - kw
+ */
+static void dump_hostent(const char *msgprefix,
+			 const LYNX_HOSTENT *phost)
 {
     if (TRACE) {
 	int i;
 	char **pcnt;
-	CTRACE((tfp,"%s: %p ", msgprefix, phost));
+
+	CTRACE((tfp, "%s: %p ", msgprefix, phost));
 	if (phost) {
-	    CTRACE((tfp,"{ h_name = %p", phost->h_name));
+	    CTRACE((tfp, "{ h_name = %p", phost->h_name));
 	    if (phost->h_name) {
 		CTRACE((tfp, " \"%s\",", phost->h_name));
 	    } else {
 		CTRACE((tfp, ","));
 	    }
-	    CTRACE((tfp,"\n\t h_aliases = %p", phost->h_aliases));
+	    CTRACE((tfp, "\n\t h_aliases = %p", phost->h_aliases));
 	    if (phost->h_aliases) {
 		CTRACE((tfp, " {"));
 		for (pcnt = phost->h_aliases; *pcnt; pcnt++) {
-		    CTRACE((tfp,"%s %p \"%s\"",
-			   (pcnt == phost->h_aliases ? " " : ", "),
-			   *pcnt, *pcnt));
+		    CTRACE((tfp, "%s %p \"%s\"",
+			    (pcnt == phost->h_aliases ? " " : ", "),
+			    *pcnt, *pcnt));
 		}
 		CTRACE((tfp, "%s0x0 },\n\t",
-		       (*phost->h_aliases ? ", " : " ")));
+			(*phost->h_aliases ? ", " : " ")));
 	    } else {
 		CTRACE((tfp, ",\n\t"));
 	    }
-	    CTRACE((tfp," h_addrtype = %d,", phost->h_addrtype));
-	    CTRACE((tfp," h_length = %d,\n\t", phost->h_length));
-	    CTRACE((tfp," h_addr_list = %p", phost->h_addr_list));
+	    CTRACE((tfp, " h_addrtype = %d,", phost->h_addrtype));
+	    CTRACE((tfp, " h_length = %d,\n\t", phost->h_length));
+	    CTRACE((tfp, " h_addr_list = %p", phost->h_addr_list));
 	    if (phost->h_addr_list) {
 		CTRACE((tfp, " {"));
 		for (pcnt = phost->h_addr_list; *pcnt; pcnt++) {
-		    CTRACE((tfp,"%s %p",
-			   (pcnt == phost->h_addr_list ? "" : ","),
-			   *pcnt));
+		    CTRACE((tfp, "%s %p",
+			    (pcnt == phost->h_addr_list ? "" : ","),
+			    *pcnt));
 		    for (i = 0; i < phost->h_length; i++) {
-			CTRACE((tfp, "%s%d%s", (i==0 ? " \"" : "."),
-			       (int)*((unsigned char *)(*pcnt)+i),
-			       (i+1 == phost->h_length ? "\"" : "")));
+			CTRACE((tfp, "%s%d%s", (i == 0 ? " \"" : "."),
+				(int) *((unsigned char *) (*pcnt) + i),
+				(i + 1 == phost->h_length ? "\"" : "")));
 		    }
 		}
 		if (*phost->h_addr_list) {
@@ -444,34 +449,33 @@
 		CTRACE((tfp, "}"));
 	    }
 	}
-	CTRACE((tfp,"\n"));
+	CTRACE((tfp, "\n"));
 	fflush(tfp);
     }
 }
 
 /*
-**  fill_rehostent - copies as much as possible relevant content from
-**  the struct hostent pointed to by phost to the char buffer given
-**  by rehostent, subject to maximum output length rehostentsize,
-**  following pointers and building self-contained output which can be
-**  cast to a struct hostent. - kw
-**  See also description of LYGetHostByName.
-*/
+ *  fill_rehostent - copies as much as possible relevant content from
+ *  the LYNX_HOSTENT pointed to by phost to the char buffer given
+ *  by rehostent, subject to maximum output length rehostentsize,
+ *  following pointers and building self-contained output which can be
+ *  cast to a LYNX_HOSTENT. - kw
+ *  See also description of LYGetHostByName.
+ */
 #ifdef NSL_FORK
 
-#define REHOSTENT_SIZE 128		/* not bigger than pipe buffer! */
+#define REHOSTENT_SIZE 128	/* not bigger than pipe buffer! */
 
 typedef struct {
-	struct hostent	h;
-	char		rest[REHOSTENT_SIZE];
-    } AlignedHOSTENT;
-
-PRIVATE size_t fill_rehostent ARGS3(
-    char *,			rehostent,
-    size_t,			rehostentsize,
-    CONST struct hostent *,	phost)
+    LYNX_HOSTENT h;
+    char rest[REHOSTENT_SIZE];
+} AlignedHOSTENT;
+
+static size_t fill_rehostent(char *rehostent,
+			     size_t rehostentsize,
+			     const LYNX_HOSTENT *phost)
 {
-    AlignedHOSTENT *data = (AlignedHOSTENT *)rehostent;
+    AlignedHOSTENT *data = (AlignedHOSTENT *) rehostent;
     int num_addrs = 0;
     int num_aliases = 0;
     char **pcnt;
@@ -479,7 +483,7 @@
     char **p_next_charptr;
     size_t name_len = 0;
     size_t required_per_addr;
-    size_t curlen = sizeof(struct hostent);
+    size_t curlen = sizeof(LYNX_HOSTENT);
     size_t available = rehostentsize - curlen;
     size_t chk_available, mem_this_alias, required_this_alias;
     int i_addr, i_alias;
@@ -487,6 +491,7 @@
     if (!phost)
 	return 0;
     required_per_addr = phost->h_length + sizeof(char *);
+
     if (phost->h_addr_list)
 	available -= sizeof(phost->h_addr_list[0]);
     if (phost->h_aliases)
@@ -510,7 +515,7 @@
 	}
     }
     if (num_addrs) {
-	for (pcnt=phost->h_addr_list+1; *pcnt; pcnt++) {
+	for (pcnt = phost->h_addr_list + 1; *pcnt; pcnt++) {
 	    if (available >= required_per_addr) {
 		num_addrs++;
 		available -= required_per_addr;
@@ -521,7 +526,7 @@
     }
     chk_available = available;
     if (phost->h_aliases) {
-	for (pcnt=phost->h_aliases; *pcnt; pcnt++) {
+	for (pcnt = phost->h_aliases; *pcnt; pcnt++) {
 	    required_this_alias = sizeof(phost->h_aliases[0]) +
 		strlen(*pcnt) + 1;
 	    if (chk_available >= required_this_alias) {
@@ -533,16 +538,16 @@
 
     data->h.h_addrtype = phost->h_addrtype;
     data->h.h_length = phost->h_length;
-    p_next_charptr = (char **)(rehostent + curlen);
+    p_next_charptr = (char **) (rehostent + curlen);
     p_next_char = rehostent + curlen;
     if (phost->h_addr_list)
-	p_next_char += (num_addrs+1) * sizeof(phost->h_addr_list[0]);
+	p_next_char += (num_addrs + 1) * sizeof(phost->h_addr_list[0]);
     if (phost->h_aliases)
-	p_next_char += (num_aliases+1) * sizeof(phost->h_aliases[0]);
+	p_next_char += (num_aliases + 1) * sizeof(phost->h_aliases[0]);
 
     if (phost->h_addr_list) {
 	data->h.h_addr_list = p_next_charptr;
-	for (pcnt=phost->h_addr_list, i_addr = 0;
+	for (pcnt = phost->h_addr_list, i_addr = 0;
 	     i_addr < num_addrs;
 	     pcnt++, i_addr++) {
 	    memcpy(p_next_char, *pcnt, sizeof(phost->h_addr_list[0]));
@@ -568,7 +573,7 @@
 
     if (phost->h_aliases) {
 	data->h.h_aliases = p_next_charptr;
-	for (pcnt=phost->h_aliases, i_alias = 0;
+	for (pcnt = phost->h_aliases, i_alias = 0;
 	     (*pcnt && i_alias < num_addrs);
 	     pcnt++, i_alias++) {
 	    mem_this_alias = strlen(*pcnt) + 1;
@@ -587,7 +592,7 @@
     } else {
 	data->h.h_aliases = NULL;
     }
-    curlen = p_next_char - (char *)rehostent;
+    curlen = p_next_char - (char *) rehostent;
     return curlen;
 }
 #endif /* NSL_FORK */
@@ -596,77 +601,74 @@
 #undef  h_errno
 #define h_errno my_errno
 static int my_errno;
+
 #else /* we do HAVE_H_ERRNO: */
-#ifndef h_errno		/* there may be a macro as well as the extern data */
+#ifndef h_errno			/* there may be a macro as well as the extern data */
 extern int h_errno;
 #endif
 #endif
 
 /*	Resolve an internet hostname, like gethostbyname
-**	------------------------------------------------
-**
-**  On entry,
-**	str	points to the given host name, not numeric address,
-**		without colon or port number.
-**
-**  On exit,
-**	returns a pointer to a struct hostent in static storage,
-**	or NULL in case of error or user interruption.
-**
-**  The interface is intended to be exactly the same as for (Unix)
-**  gethostbyname(), except for the following:
-**
-**  If NSL_FORK is not used, the result of gethostbyname is returned
-**  directly.  Otherwise:
-**  All lists, addresses, and strings referred to by pointers in the
-**  returned struct are located, together with the returned struct
-**  itself, in a buffer of size REHOSTENT_SIZE.  If not everything fits,
-**  some info is omitted, but the function is careful to still return
-**  a valid structure, without truncating strings; it tries to return,
-**  in order of decreasing priority, the first address (h_addr), the
-**  official name (h_name), the additional addresses, then alias names.
-**
-**  If NULL is returned, the reason is made available in the global
-**  variable lynx_nsl_status, with one of the following values:
-**	HT_INTERRUPTED		Interrupted by user
-**	HT_NOT_ACCEPTABLE	Hostname detected as invalid
-**				(also sets h_errno)
-**	HT_H_ERRNO_VALID	An error occurred, and h_errno holds
-**				an appropriate value
-**	HT_ERROR		Resolver error, reason not known
-**	HT_INTERNAL		Internal error
-*/
-PUBLIC struct hostent * LYGetHostByName ARGS1(
-	char *,	str)
+ *	------------------------------------------------
+ *
+ *  On entry,
+ *	str	points to the given host name, not numeric address,
+ *		without colon or port number.
+ *
+ *  On exit,
+ *	returns a pointer to a LYNX_HOSTENT in static storage,
+ *	or NULL in case of error or user interruption.
+ *
+ *  The interface is intended to be exactly the same as for (Unix)
+ *  gethostbyname(), except for the following:
+ *
+ *  If NSL_FORK is not used, the result of gethostbyname is returned
+ *  directly.  Otherwise:
+ *  All lists, addresses, and strings referred to by pointers in the
+ *  returned struct are located, together with the returned struct
+ *  itself, in a buffer of size REHOSTENT_SIZE.  If not everything fits,
+ *  some info is omitted, but the function is careful to still return
+ *  a valid structure, without truncating strings; it tries to return,
+ *  in order of decreasing priority, the first address (h_addr), the
+ *  official name (h_name), the additional addresses, then alias names.
+ *
+ *  If NULL is returned, the reason is made available in the global
+ *  variable lynx_nsl_status, with one of the following values:
+ *	HT_INTERRUPTED		Interrupted by user
+ *	HT_NOT_ACCEPTABLE	Hostname detected as invalid
+ *				(also sets h_errno)
+ *	HT_H_ERRNO_VALID	An error occurred, and h_errno holds
+ *				an appropriate value
+ *	HT_ERROR		Resolver error, reason not known
+ *	HT_INTERNAL		Internal error
+ */
+LYNX_HOSTENT *LYGetHostByName(char *str)
 {
-#ifndef _WINDOWS_NSL
     char *host = str;
-#endif
 
 #ifdef NSL_FORK
     /* for transfer of result between from child to parent: */
     static AlignedHOSTENT aligned_full_rehostent;
+
     /*
-     * We could define rehosten directly as a
-     * static char rehostent[REHOSTENT_SIZE],
-     * but the indirect approach via the above struct
-     * should automatically take care of alignment requirements.
+     * We could define rehosten directly as a static char
+     * rehostent[REHOSTENT_SIZE], but the indirect approach via the above
+     * struct should automatically take care of alignment requirements.
      * Note that, in addition,
-     *  - this must be static, as we shall return a pointer to it
-     *    which must remain valid, and
-     *  - we have to use the same rehostent in the child process as
-     *    in the parent (its address in the parent's address space
-     *    must be the same as in the child's, otherwise the internal
-     *    pointers built by the child's call to fill_rehostent would
-     *    be invalid when seen by the parent). - kw
+     * - this must be static, as we shall return a pointer to it which must
+     *   remain valid, and
+     * - we have to use the same rehostent in the child process as in the
+     *   parent (its address in the parent's address space must be the same as
+     *   in the child's, otherwise the internal pointers built by the child's
+     *   call to fill_rehostent would be invalid when seen by the parent).  -kw
      */
-    char *rehostent = (char *)&aligned_full_rehostent;
+    char *rehostent = (char *) &aligned_full_rehostent;
 
     /* for transfer of status from child to parent: */
     struct _statuses {
 	size_t rehostentlen;
 	int h_length;
-	int child_errno;  /* sometimes useful to pass this on */
+	int child_errno;	/* sometimes useful to pass this on */
 	int child_h_errno;
 	BOOL h_errno_valid;
     } statuses;
@@ -674,7 +676,7 @@
     size_t rehostentlen = 0;
 #endif /* NSL_FORK */
 
-    struct hostent *result_phost = NULL;
+    LYNX_HOSTENT *result_phost = NULL;
 
 #ifdef __DJGPP__
     _resolve_hook = ResolveYield;
@@ -687,17 +689,13 @@
     }
     CTRACE((tfp, "LYGetHostByName: parsing `%s'.\n", str));
 
-	/*  Could disable this if all our callers already check - kw */
+    /*  Could disable this if all our callers already check - kw */
     if (HTCheckForInterrupt()) {
 	CTRACE((tfp, "LYGetHostByName: INTERRUPTED for '%s'.\n", str));
 	lynx_nsl_status = HT_INTERRUPTED;
 	return NULL;
     }
 
-#ifdef _WINDOWS_NSL
-    strncpy(host, str, sizeof(host));
-#endif /*  _WINDOWS_NSL */
-
     if (!valid_hostname(host)) {
 	lynx_nsl_status = HT_NOT_ACCEPTABLE;
 #ifdef NO_RECOVERY
@@ -709,53 +707,54 @@
 #endif
 	return NULL;
     }
-
-#ifdef MVS	/* Outstanding problem with crash in MVS gethostbyname */
+#ifdef MVS			/* Outstanding problem with crash in MVS gethostbyname */
     CTRACE((tfp, "LYGetHostByName: Calling gethostbyname(%s)\n", host));
 #endif /* MVS */
 
-    CTRACE_FLUSH(tfp);  /* so child messages will not mess up parent log */
+    CTRACE_FLUSH(tfp);		/* so child messages will not mess up parent log */
 
     lynx_nsl_status = HT_INTERNAL;	/* should be set to something else below */
 
 #ifdef NSL_FORK
     statuses.h_errno_valid = NO;
-	/*
-	**  Start block for fork-based gethostbyname() with
-	**  checks for interrupts. - Tom Zerucha (tz@execpc.com) & FM
-	*/
+    /*
+     * Start block for fork-based gethostbyname() with checks for interrupts. 
+     * - Tom Zerucha (tz@execpc.com) & FM
+     */
     {
 	int got_rehostent = 0;
+
 #if HAVE_SIGACTION
 	sigset_t old_sigset;
 	sigset_t new_sigset;
 #endif
 	/*
-	**	Pipe, child pid, status buffers, start time, select()
-	**	control variables.
-	*/
+	 * Pipe, child pid, status buffers, start time, select() control
+	 * variables.
+	 */
 	int fpid, waitret;
 	int pfd[2], selret, readret;
+
 #ifdef HAVE_TYPE_UNIONWAIT
 	union wait waitstat;
+
 #else
 	int waitstat = 0;
 #endif
-	time_t start_time = time((time_t *)0);
+	time_t start_time = time((time_t *) 0);
 	fd_set readfds;
 	struct timeval one_second;
-	long dns_patience = 30; /* how many seconds will we wait for DNS? */
+	long dns_patience = 30;	/* how many seconds will we wait for DNS? */
 	int child_exited = 0;
 
-	    /*
-	    **  Reap any children that have terminated since last time
-	    **  through.  This might include children that we killed,
-	    **  then waited with WNOHANG before they were actually ready
-	    **  to be reaped.  (Should be max of 1 in this state, but
-	    **  the loop is safe if waitpid() is implemented correctly:
-	    **  returns 0 when children exist but none have exited; -1
-	    **  with errno == ECHILD when no children.)  -BL
-	    */
+	/*
+	 * Reap any children that have terminated since last time through. 
+	 * This might include children that we killed, then waited with WNOHANG
+	 * before they were actually ready to be reaped.  (Should be max of 1
+	 * in this state, but the loop is safe if waitpid() is implemented
+	 * correctly:  returns 0 when children exist but none have exited; -1
+	 * with errno == ECHILD when no children.) -BL
+	 */
 	do {
 	    waitret = waitpid(-1, 0, WNOHANG);
 	} while (waitret > 0 || (waitret == -1 && errno == EINTR));
@@ -765,14 +764,13 @@
 
 #if HAVE_SIGACTION
 	/*
-	 *  Attempt to prevent a rare situation where the child
-	 *  could execute the Lynx signal handlers because it gets
-	 *  killed before it even has a chance to reset its handlers,
-	 *  resulting in bogus 'Exiting via interrupt' message and
-	 *  screen corruption or worse.
-	 *  Should that continue to be reported, for systems without
-	 *  sigprocmask(), we need to find a different solutions for
-	 *  those. - kw 19990430
+	 * Attempt to prevent a rare situation where the child could execute
+	 * the Lynx signal handlers because it gets killed before it even has a
+	 * chance to reset its handlers, resulting in bogus 'Exiting via
+	 * interrupt' message and screen corruption or worse.
+	 * Should that continue to be reported, for systems without
+	 * sigprocmask(), we need to find a different solutions for those.  -
+	 * kw 19990430
 	 */
 	sigemptyset(&new_sigset);
 	sigaddset(&new_sigset, SIGTERM);
@@ -789,22 +787,22 @@
 	sigprocmask(SIG_BLOCK, &new_sigset, &old_sigset);
 #endif /* HAVE_SIGACTION */
 
-	if ((fpid = fork()) == 0 ) {
-	    struct hostent  *phost;	/* Pointer to host - See netdb.h */
+	if ((fpid = fork()) == 0) {
+	    LYNX_HOSTENT *phost;	/* Pointer to host - See netdb.h */
+
 	    /*
-	    **  Child - for the long call.
-	    **
-	    **  Make sure parent can kill us at will.  -BL
-	    */
+	     * Child - for the long call.
+	     *
+	     * Make sure parent can kill us at will.  -BL
+	     */
 	    (void) signal(SIGTERM, quench);
 
 	    /*
-	    **  Also make sure the child does not run one of the
-	    **  signal handlers that may have been installed by
-	    **  Lynx if one of those signals occurs.  For example
-	    **  we don't want the child to remove temp files on
-	    **  ^C, let the parent deal with that. - kw
-	    */
+	     * Also make sure the child does not run one of the signal handlers
+	     * that may have been installed by Lynx if one of those signals
+	     * occurs.  For example we don't want the child to remove temp
+	     * files on ^C, let the parent deal with that.  - kw
+	     */
 	    (void) signal(SIGINT, quench);
 #ifndef NOSIGHUP
 	    (void) signal(SIGHUP, quench);
@@ -832,8 +830,8 @@
 #endif /* HAVE_SIGACTION */
 
 	    /*
-	    **  Child won't use read side.  -BL
-	    */
+	     * Child won't use read side.  -BL
+	     */
 	    close(pfd[0]);
 #ifdef HAVE_H_ERRNO
 	    /* to detect cases when it doesn't get set although it should */
@@ -856,80 +854,79 @@
 	    if (OK_HOST(phost)) {
 		rehostentlen = fill_rehostent(rehostent, REHOSTENT_SIZE, phost);
 #ifdef DEBUG_HOSTENT_CHILD
-		dump_hostent("CHILD fill_rehostent", (struct hostent *)rehostent);
+		dump_hostent("CHILD fill_rehostent", (LYNX_HOSTENT *) rehostent);
 #endif
 	    }
-	    if (rehostentlen <= sizeof(struct hostent) ||
-		!OK_HOST((struct hostent *)rehostent)) {
+	    if (rehostentlen <= sizeof(LYNX_HOSTENT) ||
+		!OK_HOST((LYNX_HOSTENT *) rehostent)) {
 		rehostentlen = 0;
 		statuses.h_length = 0;
 	    } else {
-		statuses.h_length = ((struct hostent *)rehostent)->h_length;
+		statuses.h_length = ((LYNX_HOSTENT *) rehostent)->h_length;
 #ifdef HAVE_H_ERRNO
-		if (h_errno == -2) /* success, but h_errno unchanged? */
+		if (h_errno == -2)	/* success, but h_errno unchanged? */
 		    statuses.h_errno_valid = NO;
 #endif
 	    }
 	    /*
-	    **  Send variables indicating status of lookup to parent.
-	    **  That includes rehostentlen, which the parent will use
-	    **  as the size for the second read (if > 0).
-	    */
+	     * Send variables indicating status of lookup to parent.  That
+	     * includes rehostentlen, which the parent will use as the size for
+	     * the second read (if > 0).
+	     */
 	    if (!statuses.child_errno)
-	    statuses.child_errno = errno;
+		statuses.child_errno = errno;
 	    statuses.rehostentlen = rehostentlen;
 	    write(pfd[1], &statuses, sizeof(statuses));
 
-
 	    if (rehostentlen) {
 		/*
-		**  Return our resulting rehostent through pipe...
-		*/
+		 * Return our resulting rehostent through pipe...
+		 */
 		write(pfd[1], rehostent, rehostentlen);
 		_exit(0);
 	    } else {
 		/*
-		**  ... or return error as exit code.
-		*/
+		 * ...  or return error as exit code.
+		 */
 		_exit(1);
 	    }
 	}
-
 #if HAVE_SIGACTION
 	/*
-	**  (parent) Restore signal mask to whatever it was
-	**  before the fork. - kw
-	*/
+	 * (parent) Restore signal mask to whatever it was before the fork.  -
+	 * kw
+	 */
 	sigprocmask(SIG_SETMASK, &old_sigset, NULL);
 #endif /* HAVE_SIGACTION */
 
 	/*
-	**	(parent) Wait until lookup finishes, or interrupt,
-	**	or cycled too many times (just in case) -BL
-	*/
+	 * (parent) Wait until lookup finishes, or interrupt, or cycled too
+	 * many times (just in case) -BL
+	 */
 
-	close(pfd[1]);      /* parent won't use write side -BL */
+	close(pfd[1]);		/* parent won't use write side -BL */
 
-	if (fpid < 0) {     /* fork failed */
-		close(pfd[0]);
-		goto failed;
+	if (fpid < 0) {		/* fork failed */
+	    close(pfd[0]);
+	    goto failed;
 	}
 
-	while (child_exited || (long)(time((time_t *)0) - start_time) < dns_patience) {
+	while (child_exited || (long) (time((time_t *) 0) - start_time) < dns_patience) {
 
 	    FD_ZERO(&readfds);
 	    /*
-	    **  This allows us to abort immediately, not after 1-second
-	    **  timeout, when user hits abort key.  Can't do this when
-	    **  using SLANG (or at least I don't know how), so SLANG
-	    **  users must live with up-to-1s timeout.  -BL
-	    **
-	    **  Whoops -- we need to make sure stdin is actually
-	    **  selectable!  /dev/null isn't, on some systems, which
-	    **  makes some useful Lynx invocations fail.  -BL
-	    */
+	     * This allows us to abort immediately, not after 1-second timeout,
+	     * when user hits abort key.  Can't do this when using SLANG (or at
+	     * least I don't know how), so SLANG users must live with up-to-1s
+	     * timeout.  -BL
+	     *
+	     * Whoops -- we need to make sure stdin is actually selectable! 
+	     * /dev/null isn't, on some systems, which makes some useful Lynx
+	     * invocations fail.  -BL
+	     */
 	    {
 		int kbd_fd = LYConsoleInputFD(TRUE);
+
 		if (kbd_fd != INVSOC) {
 		    FD_SET(kbd_fd, &readfds);
 		}
@@ -939,22 +936,22 @@
 	    one_second.tv_usec = 0;
 	    FD_SET(pfd[0], &readfds);
 
-		/*
-		**  Return when data received, interrupted, or failed.
-		**  If nothing is waiting, we sleep for 1 second in
-		**  select(), to be nice to the system.  -BL
-		*/
+	    /*
+	     * Return when data received, interrupted, or failed.  If nothing
+	     * is waiting, we sleep for 1 second in select(), to be nice to the
+	     * system.  -BL
+	     */
 #ifdef SOCKS
 	    if (socks_flag)
-		selret = Rselect(pfd[0] + 1, (void *)&readfds, NULL, NULL, &one_second);
+		selret = Rselect(pfd[0] + 1, &readfds, NULL, NULL, &one_second);
 	    else
 #endif /* SOCKS */
-		selret = select(pfd[0] + 1, (void *)&readfds, NULL, NULL, &one_second);
+		selret = select(pfd[0] + 1, &readfds, NULL, NULL, &one_second);
 
 	    if ((selret > 0) && FD_ISSET(pfd[0], &readfds)) {
 		/*
-		**	First get status, including length of address.  -BL, kw
-		*/
+		 * First get status, including length of address.  -BL, kw
+		 */
 		readret = read(pfd[0], &statuses, sizeof(statuses));
 		if (readret == sizeof(statuses)) {
 		    h_errno = statuses.child_h_errno;
@@ -963,51 +960,50 @@
 		    if (statuses.h_errno_valid) {
 			lynx_nsl_status = HT_H_ERRNO_VALID;
 			/*
-			 *  If something went wrong in the child process
-			 *  other than normal lookup errors, and it appears
-			 *  that we have enough info to know what went wrong,
-			 *  generate diagnostic output.
-			 *  ENOMEM observed on linux in processes constrained
-			 *  with ulimit.  It would be too unkind to abort
-			 *  the session, access to local files or through a
-			 *  proxy may still work. - kw
+			 * If something went wrong in the child process other
+			 * than normal lookup errors, and it appears that we
+			 * have enough info to know what went wrong, generate
+			 * diagnostic output.  ENOMEM observed on linux in
+			 * processes constrained with ulimit.  It would be too
+			 * unkind to abort the session, access to local files
+			 * or through a proxy may still work.  - kw
 			 */
 			if (
 #ifdef NETDB_INTERNAL		/* linux glibc: defined in netdb.h */
-			    (errno && h_errno == NETDB_INTERNAL) ||
+			       (errno && h_errno == NETDB_INTERNAL) ||
 #endif
-			    (errno == ENOMEM &&
-			     statuses.rehostentlen == 0 &&
-			     /* should probably be NETDB_INTERNAL if child
-				memory exhausted, but we may find that
-				h_errno remains unchanged. - kw */
-			     h_errno == -2)) {
+			       (errno == ENOMEM &&
+				statuses.rehostentlen == 0 &&
+			/* should probably be NETDB_INTERNAL if child
+			   memory exhausted, but we may find that
+			   h_errno remains unchanged. - kw */
+				h_errno == -2)) {
 #ifndef MULTINET
 			    HTInetStatus("CHILD gethostbyname");
 #endif
 			    HTAlert(LYStrerror(statuses.child_errno));
 			    if (errno == ENOMEM) {
 				/*
-				 *  Not much point in continuing, right?
-				 *  Fake a 'z', should shorten pointless
-				 *  guessing cycle. - kw
+				 * Not much point in continuing, right?  Fake a
+				 * 'z', should shorten pointless guessing
+				 * cycle.  - kw
 				 */
 				LYFakeZap(YES);
 			    }
 			}
 		    }
 #endif /* HAVE_H_ERRNO */
-		    if (statuses.rehostentlen > sizeof(struct hostent)) {
+		    if (statuses.rehostentlen > sizeof(LYNX_HOSTENT)) {
 			/*
-			**  Then get the full reorganized hostent.  -BL, kw
-			*/
+			 * Then get the full reorganized hostent.  -BL, kw
+			 */
 			readret = read(pfd[0], rehostent, statuses.rehostentlen);
 #ifdef DEBUG_HOSTENT
-			dump_hostent("Read from pipe", (struct hostent *)rehostent);
+			dump_hostent("Read from pipe", (LYNX_HOSTENT *) rehostent);
 #endif
 			if (readret == (int) statuses.rehostentlen) {
 			    got_rehostent = 1;
-			    result_phost = (struct hostent *)rehostent;
+			    result_phost = (LYNX_HOSTENT *) rehostent;
 			    lynx_nsl_status = HT_OK;
 			} else if (!statuses.h_errno_valid) {
 			    lynx_nsl_status = HT_INTERNAL;
@@ -1017,8 +1013,8 @@
 		    lynx_nsl_status = HT_ERROR;
 		}
 		/*
-		**  Make sure child is cleaned up.  -BL
-		*/
+		 * Make sure child is cleaned up.  -BL
+		 */
 		if (!child_exited)
 		    waitret = waitpid(fpid, &waitstat, WNOHANG);
 		if (!WIFEXITED(waitstat) && !WIFSIGNALED(waitstat)) {
@@ -1029,28 +1025,28 @@
 	    }
 
 	    /*
-	    **  Clean up if child exited before & no data received.  -BL
-	    */
+	     * Clean up if child exited before & no data received.  -BL
+	     */
 	    if (child_exited) {
 		waitret = waitpid(fpid, &waitstat, WNOHANG);
 		break;
 	    }
 	    /*
-	    **  If child exited, loop once more looking for data.  -BL
-	    */
+	     * If child exited, loop once more looking for data.  -BL
+	     */
 	    if ((waitret = waitpid(fpid, &waitstat, WNOHANG)) > 0) {
 		/*
-		**	Data will be arriving right now, so make sure we
-		**	don't short-circuit out for too many loops, and
-		**	skip the interrupt check.  -BL
-		*/
+		 * Data will be arriving right now, so make sure we don't
+		 * short-circuit out for too many loops, and skip the interrupt
+		 * check.  -BL
+		 */
 		child_exited = 1;
 		continue;
 	    }
 
 	    /*
-	    **  Abort if interrupt key pressed.
-	    */
+	     * Abort if interrupt key pressed.
+	     */
 	    if (HTCheckForInterrupt()) {
 		CTRACE((tfp, "LYGetHostByName: INTERRUPTED gethostbyname.\n"));
 		kill(fpid, SIGTERM);
@@ -1067,20 +1063,24 @@
 	}
 	if (waitret > 0) {
 	    if (WIFEXITED(waitstat)) {
-		CTRACE((tfp, "LYGetHostByName: NSL_FORK child %d exited, status 0x%x.\n",
-			(int)waitret, WEXITSTATUS(waitstat)));
+		CTRACE((tfp,
+			"LYGetHostByName: NSL_FORK child %d exited, status 0x%x.\n",
+			(int) waitret, WEXITSTATUS(waitstat)));
 	    } else if (WIFSIGNALED(waitstat)) {
-		CTRACE((tfp, "LYGetHostByName: NSL_FORK child %d got signal, status 0x%x!\n",
-		       (int)waitret, WTERMSIG(waitstat)));
+		CTRACE((tfp,
+			"LYGetHostByName: NSL_FORK child %d got signal, status 0x%x!\n",
+			(int) waitret, WTERMSIG(waitstat)));
 #ifdef WCOREDUMP
 		if (WCOREDUMP(waitstat)) {
-		    CTRACE((tfp, "LYGetHostByName: NSL_FORK child %d dumped core!\n",
-			   (int)waitret));
+		    CTRACE((tfp,
+			    "LYGetHostByName: NSL_FORK child %d dumped core!\n",
+			    (int) waitret));
 		}
 #endif /* WCOREDUMP */
 	    } else if (WIFSTOPPED(waitstat)) {
-		CTRACE((tfp, "LYGetHostByName: NSL_FORK child %d is stopped, status 0x%x!\n",
-			(int)waitret, WSTOPSIG(waitstat)));
+		CTRACE((tfp,
+			"LYGetHostByName: NSL_FORK child %d is stopped, status 0x%x!\n",
+			(int) waitret, WSTOPSIG(waitstat)));
 	    }
 	}
 	if (!got_rehostent) {
@@ -1096,20 +1096,22 @@
 #ifndef __CYGWIN__
 	if (!system_is_NT) {	/* for Windows9x */
 	    unsigned long t;
-	    t = (unsigned long)inet_addr(host);
-	    if ((int)t != -1)
-		phost = gethostbyaddr((char *)&t, sizeof (t), AF_INET);
+
+	    t = (unsigned long) inet_addr(host);
+	    if (t != INADDR_NONE)
+		phost = gethostbyaddr((char *) &t, sizeof(t), AF_INET);
 	    else
 		phost = gethostbyname(host);
 	} else {		/* for Windows NT */
 #endif /* !__CYGWIN__ */
-	    phost = (struct hostent *) NULL;
+	    phost = (LYNX_HOSTENT *) NULL;
 	    donelookup = FALSE;
-	    hThread = CreateThread((void *)NULL, 4096UL,
-		(LPTHREAD_START_ROUTINE)_fork_func,
-		(void *)NULL, 0UL, (unsigned long *)&dwThreadID);
+	    WSASetLastError(WSAHOST_NOT_FOUND);
+
+	    hThread = CreateThread(NULL, 4096UL, _fork_func, host, 0UL,
+				   (unsigned long *) &dwThreadID);
 	    if (!hThread)
-		MessageBox((void *)NULL, "CreateThread",
+		MessageBox(NULL, "CreateThread",
 			   "CreateThread Failed", 0L);
 
 	    while (!donelookup) {
@@ -1117,8 +1119,8 @@
 		    /* Note that host is a character array and is not freed */
 		    /* to avoid possible subthread problems: */
 		    if (!CloseHandle(hThread)) {
-			MessageBox((void *)NULL,
-				   "CloseHandle","CloseHandle Failed", 0L);
+			MessageBox((void *) NULL,
+				   "CloseHandle", "CloseHandle Failed", 0L);
 		    }
 		    lynx_nsl_status = HT_INTERRUPTED;
 		    return NULL;
@@ -1138,7 +1140,8 @@
 
 #else /* !NSL_FORK, !_WINDOWS_NSL: */
     {
-	struct hostent  *phost;
+	LYNX_HOSTENT *phost;
+
 	phost = gethostbyname(host);	/* See netdb.h */
 #ifdef MVS
 	CTRACE((tfp, "LYGetHostByName: gethostbyname() returned %d\n", phost));
@@ -1161,36 +1164,31 @@
 
     return result_phost;	/* OK */
 
-failed:
+  failed:
     CTRACE((tfp, "LYGetHostByName: Can't find internet node name `%s'.\n",
-		host));
+	    host));
     return NULL;
 }
 
-
 /*	Parse a network node address and port
-**	-------------------------------------
-**
-**  On entry,
-**	str	points to a string with a node name or number,
-**		with optional trailing colon and port number.
-**	soc_in	points to the binary internet or decnet address field.
-**
-**  On exit,
-**	*soc_in is filled in.  If no port is specified in str, that
-**		field is left unchanged in *soc_in.
-*/
+ *	-------------------------------------
+ *
+ *  On entry,
+ *	str	points to a string with a node name or number,
+ *		with optional trailing colon and port number.
+ *	soc_in	points to the binary internet or decnet address field.
+ *
+ *  On exit,
+ *	*soc_in is filled in.  If no port is specified in str, that
+ *		field is left unchanged in *soc_in.
+ */
 #ifndef INET6
-PRIVATE int HTParseInet ARGS2(
-	SockA *,	soc_in,
-	CONST char *,	str)
+static int HTParseInet(SockA * soc_in, const char *str)
 {
     char *port;
     int dotcount_ip = 0;	/* for dotted decimal IP addr */
     char *strptr;
-#ifndef _WINDOWS_NSL
     char *host = NULL;
-#endif /* _WINDOWS_NSL */
 
     if (!str) {
 	CTRACE((tfp, "HTParseInet: Can't parse `NULL'.\n"));
@@ -1201,30 +1199,27 @@
 	CTRACE((tfp, "HTParseInet: INTERRUPTED for '%s'.\n", str));
 	return -1;
     }
-#ifdef _WINDOWS_NSL
-    strncpy(host, str, sizeof(host));
-#else
     StrAllocCopy(host, str);	/* Make a copy we can mutilate */
-#endif /*  _WINDOWS_NSL */
     /*
-    **	Parse port number if present.
-    */
+     * Parse port number if present.
+     */
     if ((port = strchr(host, ':')) != NULL) {
 	*port++ = 0;		/* Chop off port */
 	strptr = port;
 	if (port[0] >= '0' && port[0] <= '9') {
 #ifdef UNIX
-	    soc_in->sin_port = (PortNumber)htons(strtol(port, &strptr, 10));
+	    soc_in->sin_port = (PortNumber) htons(strtol(port, &strptr, 10));
 #else /* VMS: */
 #ifdef DECNET
-	    soc_in->sdn_objnum = (unsigned char)(strtol(port, &strptr, 10));
+	    soc_in->sdn_objnum = (unsigned char) (strtol(port, &strptr, 10));
 #else
-	    soc_in->sin_port = htons((PortNumber)strtol(port, &strptr, 10));
+	    soc_in->sin_port = htons((PortNumber) strtol(port, &strptr, 10));
 #endif /* Decnet */
 #endif /* Unix vs. VMS */
-#ifdef SUPPRESS		/* 1. crashes!?!.  2. URL syntax has number not name */
+#ifdef SUPPRESS			/* 1. crashes!?!.  2. URL syntax has number not name */
 	} else {
-	    struct servent * serv = getservbyname(port, (char*)0);
+	    struct servent *serv = getservbyname(port, (char *) 0);
+
 	    if (serv) {
 		soc_in->sin_port = serv->s_port;
 	    } else {
@@ -1233,26 +1228,24 @@
 #endif /* SUPPRESS */
 	}
 	if (strptr && *strptr != '\0') {
-#ifndef _WINDOWS_NSL
 	    FREE(host);
-#endif /* _WINDOWS_NSL */
 	    HTAlwaysAlert(NULL, gettext("Address has invalid port"));
 	    return -1;
 	}
     }
-
 #ifdef DECNET
     /*
-    **	Read Decnet node name. @@ Should know about DECnet addresses, but
-    **	it's probably worth waiting until the Phase transition from IV to V.
-    */
-    soc_in->sdn_nam.n_len = min(DN_MAXNAML, strlen(host));  /* <=6 in phase 4 */
+     * Read Decnet node name.  @@ Should know about DECnet addresses, but it's
+     * probably worth waiting until the Phase transition from IV to V.
+     */
+    soc_in->sdn_nam.n_len = min(DN_MAXNAML, strlen(host));	/* <=6 in phase 4 */
     strncpy(soc_in->sdn_nam.n_name, host, soc_in->sdn_nam.n_len + 1);
-    CTRACE((tfp, "DECnet: Parsed address as object number %d on host %.6s...\n",
-		soc_in->sdn_objnum, host));
-#else  /* parse Internet host: */
+    CTRACE((tfp,
+	    "DECnet: Parsed address as object number %d on host %.6s...\n",
+	    soc_in->sdn_objnum, host));
+#else /* parse Internet host: */
 
-    if (*host >= '0' && *host <= '9') {   /* Test for numeric node address: */
+    if (*host >= '0' && *host <= '9') {		/* Test for numeric node address: */
 	strptr = host;
 	while (*strptr) {
 	    if (*strptr == '.') {
@@ -1268,22 +1261,20 @@
     }
 
     /*
-    **	Parse host number if present.
-    */
-    if (dotcount_ip == 3)   /* Numeric node address: */
+     * Parse host number if present.
+     */
+    if (dotcount_ip == 3)	/* Numeric node address: */
     {
 #ifdef DGUX_OLD
-	soc_in->sin_addr.s_addr = inet_addr(host).s_addr; /* See arpa/inet.h */
+	soc_in->sin_addr.s_addr = inet_addr(host).s_addr;	/* See arpa/inet.h */
 #else
 #ifdef GUSI
-	soc_in->sin_addr = inet_addr(host);		/* See netinet/in.h */
+	soc_in->sin_addr = inet_addr(host);	/* See netinet/in.h */
 #else
 #ifdef HAVE_INET_ATON
 	if (!inet_aton(host, &(soc_in->sin_addr))) {
 	    CTRACE((tfp, "inet_aton(%s) returns error\n", host));
-#ifndef _WINDOWS_NSL
 	    FREE(host);
-#endif /* _WINDOWS_NSL */
 	    return -1;
 	}
 #else
@@ -1291,92 +1282,88 @@
 #endif /* HAVE_INET_ATON */
 #endif /* GUSI */
 #endif /* DGUX_OLD */
-#ifndef _WINDOWS_NSL
 	FREE(host);
-#endif /* _WINDOWS_NSL */
-    } else
-    {			    /* Alphanumeric node name: */
+    } else {			/* Alphanumeric node name: */
 
-#ifdef MVS	/* Outstanding problem with crash in MVS gethostbyname */
+#ifdef MVS			/* Outstanding problem with crash in MVS gethostbyname */
 	CTRACE((tfp, "HTParseInet: Calling LYGetHostByName(%s)\n", host));
 #endif /* MVS */
 
 #ifdef _WINDOWS_NSL
 	phost = LYGetHostByName(host);	/* See above */
-	if (!phost) goto failed;
-	memcpy((void *)&soc_in->sin_addr, phost->h_addr, phost->h_length);
+	if (!phost)
+	    goto failed;
+	memcpy((void *) &soc_in->sin_addr, phost->h_addr, phost->h_length);
 #else /* !_WINDOWS_NSL */
 	{
-	    struct hostent  *phost;
+	    LYNX_HOSTENT *phost;
+
 	    phost = LYGetHostByName(host);	/* See above */
 
-	    if (!phost) goto failed;
+	    if (!phost)
+		goto failed;
 #if defined(VMS) && defined(CMU_TCP)
 	    /*
-	    **  In LIBCMU, phost->h_length contains not the length of one address
-	    **  (four bytes) but the number of bytes in *h_addr, i.e., some multiple
-	    **  of four.  Thus we need to hard code the value here, and remember to
-	    **  change it if/when IP addresses change in size. :-(	LIBCMU is no
-	    **  longer supported, and CMU users are encouraged to obtain and use
-	    **  SOCKETSHR/NETLIB instead. - S. Bjorndahl
-	    */
-	    memcpy((void *)&soc_in->sin_addr, phost->h_addr, 4);
+	     * In LIBCMU, phost->h_length contains not the length of one
+	     * address (four bytes) but the number of bytes in *h_addr, i.e.,
+	     * some multiple of four.  Thus we need to hard code the value
+	     * here, and remember to change it if/when IP addresses change in
+	     * size.  :-( LIBCMU is no longer supported, and CMU users are
+	     * encouraged to obtain and use SOCKETSHR/NETLIB instead.  - S. 
+	     * Bjorndahl
+	     */
+	    memcpy((void *) &soc_in->sin_addr, phost->h_addr, 4);
 #else
-	    if (!phost) goto failed;
+	    if (!phost)
+		goto failed;
 	    if (phost->h_length != sizeof soc_in->sin_addr) {
 		HTAlwaysAlert(host, gettext("Address length looks invalid"));
 	    }
-	    memcpy((void *)&soc_in->sin_addr, phost->h_addr, phost->h_length);
+	    memcpy((void *) &soc_in->sin_addr, phost->h_addr, phost->h_length);
 #endif /* VMS && CMU_TCP */
 	}
 #endif /* _WINDOWS_NSL */
 
-#ifndef _WINDOWS_NSL
 	FREE(host);
-#endif /* _WINDOWS_NSL */
+    }				/* Alphanumeric node name */
 
-    }	/* Alphanumeric node name */
-
-    CTRACE((tfp, "HTParseInet: Parsed address as port %d, IP address %d.%d.%d.%d\n",
-		(int)ntohs(soc_in->sin_port),
-		(int)*((unsigned char *)(&soc_in->sin_addr)+0),
-		(int)*((unsigned char *)(&soc_in->sin_addr)+1),
-		(int)*((unsigned char *)(&soc_in->sin_addr)+2),
-		(int)*((unsigned char *)(&soc_in->sin_addr)+3)));
-#endif	/* Internet vs. Decnet */
+    CTRACE((tfp,
+	    "HTParseInet: Parsed address as port %d, IP address %d.%d.%d.%d\n",
+	    (int) ntohs(soc_in->sin_port),
+	    (int) *((unsigned char *) (&soc_in->sin_addr) + 0),
+	    (int) *((unsigned char *) (&soc_in->sin_addr) + 1),
+	    (int) *((unsigned char *) (&soc_in->sin_addr) + 2),
+	    (int) *((unsigned char *) (&soc_in->sin_addr) + 3)));
+#endif /* Internet vs. Decnet */
 
-    return 0;	/* OK */
+    return 0;			/* OK */
 
-failed:
+  failed:
     CTRACE((tfp, "HTParseInet: Can't find internet node name `%s'.\n",
-		host));
-#ifndef _WINDOWS_NSL
+	    host));
     FREE(host);
-#endif /* _WINDOWS_NSL */
     switch (lynx_nsl_status) {
-	case HT_NOT_ACCEPTABLE:
-	case HT_INTERRUPTED:
-	    return lynx_nsl_status;
-	default:
+    case HT_NOT_ACCEPTABLE:
+    case HT_INTERRUPTED:
+	return lynx_nsl_status;
+    default:
 	return -1;
     }
 }
 #endif /* !INET6 */
 
 #ifdef INET6
-PRIVATE struct addrinfo *
-HTGetAddrInfo ARGS2(
-    CONST char *, str,
-    CONST int, defport)
+static LYNX_ADDRINFO *HTGetAddrInfo(const char *str,
+				    const int defport)
 {
-    struct addrinfo hints, *res;
+    LYNX_ADDRINFO hints, *res;
     int error;
     char *p;
-    char *s;
+    char *s = NULL;
     char *host, *port;
     char pbuf[80];
 
-    s = strdup(str);
+    StrAllocCopy(s, str);
 
     if (s[0] == '[' && (p = strchr(s, ']')) != NULL) {
 	*p++ = '\0';
@@ -1403,43 +1390,46 @@
 	res = NULL;
     }
 
+    free(s);
     return res;
 }
 #endif /* INET6 */
 
 #ifdef LY_FIND_LEAKS
 /*	Free our name for the host on which we are - FM
-**	-------------------------------------------
-**
-*/
-PRIVATE void free_HTTCP_hostname NOARGS
+ *	-------------------------------------------
+ *
+ */
+static void free_HTTCP_hostname(void)
 {
     FREE(hostname);
 }
 #endif /* LY_FIND_LEAKS */
 
 /*	Derive the name of the host on which we are
-**	-------------------------------------------
-**
-*/
-PRIVATE void get_host_details NOARGS
+ *	-------------------------------------------
+ *
+ */
+static void get_host_details(void)
 {
-    char name[MAXHOSTNAMELEN+1];	/* The name of this host */
+    char name[MAXHOSTNAMELEN + 1];	/* The name of this host */
+
 #ifdef UCX
-    char *domain_name;			/* The name of this host domain */
+    char *domain_name;		/* The name of this host domain */
 #endif /* UCX */
-#ifdef NEED_HOST_ADDRESS		/* no -- needs name server! */
+#ifdef NEED_HOST_ADDRESS	/* no -- needs name server! */
 #ifdef INET6
-    struct addrinfo hints, *res;
+    LYNX_ADDRINFO hints, *res;
     int error;
+
 #else
-    struct hostent * phost;		/* Pointer to host -- See netdb.h */
+    LYNX_HOSTENT *phost;	/* Pointer to host -- See netdb.h */
 #endif /* INET6 */
 #endif /* NEED_HOST_ADDRESS */
     int namelength = sizeof(name);
 
     if (hostname)
-	return;				/* Already done */
+	return;			/* Already done */
     gethostname(name, namelength);	/* Without domain */
     StrAllocCopy(hostname, name);
 #ifdef LY_FIND_LEAKS
@@ -1447,10 +1437,10 @@
 #endif
 #ifdef UCX
     /*
-    **	UCX doesn't give the complete domain name.
-    **	Get rest from UCX$BIND_DOM logical.
-    */
-    if (strchr(hostname,'.') == NULL) {		  /* Not full address */
+     * UCX doesn't give the complete domain name.  Get rest from UCX$BIND_DOM
+     * logical.
+     */
+    if (strchr(hostname, '.') == NULL) {	/* Not full address */
 	domain_name = LYGetEnv("UCX$BIND_DOMAIN");
 	if (domain_name == NULL)
 	    domain_name = LYGetEnv("TCPIP$BIND_DOMAIN");
@@ -1458,12 +1448,12 @@
 	    StrAllocCat(hostname, ".");
 	    StrAllocCat(hostname, domain_name);
 	}
-     }
+    }
 #endif /* UCX */
     CTRACE((tfp, "TCP: Local host name is %s\n", hostname));
 
-#ifndef DECNET	/* Decnet ain't got no damn name server 8#OO */
-#ifdef NEED_HOST_ADDRESS		/* no -- needs name server! */
+#ifndef DECNET			/* Decnet ain't got no damn name server 8#OO */
+#ifdef NEED_HOST_ADDRESS	/* no -- needs name server! */
 #ifdef INET6
     memset(&hints, 0, sizeof(hints));
     hints.ai_family = PF_UNSPEC;
@@ -1474,7 +1464,7 @@
 	CTRACE((tfp, "TCP: %s: `%s'\n", gai_strerror(error), name));
 	if (res)
 	    freeaddrinfo(res);
-	return;  /* Fail! */
+	return;			/* Fail! */
     }
     StrAllocCopy(hostname, res->ai_canonname);
     memcpy(&HTHostAddress, res->ai_addr, res->ai_addrlen);
@@ -1482,82 +1472,84 @@
 #else
     phost = gethostbyname(name);	/* See netdb.h */
     if (!OK_HOST(phost)) {
-	CTRACE((tfp, "TCP: Can't find my own internet node address for `%s'!!\n",
-		    name));
-	return;  /* Fail! */
+	CTRACE((tfp,
+		"TCP: Can't find my own internet node address for `%s'!!\n",
+		name));
+	return;			/* Fail! */
     }
     StrAllocCopy(hostname, phost->h_name);
     memcpy(&HTHostAddress, &phost->h_addr, phost->h_length);
 #endif /* INET6 */
     CTRACE((tfp, "     Name server says that I am `%s' = %s\n",
-		hostname, HTInetString(&HTHostAddress)));
+	    hostname, HTInetString(&HTHostAddress)));
 #endif /* NEED_HOST_ADDRESS */
 
 #endif /* !DECNET */
 }
 
-PUBLIC CONST char * HTHostName NOARGS
+const char *HTHostName(void)
 {
     get_host_details();
     return hostname;
 }
 
 #ifndef MULTINET		/* SOCKET_ERRNO != errno ? */
-#if !defined(UCX) || !defined(VAXC) /* errno not modifiable ? */
-#define SOCKET_DEBUG_TRACE    /* show errno status after some system calls */
-#endif  /* UCX && VAXC */
+#if !defined(UCX) || !defined(VAXC)	/* errno not modifiable ? */
+#define SOCKET_DEBUG_TRACE	/* show errno status after some system calls */
+#endif /* UCX && VAXC */
 #endif /* MULTINET */
 /*
-**  Interruptible connect as implemented for Mosaic by Marc Andreesen
-**  and hacked in for Lynx years ago by Lou Montulli, and further
-**  modified over the years by numerous Lynx lovers. - FM
-*/
-PUBLIC int HTDoConnect ARGS4(
-	CONST char *,	url,
-	char *,		protocol,
-	int,		default_port,
-	int *,		s)
+ *  Interruptible connect as implemented for Mosaic by Marc Andreesen
+ *  and hacked in for Lynx years ago by Lou Montulli, and further
+ *  modified over the years by numerous Lynx lovers. - FM
+ */
+int HTDoConnect(const char *url,
+		const char *protocol,
+		int default_port,
+		int *s)
 {
     int status = 0;
     char *line = NULL;
     char *p1 = NULL;
     char *at_sign = NULL;
     char *host = NULL;
+
 #ifdef INET6
-    struct addrinfo *res = 0, *res0 = 0;
+    LYNX_ADDRINFO *res = 0, *res0 = 0;
+
 #else
     struct sockaddr_in soc_address;
     struct sockaddr_in *soc_in = &soc_address;
 
     /*
-    **	Set up defaults.
-    */
+     * Set up defaults.
+     */
     memset(soc_in, 0, sizeof(*soc_in));
     soc_in->sin_family = AF_INET;
     soc_in->sin_port = htons((PortNumber) default_port);
 #endif /* INET6 */
 
     /*
-    **	Get node name and optional port number.
-    */
+     * Get node name and optional port number.
+     */
     p1 = HTParse(url, "", PARSE_HOST);
     if ((at_sign = strchr(p1, '@')) != NULL) {
 	/*
-	**  If there's an @ then use the stuff after it as a hostname.
-	*/
+	 * If there's an @ then use the stuff after it as a hostname.
+	 */
 	StrAllocCopy(host, (at_sign + 1));
     } else {
 	StrAllocCopy(host, p1);
     }
     FREE(p1);
 
-    HTSprintf0 (&line, "%s%s", WWW_FIND_MESSAGE, host);
-    _HTProgress (line);
+    HTSprintf0(&line, "%s%s", WWW_FIND_MESSAGE, host);
+    _HTProgress(line);
 #ifdef INET6
     /* HTParseInet() is useless! */
     res0 = HTGetAddrInfo(host, default_port);
     if (res0 == NULL) {
-	HTSprintf0 (&line, gettext("Unable to locate remote host %s."), host);
+	HTSprintf0(&line, gettext("Unable to locate remote host %s."), host);
 	_HTProgress(line);
 	FREE(host);
 	FREE(line);
@@ -1568,14 +1560,14 @@
     if (status) {
 	if (status != HT_INTERRUPTED) {
 	    if (status == HT_NOT_ACCEPTABLE) {
-		/*  Not HTProgress, so warning won't be overwritten
-		 *  immediately; but not HTAlert, because typically
-		 *  there will be other alerts from the callers. - kw
+		/* Not HTProgress, so warning won't be overwritten immediately;
+		 * but not HTAlert, because typically there will be other
+		 * alerts from the callers.  - kw
 		 */
 		HTUserMsg2(gettext("Invalid hostname %s"), host);
 	    } else {
-		HTSprintf0 (&line,
-			 gettext("Unable to locate remote host %s."), host);
+		HTSprintf0(&line,
+			   gettext("Unable to locate remote host %s."), host);
 		_HTProgress(line);
 	    }
 	    status = HT_NO_DATA;
@@ -1586,284 +1578,291 @@
     }
 #endif /* INET6 */
 
-    HTSprintf0 (&line, gettext("Making %s connection to %s"), protocol, host);
-    _HTProgress (line);
+    HTSprintf0(&line, gettext("Making %s connection to %s"), protocol, host);
+    _HTProgress(line);
     FREE(host);
     FREE(line);
 
     /*
-    **	Now, let's get a socket set up from the server for the data.
-    */
-#ifdef INET6
+     * Now, let's get a socket set up from the server for the data.
+     */
+#ifndef INET6
+    *s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+    if (*s == -1) {
+	HTAlert(gettext("socket failed."));
+	return HT_NO_DATA;
+    }
+#else
     for (res = res0; res; res = res->ai_next) {
 	*s = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
 	if (*s == -1) {
 	    char hostbuf[1024], portbuf[1024];
+
 	    getnameinfo(res->ai_addr, res->ai_addrlen,
-		    hostbuf, sizeof(hostbuf), portbuf, sizeof(portbuf),
-		    NI_NUMERICHOST|NI_NUMERICSERV);
-	    HTSprintf0 (&line, gettext("socket failed: family %d addr %s port %s."),
-		    res->ai_family, hostbuf, portbuf);
-	    _HTProgress (line);
+			hostbuf, sizeof(hostbuf), portbuf, sizeof(portbuf),
+			NI_NUMERICHOST | NI_NUMERICSERV);
+	    HTSprintf0(&line,
+		       gettext("socket failed: family %d addr %s port %s."),
+		       res->ai_family, hostbuf, portbuf);
+	    _HTProgress(line);
 	    FREE(line);
 	    continue;
 	}
-#else
-    *s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
-    if (*s == -1) {
-	HTAlert(gettext("socket failed."));
-	return HT_NO_DATA;
-    }
 #endif /* INET6 */
 
 #if !defined(DOSPATH) || defined(__DJGPP__)
 #if !defined(NO_IOCTL) || defined(USE_FCNTL)
-    /*
-    **	Make the socket non-blocking, so the connect can be canceled.
-    **	This means that when we issue the connect we should NOT
-    **	have to wait for the accept on the other end.
-    */
-    {
+	/*
+	 * Make the socket non-blocking, so the connect can be canceled.  This
+	 * means that when we issue the connect we should NOT have to wait for
+	 * the accept on the other end.
+	 */
+	{
 #ifdef USE_FCNTL
-	int ret = fcntl(*s, F_SETFL, O_NONBLOCK);
+	    int ret = fcntl(*s, F_SETFL, O_NONBLOCK);
+
 #else
-	int val = 1;
-	int ret = IOCTL(*s, FIONBIO, &val);
+	    int val = 1;
+	    int ret = IOCTL(*s, FIONBIO, &val);
 #endif /* USE_FCNTL */
-	if (ret == -1)
-	    _HTProgress(gettext("Could not make connection non-blocking."));
-    }
+	    if (ret == -1)
+		_HTProgress(gettext("Could not make connection non-blocking."));
+	}
 #endif /* !NO_IOCTL || USE_FCNTL */
 #endif /* !DOSPATH || __DJGPP__ */
 
-    /*
-    **	Issue the connect.  Since the server can't do an instantaneous
-    **	accept and we are non-blocking, this will almost certainly return
-    **	a negative status.
-    */
+	/*
+	 * Issue the connect.  Since the server can't do an instantaneous
+	 * accept and we are non-blocking, this will almost certainly return a
+	 * negative status.
+	 */
 #ifdef SOCKS
-    if (socks_flag) {
+	if (socks_flag) {
 #ifdef INET6
-	status = Rconnect(*s, res->ai_addr, res->ai_addrlen);
+	    status = Rconnect(*s, res->ai_addr, res->ai_addrlen);
 #else
-	status = Rconnect(*s, (struct sockaddr*)&soc_address,
-			  sizeof(soc_address));
+	    status = Rconnect(*s, (struct sockaddr *) &soc_address,
+			      sizeof(soc_address));
 #endif /* INET6 */
-	/*
-	**  For long Rbind.
-	*/
-	socks_bind_remoteAddr = soc_address.sin_addr.s_addr;
-    } else
+	    /*
+	     * For long Rbind.
+	     */
+	    socks_bind_remoteAddr = soc_address.sin_addr.s_addr;
+	} else
 #endif /* SOCKS */
 #ifdef INET6
-    status = connect(*s, res->ai_addr, res->ai_addrlen);
+	    status = connect(*s, res->ai_addr, res->ai_addrlen);
 #else
-    status = connect(*s, (struct sockaddr*)&soc_address, sizeof(soc_address));
+	    status = connect(*s, (struct sockaddr *) &soc_address, sizeof(soc_address));
 #endif /* INET6 */
 
-    /*
-    **	According to the Sun man page for connect:
-    **	   EINPROGRESS	       The socket is non-blocking and the  con-
-    **			       nection cannot be completed immediately.
-    **			       It is possible to select(2) for	comple-
-    **			       tion  by  selecting the socket for writ-
-    **			       ing.
-    **	According to the Motorola SVR4 man page for connect:
-    **	   EAGAIN	       The socket is non-blocking and the  con-
-    **			       nection cannot be completed immediately.
-    **			       It is possible to select for  completion
-    **			       by  selecting  the  socket  for writing.
-    **			       However, this is only  possible	if  the
-    **			       socket  STREAMS	module	is  the topmost
-    **			       module on  the  protocol  stack	with  a
-    **			       write  service  procedure.  This will be
-    **			       the normal case.
-    */
-    if ((status < 0) &&
-	(SOCKET_ERRNO == EINPROGRESS
+	/*
+	 * According to the Sun man page for connect:
+	 *  EINPROGRESS         The socket is non-blocking and the  con-
+	 *                      nection cannot be completed immediately.
+	 *                      It is possible to select(2) for  comple-
+	 *                      tion  by  selecting the socket for writ-
+	 *                      ing.
+	 * According to the Motorola SVR4 man page for connect:
+	 *  EAGAIN              The socket is non-blocking and the  con-
+	 *                      nection cannot be completed immediately.
+	 *                      It is possible to select for  completion
+	 *                      by  selecting  the  socket  for writing.
+	 *                      However, this is only  possible  if  the
+	 *                      socket  STREAMS  module  is  the topmost
+	 *                      module on  the  protocol  stack  with  a
+	 *                      write  service  procedure.  This will be
+	 *                      the normal case.
+	 */
+	if ((status < 0) &&
+	    (SOCKET_ERRNO == EINPROGRESS
 #ifdef EAGAIN
-	 || SOCKET_ERRNO == EAGAIN
+	     || SOCKET_ERRNO == EAGAIN
 #endif
-	 )) {
-	struct timeval select_timeout;
-	int ret;
-	int tries=0;
+	    )) {
+	    struct timeval select_timeout;
+	    int ret;
+	    int tries = 0;
 
 #ifdef SOCKET_DEBUG_TRACE
-	HTInetStatus("this socket's first connect");
+	    HTInetStatus("this socket's first connect");
 #endif /* SOCKET_DEBUG_TRACE */
-	ret = 0;
-	while (ret <= 0) {
-	    fd_set writefds;
+	    ret = 0;
+	    while (ret <= 0) {
+		fd_set writefds;
 
-	    /*
-	    **	Protect against an infinite loop.
-	    */
-	    if ((tries++/10) >= connect_timeout) {
-		HTAlert(gettext("Connection failed (too many retries)."));
+		/*
+		 * Protect against an infinite loop.
+		 */
+		if ((tries++ / 10) >= connect_timeout) {
+		    HTAlert(gettext("Connection failed (too many retries)."));
 #ifdef INET6
-		FREE(line);
-		if (res0)
-		    freeaddrinfo(res0);
+		    FREE(line);
+		    if (res0)
+			freeaddrinfo(res0);
 #endif /* INET6 */
-		return HT_NO_DATA;
-	    }
-
+		    return HT_NO_DATA;
+		}
 #ifdef _WINDOWS_NSL
-	    select_timeout.tv_sec = connect_timeout;
-	    select_timeout.tv_usec = 0;
+		select_timeout.tv_sec = connect_timeout;
+		select_timeout.tv_usec = 0;
 #else
-	    select_timeout.tv_sec = 0;
-	    select_timeout.tv_usec = 100000;
+		select_timeout.tv_sec = 0;
+		select_timeout.tv_usec = 100000;
 #endif /* _WINDOWS_NSL */
-	    FD_ZERO(&writefds);
-	    FD_SET((unsigned) *s, &writefds);
+		FD_ZERO(&writefds);
+		FD_SET((unsigned) *s, &writefds);
 #ifdef SOCKS
-	    if (socks_flag)
-		ret = Rselect((unsigned)*s + 1, NULL,
-			      (void *)&writefds, NULL, &select_timeout);
-	    else
+		if (socks_flag)
+		    ret = Rselect((unsigned) *s + 1, NULL,
+				  &writefds, NULL, &select_timeout);
+		else
 #endif /* SOCKS */
-	    ret = select((unsigned)*s + 1, NULL, (void *)&writefds, NULL, &select_timeout);
+		    ret = select((unsigned) *s + 1,
+				 NULL,
+				 &writefds,
+				 NULL,
+				 &select_timeout);
 
 #ifdef SOCKET_DEBUG_TRACE
-	    if (tries == 1) {
-		HTInetStatus("this socket's first select");
-	    }
+		if (tries == 1) {
+		    HTInetStatus("this socket's first select");
+		}
 #endif /* SOCKET_DEBUG_TRACE */
-	    /*
-	    **  If we suspend, then it is possible that select will be
-	    **  interrupted.  Allow for this possibility. - JED
-	    */
-	    if ((ret == -1) && (errno == EINTR))
-		continue;
+		/*
+		 * If we suspend, then it is possible that select will be
+		 * interrupted.  Allow for this possibility.  - JED
+		 */
+		if ((ret == -1) && (errno == EINTR))
+		    continue;
 
 #ifdef SOCKET_DEBUG_TRACE
-	    if (ret < 0) {
-		HTInetStatus("failed select");
-	    }
+		if (ret < 0) {
+		    HTInetStatus("failed select");
+		}
 #endif /* SOCKET_DEBUG_TRACE */
-	    /*
-	    **	Again according to the Sun and Motorola man pages for connect:
-	    **	   EALREADY	       The socket is non-blocking and a  previ-
-	    **			       ous  connection attempt has not yet been
-	    **			       completed.
-	    **	Thus if the SOCKET_ERRNO is NOT EALREADY we have a real error,
-	    **	and should break out here and return that error.
-	    **	Otherwise if it is EALREADY keep on trying to complete the
-	    **	connection.
-	    */
-	    if ((ret < 0) && (SOCKET_ERRNO != EALREADY)) {
-		status = ret;
-		break;
-	    } else if (ret > 0) {
 		/*
-		**  Extra check here for connection success, if we try to
-		**  connect again, and get EISCONN, it means we have a
-		**  successful connection.  But don't check with SOCKS.
-		*/
+		 * Again according to the Sun and Motorola man pages for
+		 * connect:
+		 *  EALREADY    The socket is non-blocking and a  previ-
+		 *              ous  connection attempt has not yet been
+		 *              completed.
+		 * Thus if the SOCKET_ERRNO is NOT EALREADY we have a real
+		 * error, and should break out here and return that error. 
+		 * Otherwise if it is EALREADY keep on trying to complete the
+		 * connection.
+		 */
+		if ((ret < 0) && (SOCKET_ERRNO != EALREADY)) {
+		    status = ret;
+		    break;
+		} else if (ret > 0) {
+		    /*
+		     * Extra check here for connection success, if we try to
+		     * connect again, and get EISCONN, it means we have a
+		     * successful connection.  But don't check with SOCKS.
+		     */
 #ifdef SOCKS
-		if (socks_flag) {
-		    status = 0;
-		} else {
+		    if (socks_flag) {
+			status = 0;
+		    } else {
 #endif /* SOCKS */
 #ifdef INET6
-		status = connect(*s, res->ai_addr, res->ai_addrlen);
+			status = connect(*s, res->ai_addr, res->ai_addrlen);
 #else
-		status = connect(*s, (struct sockaddr*)&soc_address,
-				 sizeof(soc_address));
+			status = connect(*s, (struct sockaddr *) &soc_address,
+					 sizeof(soc_address));
 #endif /* INET6 */
 #ifdef UCX
-		/*
-		**  A UCX feature: Instead of returning EISCONN
-		**		 UCX returns EADDRINUSE.
-		**  Test for this status also.
-		*/
-		if ((status < 0) && ((SOCKET_ERRNO == EISCONN) ||
-				     (SOCKET_ERRNO == EADDRINUSE)))
+			/*
+			 * A UCX feature:  Instead of returning EISCONN UCX
+			 * returns EADDRINUSE.  Test for this status also.
+			 */
+			if ((status < 0) && ((SOCKET_ERRNO == EISCONN) ||
+					     (SOCKET_ERRNO == EADDRINUSE)))
 #else
-		if ((status < 0) && (SOCKET_ERRNO == EISCONN))
+			if ((status < 0) && (SOCKET_ERRNO == EISCONN))
 #endif /* UCX */
-		{
-		    status = 0;
-		}
+			{
+			    status = 0;
+			}
 
-		if (status && (SOCKET_ERRNO == EALREADY)) /* new stuff LJM */
-		    ret = 0; /* keep going */
-		else {
+			if (status && (SOCKET_ERRNO == EALREADY))	/* new stuff LJM */
+			    ret = 0;	/* keep going */
+			else {
 #ifdef SOCKET_DEBUG_TRACE
-		    if (status < 0) {
-			HTInetStatus("confirm-ready connect");
-		    }
+			    if (status < 0) {
+				HTInetStatus("confirm-ready connect");
+			    }
 #endif /* SOCKET_DEBUG_TRACE */
-		    break;
-		}
+			    break;
+			}
 #ifdef SOCKS
-		}
+		    }
 #endif /* SOCKS */
-	    }
+		}
 #ifdef SOCKS
-	    else if (!socks_flag)
+		else if (!socks_flag)
 #else
-	    else
+		else
 #endif /* SOCKS */
-	    {
-		/*
-		**  The select says we aren't ready yet.  Try to connect
-		**  again to make sure.  If we don't get EALREADY or EISCONN,
-		**  something has gone wrong.  Break out and report it.
-		**
-		**  For some reason, SVR4 returns EAGAIN here instead of
-		**  EALREADY, even though the man page says it should be
-		**  EALREADY.
-		**
-		**  For some reason, UCX pre 3 apparently returns
-		**  errno = 18242 instead the EALREADY or EISCONN.
-		*/
+		{
+		    /*
+		     * The select says we aren't ready yet.  Try to connect
+		     * again to make sure.  If we don't get EALREADY or
+		     * EISCONN, something has gone wrong.  Break out and report
+		     * it.
+		     *
+		     * For some reason, SVR4 returns EAGAIN here instead of
+		     * EALREADY, even though the man page says it should be
+		     * EALREADY.
+		     *
+		     * For some reason, UCX pre 3 apparently returns errno =
+		     * 18242 instead of EALREADY or EISCONN.
+		     */
 #ifdef INET6
-		status = connect(*s, res->ai_addr, res->ai_addrlen);
+		    status = connect(*s, res->ai_addr, res->ai_addrlen);
 #else
-		status = connect(*s, (struct sockaddr*)&soc_address,
-				 sizeof(soc_address));
+		    status = connect(*s, (struct sockaddr *) &soc_address,
+				     sizeof(soc_address));
 #endif /* INET6 */
-		if ((status < 0) &&
-		    (SOCKET_ERRNO != EALREADY
+		    if ((status < 0) &&
+			(SOCKET_ERRNO != EALREADY
 #ifdef EAGAIN
-		    && SOCKET_ERRNO != EAGAIN
+			 && SOCKET_ERRNO != EAGAIN
 #endif
-		    ) &&
+			) &&
 #ifdef UCX
-		    (SOCKET_ERRNO != 18242) &&
+			(SOCKET_ERRNO != 18242) &&
 #endif /* UCX */
-		    (SOCKET_ERRNO != EISCONN)) {
+			(SOCKET_ERRNO != EISCONN)) {
 #ifdef SOCKET_DEBUG_TRACE
-		    HTInetStatus("confirm-not-ready connect");
+			HTInetStatus("confirm-not-ready connect");
 #endif /* SOCKET_DEBUG_TRACE */
-		    break;
+			break;
+		    }
 		}
-	    }
-	    if (HTCheckForInterrupt()) {
-		CTRACE((tfp, "*** INTERRUPTED in middle of connect.\n"));
-		status = HT_INTERRUPTED;
+		if (HTCheckForInterrupt()) {
+		    CTRACE((tfp, "*** INTERRUPTED in middle of connect.\n"));
+		    status = HT_INTERRUPTED;
 #ifdef _WINDOWS
-		WSASetLastError(EINTR);
+		    WSASetLastError(EINTR);
 #else
-		SOCKET_ERRNO = EINTR;
+		    SOCKET_ERRNO = EINTR;
 #endif
-		break;
+		    break;
+		}
 	    }
 	}
-    }
 #ifdef SOCKET_DEBUG_TRACE
-    else if (status < 0) {
-	HTInetStatus("this socket's first and only connect");
-    }
+	else if (status < 0) {
+	    HTInetStatus("this socket's first and only connect");
+	}
 #endif /* SOCKET_DEBUG_TRACE */
 #ifdef INET6
 	if (status < 0) {
-		NETCLOSE(*s);
-		*s = -1;
-		continue;
+	    NETCLOSE(*s);
+	    *s = -1;
+	    continue;
 	}
 	break;
     }
@@ -1876,19 +1875,20 @@
 #endif /* INET6 */
     {
 	/*
-	**  The connect attempt failed or was interrupted,
-	**  so close up the socket.
-	*/
+	 * The connect attempt failed or was interrupted, so close up the
+	 * socket.
+	 */
 	NETCLOSE(*s);
     }
 #if !defined(DOSPATH) || defined(__DJGPP__)
 #if !defined(NO_IOCTL) || defined(USE_FCNTL)
     else {
 	/*
-	**  Make the socket blocking again on good connect.
-	*/
+	 * Make the socket blocking again on good connect.
+	 */
 #ifdef USE_FCNTL
 	int ret = fcntl(*s, F_SETFL, 0);
+
 #else
 	int val = 0;
 	int ret = IOCTL(*s, FIONBIO, &val);
@@ -1908,20 +1908,20 @@
 }
 
 /*
-**  This is so interruptible reads can be implemented cleanly.
-*/
-PUBLIC int HTDoRead ARGS3(
-	int,		fildes,
-	void *,		buf,
-	unsigned,	nbyte)
+ *  This is so interruptible reads can be implemented cleanly.
+ */
+int HTDoRead(int fildes,
+	     void *buf,
+	     unsigned nbyte)
 {
     int ready, ret;
     fd_set readfds;
     struct timeval select_timeout;
-    int tries=0;
+    int tries = 0;
+
 #ifdef USE_READPROGRESS
     int otries = 0;
-    time_t otime = time((time_t *)0);
+    time_t otime = time((time_t *) 0);
 #endif
 #if defined(UNIX) || defined(UCX)
     int nb;
@@ -1930,8 +1930,8 @@
 #ifdef UNIX
     if (fildes == 0) {
 	/*
-	 *  0 can be a valid socket fd, but if it's a tty something must
-	 *  have gone wrong. - kw
+	 * 0 can be a valid socket fd, but if it's a tty something must have
+	 * gone wrong.  - kw
 	 */
 	if (isatty(fildes)) {
 	    CTRACE((tfp, "HTDoRead - refusing to read fd 0 which is a tty!\n"));
@@ -1950,7 +1950,6 @@
 #endif
 	return (HT_INTERRUPTED);
     }
-
 #if !defined(NO_IOCTL)
     ready = 0;
 #else
@@ -1958,8 +1957,8 @@
 #endif /* bypass for NO_IOCTL */
     while (!ready) {
 	/*
-	**  Protect against an infinite loop.
-	*/
+	 * Protect against an infinite loop.
+	 */
 	if (tries++ >= 180000) {
 	    HTAlert(gettext("Socket read failed for 180,000 tries."));
 #ifdef _WINDOWS
@@ -1969,10 +1968,9 @@
 #endif
 	    return HT_INTERRUPTED;
 	}
-
 #ifdef USE_READPROGRESS
 	if (tries - otries > 10) {
-	    time_t t = time((time_t *)0);
+	    time_t t = time((time_t *) 0);
 
 	    otries = tries;
 	    if (t - otime >= 5) {
@@ -1983,22 +1981,22 @@
 #endif
 
 	/*
-	**  If we suspend, then it is possible that select will be
-	**  interrupted.  Allow for this possibility. - JED
-	*/
+	 * If we suspend, then it is possible that select will be interrupted. 
+	 * Allow for this possibility.  - JED
+	 */
 	do {
 	    select_timeout.tv_sec = 0;
 	    select_timeout.tv_usec = 100000;
 	    FD_ZERO(&readfds);
-	    FD_SET((unsigned)fildes, &readfds);
+	    FD_SET((unsigned) fildes, &readfds);
 #ifdef SOCKS
 	    if (socks_flag)
-		ret = Rselect((unsigned)fildes + 1,
-			      (void *)&readfds, NULL, NULL, &select_timeout);
+		ret = Rselect((unsigned) fildes + 1,
+			      &readfds, NULL, NULL, &select_timeout);
 	    else
 #endif /* SOCKS */
-		ret = select((unsigned)fildes + 1,
-			     (void *)&readfds, NULL, NULL, &select_timeout);
+		ret = select((unsigned) fildes + 1,
+			     &readfds, NULL, NULL, &select_timeout);
 	} while ((ret == -1) && (errno == EINTR));
 
 	if (ret < 0) {
@@ -2017,7 +2015,7 @@
 
 #if !defined(UCX) || !defined(VAXC)
 #ifdef UNIX
-    while ((nb = SOCKET_READ (fildes, buf, nbyte)) == -1) {
+    while ((nb = SOCKET_READ(fildes, buf, nbyte)) == -1) {
 	if (errno == EINTR)
 	    continue;
 #ifdef ERESTARTSYS
@@ -2028,23 +2026,23 @@
 	break;
     }
     return nb;
-#else  /* UNIX */
-    return SOCKET_READ (fildes, buf, nbyte);
+#else /* UNIX */
+    return SOCKET_READ(fildes, buf, nbyte);
 #endif /* !UNIX */
 
-#else  /* UCX && VAXC */
+#else /* UCX && VAXC */
     /*
-    **	VAXC and UCX problem only.
-    */
+     * VAXC and UCX problem only.
+     */
     errno = vaxc$errno = 0;
-    nb = SOCKET_READ (fildes, buf, nbyte);
+    nb = SOCKET_READ(fildes, buf, nbyte);
     CTRACE((tfp,
-	   "Read - nb,errno,vaxc$errno: %d %d %d\n", nb,errno,vaxc$errno));
+	    "Read - nb,errno,vaxc$errno: %d %d %d\n", nb, errno, vaxc$errno));
     if ((nb <= 0) && TRACE)
-	perror ("HTTCP.C:HTDoRead:read");	   /* RJF */
+	perror("HTTCP.C:HTDoRead:read");	/* RJF */
     /*
-    **	An errno value of EPIPE and nb < 0 indicates end-of-file on VAXC.
-    */
+     * An errno value of EPIPE and nb < 0 indicates end-of-file on VAXC.
+     */
     if ((nb <= 0) && (errno == EPIPE)) {
 	nb = 0;
 	set_errno(0);
@@ -2055,20 +2053,20 @@
 
 #ifdef SVR4_BSDSELECT
 /*
-**  This is a fix for the difference between BSD's select() and
-**  SVR4's select().  SVR4's select() can never return a value larger
-**  than the total number of file descriptors being checked.  So, if
-**  you select for read and write on one file descriptor, and both
-**  are true, SVR4 select() will only return 1.  BSD select in the
-**  same situation will return 2.
-**
-**	Additionally, BSD select() on timing out, will zero the masks,
-**	while SVR4 does not.  This is fixed here as well.
-**
-**	Set your tabstops to 4 characters to have this code nicely formatted.
-**
-**	Jerry Whelan, guru@bradley.edu, June 12th, 1993
-*/
+ *  This is a fix for the difference between BSD's select() and
+ *  SVR4's select().  SVR4's select() can never return a value larger
+ *  than the total number of file descriptors being checked.  So, if
+ *  you select for read and write on one file descriptor, and both
+ *  are true, SVR4 select() will only return 1.  BSD select in the
+ *  same situation will return 2.
+ *
+ *	Additionally, BSD select() on timing out, will zero the masks,
+ *	while SVR4 does not.  This is fixed here as well.
+ *
+ *	Set your tabstops to 4 characters to have this code nicely formatted.
+ *
+ *	Jerry Whelan, guru@bradley.edu, June 12th, 1993
+ */
 #ifdef select
 #undef select
 #endif /* select */
@@ -2083,47 +2081,45 @@
 #include <sys/time.h>
 #include <sys/select.h>
 
-PUBLIC int BSDselect ARGS5(
-	int,			nfds,
-	fd_set *,		readfds,
-	fd_set *,		writefds,
-	fd_set *,		exceptfds,
-	struct timeval *,	select_timeout)
+int BSDselect(int nfds,
+	      fd_set * readfds,
+	      fd_set * writefds,
+	      fd_set * exceptfds,
+	      struct timeval *select_timeout)
 {
-    int rval,
-    i;
+    int rval, i;
 
 #ifdef SOCKS
     if (socks_flag)
 	rval = Rselect(nfds, readfds, writefds, exceptfds, select_timeout);
     else
 #endif /* SOCKS */
-    rval = select(nfds, readfds, writefds, exceptfds, select_timeout);
+	rval = select(nfds, readfds, writefds, exceptfds, select_timeout);
 
     switch (rval) {
-	case -1:
-	    return(rval);
+    case -1:
+	return (rval);
 
-	case 0:
-	    if (readfds != NULL)
-		FD_ZERO(readfds);
-	    if (writefds != NULL)
-		FD_ZERO(writefds);
-	    if (exceptfds != NULL)
-		FD_ZERO(exceptfds);
-	    return(rval);
-
-	default:
-	    for (i = 0, rval = 0; i < nfds; i++) {
-		if ((readfds != NULL) && FD_ISSET(i, readfds))
-		    rval++;
-		if ((writefds != NULL) && FD_ISSET(i, writefds))
-		    rval++;
-		if ((exceptfds != NULL) && FD_ISSET(i, exceptfds))
-		    rval++;
+    case 0:
+	if (readfds != NULL)
+	    FD_ZERO(readfds);
+	if (writefds != NULL)
+	    FD_ZERO(writefds);
+	if (exceptfds != NULL)
+	    FD_ZERO(exceptfds);
+	return (rval);
+
+    default:
+	for (i = 0, rval = 0; i < nfds; i++) {
+	    if ((readfds != NULL) && FD_ISSET(i, readfds))
+		rval++;
+	    if ((writefds != NULL) && FD_ISSET(i, writefds))
+		rval++;
+	    if ((exceptfds != NULL) && FD_ISSET(i, exceptfds))
+		rval++;
 
-	    }
-	    return(rval);
+	}
+	return (rval);
     }
 /* Should never get here */
 }
--- lynx-cur-2.8.6.orig/WWW/Library/Implementation/HTFTP.c
+++ lynx-cur-2.8.6/WWW/Library/Implementation/HTFTP.c
@@ -1,76 +1,76 @@
 /*			File Transfer Protocol (FTP) Client
-**			for a WorldWideWeb browser
-**			===================================
-**
-**	A cache of control connections is kept.
-**
-** Note: Port allocation
-**
-**	It is essential that the port is allocated by the system, rather
-**	than chosen in rotation by us (POLL_PORTS), or the following
-**	problem occurs.
-**
-**	It seems that an attempt by the server to connect to a port which has
-**	been used recently by a listen on the same socket, or by another
-**	socket this or another process causes a hangup of (almost exactly)
-**	one minute.  Therefore, we have to use a rotating port number.
-**	The problem remains that if the application is run twice in quick
-**	succession, it will hang for what remains of a minute.
-**
-** Authors
-**	TBL	Tim Berners-lee <timbl@info.cern.ch>
-**	DD	Denis DeLaRoca 310 825-4580 <CSP1DWD@mvs.oac.ucla.edu>
-**	LM	Lou Montulli <montulli@ukanaix.cc.ukans.edu>
-**	FM	Foteos Macrides <macrides@sci.wfeb.edu>
-** History:
-**	 2 May 91	Written TBL, as a part of the WorldWideWeb project.
-**	15 Jan 92	Bug fix: close() was used for NETCLOSE for control soc
-**	10 Feb 92	Retry if cached connection times out or breaks
-**	 8 Dec 92	Bug fix 921208 TBL after DD
-**	17 Dec 92	Anon FTP password now just WWWuser@ suggested by DD
-**			fails on princeton.edu!
-**	27 Dec 93 (FM)	Fixed up so FTP now works with VMS hosts.  Path
-**			must be Unix-style and cannot include the device
-**			or top directory.
-**	?? ??? ?? (LM)	Added code to prompt and send passwords for non
-**			anonymous FTP
-**	25 Mar 94 (LM)	Added code to recognize different ftp server types
-**			and code to parse dates and sizes on most hosts.
-**	27 Mar 93 (FM)	Added code for getting dates and sizes on VMS hosts.
-**
-** Notes:
-**			Portions Copyright 1994 Trustees of Dartmouth College
-**			Code for recognizing different FTP servers and
-**			parsing "ls -l" output taken from Macintosh Fetch
-**			program with permission from Jim Matthews,
-**			Dartmouth Software Development Team.
-*/
+ *			for a WorldWideWeb browser
+ *			===================================
+ *
+ *	A cache of control connections is kept.
+ *
+ * Note: Port allocation
+ *
+ *	It is essential that the port is allocated by the system, rather
+ *	than chosen in rotation by us (POLL_PORTS), or the following
+ *	problem occurs.
+ *
+ *	It seems that an attempt by the server to connect to a port which has
+ *	been used recently by a listen on the same socket, or by another
+ *	socket this or another process causes a hangup of (almost exactly)
+ *	one minute.  Therefore, we have to use a rotating port number.
+ *	The problem remains that if the application is run twice in quick
+ *	succession, it will hang for what remains of a minute.
+ *
+ * Authors
+ *	TBL	Tim Berners-lee <timbl@info.cern.ch>
+ *	DD	Denis DeLaRoca 310 825-4580 <CSP1DWD@mvs.oac.ucla.edu>
+ *	LM	Lou Montulli <montulli@ukanaix.cc.ukans.edu>
+ *	FM	Foteos Macrides <macrides@sci.wfeb.edu>
+ * History:
+ *	 2 May 91	Written TBL, as a part of the WorldWideWeb project.
+ *	15 Jan 92	Bug fix: close() was used for NETCLOSE for control soc
+ *	10 Feb 92	Retry if cached connection times out or breaks
+ *	 8 Dec 92	Bug fix 921208 TBL after DD
+ *	17 Dec 92	Anon FTP password now just WWWuser@ suggested by DD
+ *			fails on princeton.edu!
+ *	27 Dec 93 (FM)	Fixed up so FTP now works with VMS hosts.  Path
+ *			must be Unix-style and cannot include the device
+ *			or top directory.
+ *	?? ??? ?? (LM)	Added code to prompt and send passwords for non
+ *			anonymous FTP
+ *	25 Mar 94 (LM)	Added code to recognize different ftp server types
+ *			and code to parse dates and sizes on most hosts.
+ *	27 Mar 93 (FM)	Added code for getting dates and sizes on VMS hosts.
+ *
+ * Notes:
+ *			Portions Copyright 1994 Trustees of Dartmouth College
+ *			Code for recognizing different FTP servers and
+ *			parsing "ls -l" output taken from Macintosh Fetch
+ *			program with permission from Jim Matthews,
+ *			Dartmouth Software Development Team.
+ */
 
 /*
-BUGS:	@@@	Limit connection cache size!
-		Error reporting to user.
-		400 & 500 errors are ack'ed by user with windows.
-		Use configuration file for user names
-
-**		Note for portability this version does not use select() and
-**		so does not watch the control and data channels at the
-**		same time.
-*/
+ * BUGS:	@@@	Limit connection cache size!
+ * 		Error reporting to user.
+ * 		400 & 500 errors are ack'ed by user with windows.
+ * 		Use configuration file for user names
+ * 
+ *		Note for portability this version does not use select() and
+ *		so does not watch the control and data channels at the
+ *		same time.
+ */
 
 #include <HTUtils.h>
 
 #include <HTAlert.h>
 
-#include <HTFTP.h>	/* Implemented here */
+#include <HTFTP.h>		/* Implemented here */
 #include <HTTCP.h>
 #include <HTTP.h>
 #include <HTFont.h>
 
-#define REPEAT_PORT	/* Give the port number for each file */
-#define REPEAT_LISTEN	/* Close each listen socket and open a new one */
+#define REPEAT_PORT		/* Give the port number for each file */
+#define REPEAT_LISTEN		/* Close each listen socket and open a new one */
 
 /* define POLL_PORTS		 If allocation does not work, poll ourselves.*/
-#define LISTEN_BACKLOG 2	/* Number of pending connect requests (TCP)*/
+#define LISTEN_BACKLOG 2	/* Number of pending connect requests (TCP) */
 
 #define FIRST_TCP_PORT	1024	/* Region to try for a listening port */
 #define LAST_TCP_PORT	5999
@@ -79,7 +79,7 @@
 
 #include <HTParse.h>
 #include <HTAnchor.h>
-#include <HTFile.h>	/* For HTFileFormat() */
+#include <HTFile.h>		/* For HTFileFormat() */
 #include <HTBTree.h>
 #include <HTChunk.h>
 #ifndef IPPORT_FTP
@@ -92,16 +92,59 @@
 #include <LYLeaks.h>
 
 typedef struct _connection {
-    struct _connection *	next;	/* Link on list		*/
-    unsigned long		addr;	/* IP address		*/
-    int				socket; /* Socket number for communication */
-    BOOL			binary; /* Binary mode? */
+    struct _connection *next;	/* Link on list         */
+    unsigned long addr;		/* IP address           */
+    int socket;			/* Socket number for communication */
+    BOOL binary;		/* Binary mode? */
 } connection;
 
 /*		Hypertext object building machinery
 */
 #include <HTML.h>
 
+/*
+ * socklen_t is the standard, but there are many pre-standard variants.
+ * This ifdef works around a few of those cases.
+ *
+ * Information was obtained from header files on these platforms:
+ *	AIX 4.3.2, 5.1
+ *	HPUX 10.20, 11.00, 11.11
+ *	IRIX64 6.5
+ *	Tru64 4.0G, 4.0D, 5.1
+ */
+#if defined(SYS_IRIX64)
+	/* IRIX64 6.5 socket.h may use socklen_t if SGI_SOURCE is not defined */
+#  if _NO_XOPEN4 && _NO_XOPEN5
+#    define LY_SOCKLEN socklen_t
+#  elif _ABIAPI
+#    define LY_SOCKLEN int
+#  elif _XOPEN5
+#    if (_MIPS_SIM != _ABIO32)
+#      define LY_SOCKLEN socklen_t
+#    else
+#      define LY_SOCKLEN int
+#    endif
+#  else
+#    define LY_SOCKLEN size_t
+#  endif
+#elif defined(SYS_HPUX)
+#  if defined(_XOPEN_SOURCE_EXTENDED) && defined(SO_PROTOTYPE)
+#    define LY_SOCKLEN socklen_t
+#  else	/* HPUX 10.20, etc. */
+#    define LY_SOCKLEN int
+#  endif
+#elif defined(SYS_TRU64)
+#  if defined(_POSIX_PII_SOCKET)
+#    define LY_SOCKLEN socklen_t
+#  elif defined(_XOPEN_SOURCE_EXTENDED)
+#    define LY_SOCKLEN size_t
+#  else
+#    define LY_SOCKLEN int
+#  endif
+#else
+#  define LY_SOCKLEN socklen_t
+#endif
+
 #define PUTC(c)      (*targetClass.put_character) (target, c)
 #define PUTS(s)      (*targetClass.put_string)    (target, s)
 #define START(e)     (*targetClass.start_element) (target, e, 0, 0, -1, 0)
@@ -110,30 +153,30 @@
 #define ABORT_TARGET (*targetClass._free)         (target)
 
 struct _HTStructured {
-	CONST HTStructuredClass *	isa;
-	/* ... */
+    const HTStructuredClass *isa;
+    /* ... */
 };
 
 /*	Global Variables
-**	---------------------
-*/
-PUBLIC int HTfileSortMethod = FILE_BY_NAME;
+ *	---------------------
+ */
+int HTfileSortMethod = FILE_BY_NAME;
 
-#ifndef DISABLE_FTP /*This disables everything to end-of-file */
-PRIVATE char ThisYear[8];
-PRIVATE char LastYear[8];
-PRIVATE int TheDate;
-PRIVATE BOOLEAN HaveYears = FALSE;
+#ifndef DISABLE_FTP		/*This disables everything to end-of-file */
+static char ThisYear[8];
+static char LastYear[8];
+static int TheDate;
+static BOOLEAN HaveYears = FALSE;
 
 /*	Module-Wide Variables
-**	---------------------
-*/
-PRIVATE connection * connections = NULL;/* Linked list of connections */
-PRIVATE char response_text[LINE_LENGTH+1];/* Last response from ftp host */
-PRIVATE connection * control = NULL;	/* Current connection */
-PRIVATE int data_soc = -1;		/* Socket for data transfer =invalid */
-PRIVATE char *user_entered_password = NULL;
-PRIVATE char *last_username_and_host = NULL;
+ *	---------------------
+ */
+static connection *connections = NULL;	/* Linked list of connections */
+static char response_text[LINE_LENGTH + 1];	/* Last response from ftp host */
+static connection *control = NULL;	/* Current connection */
+static int data_soc = -1;	/* Socket for data transfer =invalid */
+static char *user_entered_password = NULL;
+static char *last_username_and_host = NULL;
 
 /*
  * ProFTPD 1.2.5rc1 is known to have a broken implementation of RETR.  If asked
@@ -142,60 +185,66 @@
  * at some point - TD 2004/1/1.
  */
 #define BROKEN_PROFTPD 1
-PRIVATE int ProFTPD_bugs = FALSE;
+static int ProFTPD_bugs = FALSE;
+
+/*
+ * wu-ftpd 2.6.2(12) is known to have a broken implementation of EPSV.  The
+ * server will hang for a long time when we attempt to connect after issuing
+ * this command - TD 2004/12/28
+ */
+#define BROKEN_WUFTPD 1
+static int WU_FTPD_bugs = FALSE;
 
 typedef enum {
-	GENERIC_SERVER
-	, MACHTEN_SERVER
-	, UNIX_SERVER
-	, VMS_SERVER
-	, CMS_SERVER
-	, DCTS_SERVER
-	, TCPC_SERVER
-	, PETER_LEWIS_SERVER
-	, NCSA_SERVER
-	, WINDOWS_NT_SERVER
-	, WINDOWS_2K_SERVER
-	, MS_WINDOWS_SERVER
-	, MSDOS_SERVER
-	, APPLESHARE_SERVER
-	, NETPRESENZ_SERVER
-	, DLS_SERVER
+    GENERIC_SERVER
+    ,MACHTEN_SERVER
+    ,UNIX_SERVER
+    ,VMS_SERVER
+    ,CMS_SERVER
+    ,DCTS_SERVER
+    ,TCPC_SERVER
+    ,PETER_LEWIS_SERVER
+    ,NCSA_SERVER
+    ,WINDOWS_NT_SERVER
+    ,WINDOWS_2K_SERVER
+    ,MS_WINDOWS_SERVER
+    ,MSDOS_SERVER
+    ,APPLESHARE_SERVER
+    ,NETPRESENZ_SERVER
+    ,DLS_SERVER
 } eServerType;
 
-PRIVATE eServerType server_type = GENERIC_SERVER; /* the type of ftp host */
-PRIVATE int	unsure_type = FALSE;		/* sure about the type? */
-PRIVATE BOOLEAN use_list = FALSE;		/* use the LIST command? */
+static eServerType server_type = GENERIC_SERVER;	/* the type of ftp host */
+static int unsure_type = FALSE;	/* sure about the type? */
+static BOOLEAN use_list = FALSE;	/* use the LIST command? */
 
-PRIVATE int	interrupted_in_next_data_char = FALSE;
+static int interrupted_in_next_data_char = FALSE;
 
 #ifdef POLL_PORTS
-PRIVATE PortNumber	port_number = FIRST_TCP_PORT;
+static PortNumber port_number = FIRST_TCP_PORT;
 #endif /* POLL_PORTS */
 
-PRIVATE int	master_socket = -1;	/* Listening socket = invalid	*/
-PRIVATE char	port_command[255];	/* Command for setting the port */
-PRIVATE fd_set	open_sockets;		/* Mask of active channels */
-PRIVATE int	num_sockets;		/* Number of sockets to scan */
-PRIVATE PortNumber	passive_port;	/* Port server specified for data */
-
+static int master_socket = -1;	/* Listening socket = invalid   */
+static char port_command[255];	/* Command for setting the port */
+static fd_set open_sockets;	/* Mask of active channels */
+static int num_sockets;		/* Number of sockets to scan */
+static PortNumber passive_port;	/* Port server specified for data */
 
 #define NEXT_CHAR HTGetCharacter()	/* Use function in HTFormat.c */
 
 #define DATA_BUFFER_SIZE 2048
-PRIVATE char data_buffer[DATA_BUFFER_SIZE];		/* Input data buffer */
-PRIVATE char * data_read_pointer;
-PRIVATE char * data_write_pointer;
-#define NEXT_DATA_CHAR next_data_char()
-PRIVATE int close_connection PARAMS((
-	connection *	con));
+static char data_buffer[DATA_BUFFER_SIZE];	/* Input data buffer */
+static char *data_read_pointer;
+static char *data_write_pointer;
 
+#define NEXT_DATA_CHAR next_data_char()
+static int close_connection(connection * con);
 
 #ifdef LY_FIND_LEAKS
 /*
-**  This function frees module globals. - FM
-*/
-PRIVATE void free_FTPGlobals NOARGS
+ *  This function frees module globals. - FM
+ */
+static void free_FTPGlobals(void)
 {
     FREE(user_entered_password);
     FREE(last_username_and_host);
@@ -208,76 +257,76 @@
 #endif /* LY_FIND_LEAKS */
 
 /* PUBLIC						HTVMS_name()
-**		CONVERTS WWW name into a VMS name
-** ON ENTRY:
-**	nn		Node Name (optional)
-**	fn		WWW file name
-**
-** ON EXIT:
-**	returns		vms file specification
-**
-** Bug: Returns pointer to static -- non-reentrant
-*/
-PUBLIC char * HTVMS_name ARGS2(
-	CONST char *,	nn,
-	CONST char *,	fn)
+ *		CONVERTS WWW name into a VMS name
+ * ON ENTRY:
+ *	nn		Node Name (optional)
+ *	fn		WWW file name
+ *
+ * ON EXIT:
+ *	returns		vms file specification
+ *
+ * Bug: Returns pointer to static -- non-reentrant
+ */
+char *HTVMS_name(const char *nn,
+		 const char *fn)
 {
-
-/*	We try converting the filename into Files-11 syntax.  That is, we assume
-**	first that the file is, like us, on a VMS node.  We try remote
-**	(or local) DECnet access.  Files-11, VMS, VAX and DECnet
-**	are trademarks of Digital Equipment Corporation.
-**	The node is assumed to be local if the hostname WITHOUT DOMAIN
-**	matches the local one. @@@
-*/
+    /* We try converting the filename into Files-11 syntax.  That is, we assume
+     * first that the file is, like us, on a VMS node.  We try remote (or
+     * local) DECnet access.  Files-11, VMS, VAX and DECnet are trademarks of
+     * Digital Equipment Corporation.  The node is assumed to be local if the
+     * hostname WITHOUT DOMAIN matches the local one.  @@@
+     */
     static char *vmsname;
-    char * filename = (char*)malloc(strlen(fn)+1);
-    char * nodename = (char*)malloc(strlen(nn)+2+1);	/* Copies to hack */
+    char *filename = (char *) malloc(strlen(fn) + 1);
+    char *nodename = (char *) malloc(strlen(nn) + 2 + 1);	/* Copies to hack */
     char *second;		/* 2nd slash */
     char *last;			/* last slash */
 
-    CONST char * hostname = HTHostName();
+    const char *hostname = HTHostName();
 
     if (!filename || !nodename)
 	outofmem(__FILE__, "HTVMSname");
     strcpy(filename, fn);
     strcpy(nodename, "");	/* On same node?  Yes if node names match */
     if (strncmp(nn, "localhost", 9)) {
-	CONST char *p;
-	CONST char *q;
+	const char *p;
+	const char *q;
+
 	for (p = hostname, q = nn;
-	     *p && *p != '.' && *q && *q != '.'; p++, q++){
+	     *p && *p != '.' && *q && *q != '.'; p++, q++) {
 	    if (TOUPPER(*p) != TOUPPER(*q)) {
 		char *r;
+
 		strcpy(nodename, nn);
 		r = strchr(nodename, '.');	/* Mismatch */
 		if (r)
-		    *r = '\0';			/* Chop domain */
+		    *r = '\0';	/* Chop domain */
 		strcat(nodename, "::");		/* Try decnet anyway */
 		break;
 	    }
 	}
     }
 
-    second = strchr(filename+1, '/');		/* 2nd slash */
+    second = strchr(filename + 1, '/');		/* 2nd slash */
     last = strrchr(filename, '/');	/* last slash */
 
-    if (!second) {				/* Only one slash */
+    if (!second) {		/* Only one slash */
 	HTSprintf0(&vmsname, "%s%s", nodename, filename + 1);
-    } else if (second == last) {		/* Exactly two slashes */
+    } else if (second == last) {	/* Exactly two slashes */
 	*second = '\0';		/* Split filename from disk */
-	HTSprintf0(&vmsname, "%s%s:%s", nodename, filename+1, second+1);
-	*second = '/';	/* restore */
-    } else {				/* More than two slashes */
-	char * p;
+	HTSprintf0(&vmsname, "%s%s:%s", nodename, filename + 1, second + 1);
+	*second = '/';		/* restore */
+    } else {			/* More than two slashes */
+	char *p;
+
 	*second = '\0';		/* Split disk from directories */
 	*last = '\0';		/* Split dir from filename */
 	HTSprintf0(&vmsname, "%s%s:[%s]%s",
-		nodename, filename+1, second+1, last+1);
+		   nodename, filename + 1, second + 1, last + 1);
 	*second = *last = '/';	/* restore filename */
-	for (p = strchr(vmsname, '['); *p!=']'; p++)
+	for (p = strchr(vmsname, '['); *p != ']'; p++)
 	    if (*p == '/')
-		*p = '.';		/* Convert dir sep.  to dots */
+		*p = '.';	/* Convert dir sep.  to dots */
     }
     FREE(nodename);
     FREE(filename);
@@ -285,23 +334,25 @@
 }
 
 /*	Procedure: Read a character from the data connection
-**	----------------------------------------------------
-*/
-PRIVATE int next_data_char NOARGS
+ *	----------------------------------------------------
+ */
+static int next_data_char(void)
 {
     int status;
+
     if (data_read_pointer >= data_write_pointer) {
 	status = NETREAD(data_soc, data_buffer, DATA_BUFFER_SIZE);
-      if (status == HT_INTERRUPTED)
-	interrupted_in_next_data_char = 1;
-      if (status <= 0)
-	return -1;
-      data_write_pointer = data_buffer + status;
-      data_read_pointer = data_buffer;
+	if (status == HT_INTERRUPTED)
+	    interrupted_in_next_data_char = 1;
+	if (status <= 0)
+	    return -1;
+	data_write_pointer = data_buffer + status;
+	data_read_pointer = data_buffer;
     }
 #ifdef NOT_ASCII
     {
 	char c = *data_read_pointer++;
+
 	return FROMASCII(c);
     }
 #else
@@ -309,15 +360,14 @@
 #endif /* NOT_ASCII */
 }
 
-
 /*	Close an individual connection
-**
-*/
-PRIVATE int close_connection ARGS1(
-	connection *,	con)
+ *
+ */
+static int close_connection(connection * con)
 {
-    connection * scan;
+    connection *scan;
     int status;
+
     CTRACE((tfp, "HTFTP: Closing control socket %d\n", con->socket));
     status = NETCLOSE(con->socket);
     if (TRACE && status != 0) {
@@ -337,82 +387,82 @@
 	if (scan->next == con) {
 	    scan->next = con->next;	/* Unlink */
 	    if (control == con)
-		control = (connection*)0;
+		control = (connection *) 0;
 	    return status;
-	} /*if */
-    } /* for */
-    return -1;		/* very strange -- was not on list. */
+	}			/*if */
+    }				/* for */
+    return -1;			/* very strange -- was not on list. */
 }
 
-PRIVATE char *help_message_buffer = NULL;  /* global :( */
+static char *help_message_buffer = NULL;	/* global :( */
 
-PRIVATE void init_help_message_cache NOARGS
+static void init_help_message_cache(void)
 {
     FREE(help_message_buffer);
 }
 
-PRIVATE void help_message_cache_add ARGS1(
-	char *,		string)
+static void help_message_cache_add(char *string)
 {
     if (help_message_buffer)
 	StrAllocCat(help_message_buffer, string);
     else
 	StrAllocCopy(help_message_buffer, string);
 
-    CTRACE((tfp,"Adding message to help cache: %s\n",string));
+    CTRACE((tfp, "Adding message to help cache: %s\n", string));
 }
 
-PRIVATE char *help_message_cache_non_empty NOARGS
+static char *help_message_cache_non_empty(void)
 {
-  return(help_message_buffer);
+    return (help_message_buffer);
 }
 
-PRIVATE char *help_message_cache_contents NOARGS
+static char *help_message_cache_contents(void)
 {
-   return(help_message_buffer);
+    return (help_message_buffer);
 }
 
 /*	Send One Command
-**	----------------
-**
-**	This function checks whether we have a control connection, and sends
-**	one command if given.
-**
-** On entry,
-**	control	points to the connection which is established.
-**	cmd	points to a command, or is zero to just get the response.
-**
-**	The command should already be terminated with the CRLF pair.
-**
-** On exit,
-**	returns:  1 for success,
-**		  or negative for communication failure (in which case
-**		  the control connection will be closed).
-*/
-PRIVATE int write_cmd ARGS1(
-	char *,		cmd)
+ *	----------------
+ *
+ *	This function checks whether we have a control connection, and sends
+ *	one command if given.
+ *
+ * On entry,
+ *	control	points to the connection which is established.
+ *	cmd	points to a command, or is zero to just get the response.
+ *
+ *	The command should already be terminated with the CRLF pair.
+ *
+ * On exit,
+ *	returns:  1 for success,
+ *		  or negative for communication failure (in which case
+ *		  the control connection will be closed).
+ */
+static int write_cmd(const char *cmd)
 {
     int status;
 
     if (!control) {
 	CTRACE((tfp, "HTFTP: No control connection set up!!\n"));
-	return -99;
+	return HT_NO_CONNECTION;
     }
 
     if (cmd) {
 	CTRACE((tfp, "  Tx: %s", cmd));
 #ifdef NOT_ASCII
 	{
-	    char * p;
+	    char *p;
+
 	    for (p = cmd; *p; p++) {
 		*p = TOASCII(*p);
 	    }
 	}
 #endif /* NOT_ASCII */
-	status = NETWRITE(control->socket, cmd, (int)strlen(cmd));
+	status = NETWRITE(control->socket, cmd, (int) strlen(cmd));
 	if (status < 0) {
-	    CTRACE((tfp, "HTFTP: Error %d sending command: closing socket %d\n",
-			status, control->socket));
+	    CTRACE((tfp,
+		    "HTFTP: Error %d sending command: closing socket %d\n",
+		    status, control->socket));
 	    close_connection(control);
 	    return status;
 	}
@@ -421,30 +471,29 @@
 }
 
 /*	Execute Command and get Response
-**	--------------------------------
-**
-**	See the state machine illustrated in RFC959, p57. This implements
-**	one command/reply sequence.  It also interprets lines which are to
-**	be continued, which are marked with a "-" immediately after the
-**	status code.
-**
-**	Continuation then goes on until a line with a matching reply code
-**	an a space after it.
-**
-** On entry,
-**	control	points to the connection which is established.
-**	cmd	points to a command, or is zero to just get the response.
-**
-**	The command must already be terminated with the CRLF pair.
-**
-** On exit,
-**	returns:  The first digit of the reply type,
-**		  or negative for communication failure.
-*/
-PRIVATE int response ARGS1(
-	char *,		cmd)
+ *	--------------------------------
+ *
+ *	See the state machine illustrated in RFC959, p57. This implements
+ *	one command/reply sequence.  It also interprets lines which are to
+ *	be continued, which are marked with a "-" immediately after the
+ *	status code.
+ *
+ *	Continuation then goes on until a line with a matching reply code
+ *	an a space after it.
+ *
+ * On entry,
+ *	control	points to the connection which is established.
+ *	cmd	points to a command, or is zero to just get the response.
+ *
+ *	The command must already be terminated with the CRLF pair.
+ *
+ * On exit,
+ *	returns:  The first digit of the reply type,
+ *		  or negative for communication failure.
+ */
+static int response(const char *cmd)
 {
-    int result;				/* Three-digit decimal code */
+    int result;			/* Three-digit decimal code */
     int continuation_response = -1;
     int status;
 
@@ -453,37 +502,40 @@
 
     do {
 	char *p = response_text;
+
 	for (;;) {
 	    int ich = NEXT_CHAR;
+
 	    if (((*p++ = (char) ich) == LF)
-			|| (p == &response_text[LINE_LENGTH])) {
+		|| (p == &response_text[LINE_LENGTH])) {
 
 		char continuation;
 
 		if (interrupted_in_htgetcharacter) {
-		    CTRACE((tfp, "HTFTP: Interrupted in HTGetCharacter, apparently.\n"));
-		    NETCLOSE (control->socket);
+		    CTRACE((tfp,
+			    "HTFTP: Interrupted in HTGetCharacter, apparently.\n"));
+		    NETCLOSE(control->socket);
 		    control->socket = -1;
 		    return HT_INTERRUPTED;
 		}
 
-		*p = '\0';			/* Terminate the string */
+		*p = '\0';	/* Terminate the string */
 		CTRACE((tfp, "    Rx: %s", response_text));
 
 		/* Check for login or help messages */
-		if (!strncmp(response_text,"230-",4) ||
-		    !strncmp(response_text,"250-",4) ||
-		    !strncmp(response_text,"220-",4))
-		    help_message_cache_add(response_text+4);
+		if (!strncmp(response_text, "230-", 4) ||
+		    !strncmp(response_text, "250-", 4) ||
+		    !strncmp(response_text, "220-", 4))
+		    help_message_cache_add(response_text + 4);
 
 		sscanf(response_text, "%d%c", &result, &continuation);
-		if  (continuation_response == -1) {
-			if (continuation == '-')  /* start continuation */
-			    continuation_response = result;
+		if (continuation_response == -1) {
+		    if (continuation == '-')	/* start continuation */
+			continuation_response = result;
 		} else {	/* continuing */
-			if (continuation_response == result &&
-			    continuation == ' ')
-			    continuation_response = -1; /* ended */
+		    if (continuation_response == result &&
+			continuation == ' ')
+			continuation_response = -1;	/* ended */
 		}
 #ifdef BROKEN_PROFTPD
 		if (result == 220 && LYstrstr(response_text, "ProFTPD 1.2.5")) {
@@ -491,30 +543,38 @@
 		    CTRACE((tfp, "This server is broken (RETR)\n"));
 		}
 #endif
+#ifdef BROKEN_WUFTPD
+		if (result == 220 && LYstrstr(response_text,
+					      "(Version wu-2.6.2-12)")) {
+		    WU_FTPD_bugs = TRUE;
+		    CTRACE((tfp, "This server is broken (EPSV)\n"));
+		}
+#endif
 		break;
-	    } /* if end of line */
-
+	    }
+	    /* if end of line */
 	    if (interrupted_in_htgetcharacter) {
-		CTRACE((tfp, "HTFTP: Interrupted in HTGetCharacter, apparently.\n"));
-		NETCLOSE (control->socket);
+		CTRACE((tfp,
+			"HTFTP: Interrupted in HTGetCharacter, apparently.\n"));
+		NETCLOSE(control->socket);
 		control->socket = -1;
 		return HT_INTERRUPTED;
 	    }
 
 	    if (ich == EOF) {
 		CTRACE((tfp, "Error on rx: closing socket %d\n",
-			    control->socket));
+			control->socket));
 		strcpy(response_text, "000 *** TCP read error on response\n");
 		close_connection(control);
 		return -1;	/* End of file on response */
 	    }
-	} /* Loop over characters */
+	}			/* Loop over characters */
 
     } while (continuation_response != -1);
 
     if (result == 421) {
 	CTRACE((tfp, "HTFTP: They close so we close socket %d\n",
-		    control->socket));
+		control->socket));
 	close_connection(control);
 	return -1;
     }
@@ -522,28 +582,28 @@
 	(0 == strncasecomp(cmd, "CWD", 3) ||
 	 0 == strcasecomp(cmd, "CDUP"))) {
 	/*
-	**  Alas, CMS returns 255 on failure to CWD to parent of root. - PG
-	*/
+	 * Alas, CMS returns 255 on failure to CWD to parent of root.  - PG
+	 */
 	result = 555;
     }
-    return result/100;
+    return result / 100;
 }
 
-PRIVATE int send_cmd_1 ARGS1(char *, verb)
+static int send_cmd_1(const char *verb)
 {
     char command[80];
 
-    sprintf(command, "%.*s%c%c", (int) sizeof(command)-4, verb, CR, LF);
-    return response (command);
+    sprintf(command, "%.*s%c%c", (int) sizeof(command) - 4, verb, CR, LF);
+    return response(command);
 }
 
-PRIVATE int send_cmd_2 ARGS2(char *, verb, char *, param)
+static int send_cmd_2(const char *verb, const char *param)
 {
     char *command = 0;
     int status;
 
     HTSprintf0(&command, "%s %s%c%c", verb, param, CR, LF);
-    status = response (command);
+    status = response(command);
     FREE(command);
 
     return status;
@@ -552,21 +612,20 @@
 #define send_cwd(path) send_cmd_2("CWD", path)
 
 /*
- *  This function should try to set the macintosh server into binary mode.
- *  Some servers need an additional letter after the MACB command.
+ * This function should try to set the macintosh server into binary mode.  Some
+ * servers need an additional letter after the MACB command.
  */
-PRIVATE int set_mac_binary ARGS1(
-	eServerType,	ServerType)
+static int set_mac_binary(eServerType ServerType)
 {
     /* try to set mac binary mode */
     if (ServerType == APPLESHARE_SERVER ||
 	ServerType == NETPRESENZ_SERVER) {
 	/*
-	 *  Presumably E means "Enable".  - KW
+	 * Presumably E means "Enable".  - KW
 	 */
-	return(2 == response("MACB E\r\n"));
+	return (2 == response("MACB E\r\n"));
     } else {
-	return(2 == response("MACB\r\n"));
+	return (2 == response("MACB\r\n"));
     }
 }
 
@@ -574,26 +633,25 @@
  * determine what kind of host it is
  */
 
-PRIVATE void get_ftp_pwd ARGS2(
-	eServerType *,	ServerType,
-	BOOLEAN *,	UseList)
+static void get_ftp_pwd(eServerType *ServerType, BOOLEAN *UseList)
 {
-
     char *cp;
+
     /* get the working directory (to see what it looks like) */
     int status = response("PWD\r\n");
+
     if (status < 0) {
 	return;
     } else {
-	cp = strchr(response_text+5,'"');
+	cp = strchr(response_text + 5, '"');
 	if (cp)
 	    *cp = '\0';
 	if (*ServerType == TCPC_SERVER) {
 	    *ServerType = ((response_text[5] == '/') ?
-					  NCSA_SERVER : TCPC_SERVER);
+			   NCSA_SERVER : TCPC_SERVER);
 	    CTRACE((tfp, "HTFTP: Treating as %s server.\n",
-			 ((*ServerType == NCSA_SERVER) ?
-						 "NCSA" : "TCPC")));
+		    ((*ServerType == NCSA_SERVER) ?
+		     "NCSA" : "TCPC")));
 	} else if (response_text[5] == '/') {
 	    /* path names beginning with / imply Unix,
 	     * right?
@@ -602,12 +660,12 @@
 		*ServerType = NCSA_SERVER;
 		CTRACE((tfp, "HTFTP: Treating as NCSA server.\n"));
 	    } else {
-		 *ServerType = UNIX_SERVER;
-		 *UseList = TRUE;
-		 CTRACE((tfp, "HTFTP: Treating as Unix server.\n"));
+		*ServerType = UNIX_SERVER;
+		*UseList = TRUE;
+		CTRACE((tfp, "HTFTP: Treating as Unix server.\n"));
 	    }
 	    return;
-	} else if (response_text[strlen(response_text)-1] == ']') {
+	} else if (response_text[strlen(response_text) - 1] == ']') {
 	    /* path names ending with ] imply VMS, right? */
 	    *ServerType = VMS_SERVER;
 	    *UseList = TRUE;
@@ -629,17 +687,16 @@
  * Windows NT servers.
  */
 
-PRIVATE void set_unix_dirstyle ARGS2(
-	eServerType *,	ServerType,
-	BOOLEAN *,	UseList)
+static void set_unix_dirstyle(eServerType *ServerType, BOOLEAN *UseList)
 {
-
     char *cp;
+
     /* This is a toggle.  It seems we have to toggle in order to see
      * the current state (after toggling), so we may end up toggling
      * twice.  - kw
      */
     int status = response("SITE DIRSTYLE\r\n");
+
     if (status != 2) {
 	*ServerType = GENERIC_SERVER;
 	CTRACE((tfp, "HTFTP: DIRSTYLE failed, treating as Generic server.\n"));
@@ -655,7 +712,7 @@
 	 * anyway, under the assumption that it's more likely that
 	 * the MSDOS setting was "off" originally. - kw
 	 */
-	cp = strstr(response_text+4, "MSDOS");
+	cp = strstr(response_text + 4, "MSDOS");
 	if (cp && strstr(cp, " off")) {
 	    return;		/* already off now. */
 	} else {
@@ -665,35 +722,34 @@
 }
 
 /*	Get a valid connection to the host
-**	----------------------------------
-**
-** On entry,
-**	arg	points to the name of the host in a hypertext address
-** On exit,
-**	returns <0 if error
-**		socket number if success
-**
-**	This routine takes care of managing timed-out connections, and
-**	limiting the number of connections in use at any one time.
-**
-**	It ensures that all connections are logged in if they exist.
-**	It ensures they have the port number transferred.
-*/
-PRIVATE int get_connection ARGS2(
-	CONST char *,		arg,
-	HTParentAnchor *,	anchor)
+ *	----------------------------------
+ *
+ * On entry,
+ *	arg	points to the name of the host in a hypertext address
+ * On exit,
+ *	returns <0 if error
+ *		socket number if success
+ *
+ *	This routine takes care of managing timed-out connections, and
+ *	limiting the number of connections in use at any one time.
+ *
+ *	It ensures that all connections are logged in if they exist.
+ *	It ensures they have the port number transferred.
+ */
+static int get_connection(const char *arg,
+			  HTParentAnchor *anchor)
 {
     int status;
-    char * command = 0;
-    connection * con;
-    char * username = NULL;
-    char * password = NULL;
+    char *command = 0;
+    connection *con;
+    char *username = NULL;
+    char *password = NULL;
     static BOOLEAN firstuse = TRUE;
 
     if (firstuse) {
 	/*
-	**  Set up freeing at exit. - FM
-	*/
+	 * Set up freeing at exit.  - FM
+	 */
 #ifdef LY_FIND_LEAKS
 	atexit(free_FTPGlobals);
 #endif
@@ -702,8 +758,8 @@
 
     if (control) {
 	/*
-	**  Reuse this object - KW, DW & FM
-	*/
+	 * Reuse this object - KW, DW & FM
+	 */
 	if (control->socket != -1) {
 	    NETCLOSE(control->socket);
 	}
@@ -712,16 +768,18 @@
 	con->binary = FALSE;
     } else {
 	/*
-	**  Allocate and init control struct.
-	*/
+	 * Allocate and init control struct.
+	 */
 	con = typecalloc(connection);
 	if (con == NULL)
 	    outofmem(__FILE__, "get_connection");
     }
     con->socket = -1;
 
-    if (!arg) return -1;		/* Bad if no name specified	*/
-    if (!*arg) return -1;		/* Bad if name had zero length	*/
+    if (!arg)
+	return -1;		/* Bad if no name specified     */
+    if (!*arg)
+	return -1;		/* Bad if name had zero length  */
 
 /* Get node name:
 */
@@ -729,12 +787,12 @@
     {
 	char *p1 = HTParse(arg, "", PARSE_HOST);
 	char *p2 = strrchr(p1, '@');	/* user? */
-	char * pw = NULL;
+	char *pw = NULL;
 
 	if (p2 != NULL) {
 	    username = p1;
-	    *p2 = '\0';			/* terminate */
-	    p1 = p2+1;			/* point to host */
+	    *p2 = '\0';		/* terminate */
+	    p1 = p2 + 1;	/* point to host */
 	    pw = strchr(username, ':');
 	    if (pw != NULL) {
 		*pw++ = '\0';
@@ -744,19 +802,18 @@
 		HTUnEscape(username);
 
 	    /*
-	     *	If the password doesn't exist then we are going to have
-	     *	to ask the user for it.  The only problem is that we
-	     *	don't want to ask for it every time, so we will store
-	     *	away in a primitive fashion.
+	     * If the password doesn't exist then we are going to have to ask
+	     * the user for it.  The only problem is that we don't want to ask
+	     * for it every time, so we will store away in a primitive fashion.
 	     */
 	    if (!password) {
 		char *tmp = NULL;
 
 		HTSprintf0(&tmp, "%s@%s", username, p1);
 		/*
-		 *  If the user@host is not equal to the last time through
-		 *  or user_entered_password has no data then we need
-		 *  to ask the user for the password.
+		 * If the user@host is not equal to the last time through or
+		 * user_entered_password has no data then we need to ask the
+		 * user for the password.
 		 */
 		if (!last_username_and_host ||
 		    strcmp(tmp, last_username_and_host) ||
@@ -764,11 +821,11 @@
 
 		    StrAllocCopy(last_username_and_host, tmp);
 		    HTSprintf0(&tmp, gettext("Enter password for user %s@%s:"),
-				     username, p1);
+			       username, p1);
 		    FREE(user_entered_password);
 		    user_entered_password = HTPromptPassword(tmp);
 
-		} /* else we already know the password */
+		}		/* else we already know the password */
 		password = user_entered_password;
 		FREE(tmp);
 	    }
@@ -776,51 +833,49 @@
 
 	if (!username)
 	    FREE(p1);
-    } /* scope of p1 */
+    }				/* scope of p1 */
 
-    status = HTDoConnect (arg, "FTP", IPPORT_FTP, (int *)&con->socket);
+    status = HTDoConnect(arg, "FTP", IPPORT_FTP, (int *) &con->socket);
 
     if (status < 0) {
 	if (status == HT_INTERRUPTED) {
 	    CTRACE((tfp, "HTFTP: Interrupted on connect\n"));
 	} else {
 	    CTRACE((tfp, "HTFTP: Unable to connect to remote host for `%s'.\n",
-			arg));
+		    arg));
 	}
 	if (status == HT_INTERRUPTED) {
-	    _HTProgress (CONNECTION_INTERRUPTED);
+	    _HTProgress(CONNECTION_INTERRUPTED);
 	    status = HT_NOT_LOADED;
 	} else {
 	    HTAlert(gettext("Unable to connect to FTP host."));
 	}
-	if (con->socket != -1)
-	{
-	  NETCLOSE(con->socket);
+	if (con->socket != -1) {
+	    NETCLOSE(con->socket);
 	}
 
 	FREE(username);
 	if (control == con)
 	    control = NULL;
 	FREE(con);
-	return status;			/* Bad return */
+	return status;		/* Bad return */
     }
 
     CTRACE((tfp, "FTP connected, socket %d  control %p\n",
-		con->socket, con));
+	    con->socket, con));
     control = con;		/* Current control connection */
 
     /* Initialise buffering for control connection */
     HTInitInput(control->socket);
     init_help_message_cache();	/* Clear the login message buffer. */
 
-
 /*	Now we log in		Look up username, prompt for pw.
 */
-    status = response((char *)0);	/* Get greeting */
+    status = response((char *) 0);	/* Get greeting */
 
     if (status == HT_INTERRUPTED) {
 	CTRACE((tfp, "HTFTP: Interrupted at beginning of login.\n"));
-	_HTProgress (CONNECTION_INTERRUPTED);
+	_HTProgress(CONNECTION_INTERRUPTED);
 	NETCLOSE(control->socket);
 	control->socket = -1;
 	return HT_INTERRUPTED;
@@ -849,7 +904,7 @@
 
 	if (status == HT_INTERRUPTED) {
 	    CTRACE((tfp, "HTFTP: Interrupted while sending username.\n"));
-	    _HTProgress (CONNECTION_INTERRUPTED);
+	    _HTProgress(CONNECTION_INTERRUPTED);
 	    NETCLOSE(control->socket);
 	    control->socket = -1;
 	    return HT_INTERRUPTED;
@@ -865,30 +920,27 @@
 	    /*
 	     * Create and send a mail address as the password. - FM
 	     */
+	    char *the_address;
 	    char *user = NULL;
-	    CONST char *host = NULL;
-	    char * cp;
+	    const char *host = NULL;
+	    char *cp;
 
-	    if (personal_mail_address && *personal_mail_address) {
-		/*
-		 * We have a non-zero length personal
-		 * mail address, so use that. - FM
-		 */
-		StrAllocCopy(user, personal_mail_address);
-		if ((cp=strchr(user, '@')) != NULL) {
-		    *cp++ = '\0';
-		    host = cp;
-		} else {
+	    the_address = anonftp_password;
+	    if (isEmpty(the_address))
+		the_address = personal_mail_address;
+	    if (isEmpty(the_address))
+		the_address = LYGetEnv("USER");
+	    if (isEmpty(the_address))
+		the_address = "WWWuser";
+
+	    StrAllocCopy(user, the_address);
+	    if ((cp = strchr(user, '@')) != NULL) {
+		*cp++ = '\0';
+		if (*cp == '\0')
 		    host = HTHostName();
-		}
-	    } else {
-		/*
-		 * Use an environment variable and the host global. - FM
-		 */
-		if ((cp=LYGetEnv("USER")) != NULL)
-		    StrAllocCopy(user, cp);
 		else
-		    StrAllocCopy(user, "WWWuser");
+		    host = cp;
+	    } else {
 		host = HTHostName();
 	    }
 
@@ -906,7 +958,7 @@
 	FREE(command);
 	if (status == HT_INTERRUPTED) {
 	    CTRACE((tfp, "HTFTP: Interrupted while sending password.\n"));
-	    _HTProgress (CONNECTION_INTERRUPTED);
+	    _HTProgress(CONNECTION_INTERRUPTED);
 	    NETCLOSE(control->socket);
 	    control->socket = -1;
 	    return HT_INTERRUPTED;
@@ -918,7 +970,7 @@
 	status = send_cmd_1("ACCT noaccount");
 	if (status == HT_INTERRUPTED) {
 	    CTRACE((tfp, "HTFTP: Interrupted while sending password.\n"));
-	    _HTProgress (CONNECTION_INTERRUPTED);
+	    _HTProgress(CONNECTION_INTERRUPTED);
 	    NETCLOSE(control->socket);
 	    control->socket = -1;
 	    return HT_INTERRUPTED;
@@ -932,36 +984,37 @@
     }
     CTRACE((tfp, "HTFTP: Logged in.\n"));
 
-    /** Check for host type **/
+    /* Check for host type */
     if (server_type != NETPRESENZ_SERVER)
 	server_type = GENERIC_SERVER;	/* reset */
-    use_list = FALSE;			/* reset */
-    if ((status=response("SYST\r\n")) == 2) {
+    use_list = FALSE;		/* reset */
+    if ((status = response("SYST\r\n")) == 2) {
 	/* we got a line -- what kind of server are we talking to? */
-	if (strncmp(response_text+4,
+	if (strncmp(response_text + 4,
 		    "UNIX Type: L8 MAC-OS MachTen", 28) == 0) {
 	    server_type = MACHTEN_SERVER;
 	    use_list = TRUE;
 	    CTRACE((tfp, "HTFTP: Treating as MachTen server.\n"));
 
-	} else if (strstr(response_text+4, "UNIX") != NULL ||
-		   strstr(response_text+4, "Unix") != NULL) {
+	} else if (strstr(response_text + 4, "UNIX") != NULL ||
+		   strstr(response_text + 4, "Unix") != NULL) {
 	    server_type = UNIX_SERVER;
-	    unsure_type = FALSE; /* to the best of out knowledge... */
+	    unsure_type = FALSE;	/* to the best of out knowledge... */
 	    use_list = TRUE;
 	    CTRACE((tfp, "HTFTP: Treating as Unix server.\n"));
 
-	} else if (strstr(response_text+4, "MSDOS") != NULL) {
+	} else if (strstr(response_text + 4, "MSDOS") != NULL) {
 	    server_type = MSDOS_SERVER;
 	    use_list = TRUE;
 	    CTRACE((tfp, "HTFTP: Treating as MSDOS (Unix emulation) server.\n"));
 
-	} else if (strncmp(response_text+4, "VMS", 3) == 0) {
+	} else if (strncmp(response_text + 4, "VMS", 3) == 0) {
 	    char *tilde = strstr(arg, "/~");
+
 	    use_list = TRUE;
 	    if (tilde != 0
-	     && tilde[2] != 0
-	     && strstr(response_text+4, "MadGoat") != 0) {
+		&& tilde[2] != 0
+		&& strstr(response_text + 4, "MadGoat") != 0) {
 		server_type = UNIX_SERVER;
 		CTRACE((tfp, "HTFTP: Treating VMS as UNIX server.\n"));
 	    } else {
@@ -969,64 +1022,64 @@
 		CTRACE((tfp, "HTFTP: Treating as VMS server.\n"));
 	    }
 
-	} else if ((strncmp(response_text+4, "VM/CMS", 6) == 0) ||
-		   (strncmp(response_text+4, "VM ", 3) == 0)) {
+	} else if ((strncmp(response_text + 4, "VM/CMS", 6) == 0) ||
+		   (strncmp(response_text + 4, "VM ", 3) == 0)) {
 	    server_type = CMS_SERVER;
 	    use_list = TRUE;
 	    CTRACE((tfp, "HTFTP: Treating as CMS server.\n"));
 
-	} else if (strncmp(response_text+4, "DCTS", 4) == 0) {
+	} else if (strncmp(response_text + 4, "DCTS", 4) == 0) {
 	    server_type = DCTS_SERVER;
 	    CTRACE((tfp, "HTFTP: Treating as DCTS server.\n"));
 
-	} else if (strstr(response_text+4, "MAC-OS TCP/Connect II") != NULL) {
+	} else if (strstr(response_text + 4, "MAC-OS TCP/Connect II") != NULL) {
 	    server_type = TCPC_SERVER;
 	    CTRACE((tfp, "HTFTP: Looks like a TCPC server.\n"));
 	    get_ftp_pwd(&server_type, &use_list);
 	    unsure_type = TRUE;
 
-	} else if (server_type == NETPRESENZ_SERVER) { /* already set above */
+	} else if (server_type == NETPRESENZ_SERVER) {	/* already set above */
 	    use_list = TRUE;
 	    set_mac_binary(server_type);
 	    CTRACE((tfp, "HTFTP: Treating as NetPresenz (MACOS) server.\n"));
 
-	} else if (strncmp(response_text+4, "MACOS Peter's Server", 20) == 0) {
+	} else if (strncmp(response_text + 4, "MACOS Peter's Server", 20) == 0) {
 	    server_type = PETER_LEWIS_SERVER;
 	    use_list = TRUE;
 	    set_mac_binary(server_type);
 	    CTRACE((tfp, "HTFTP: Treating as Peter Lewis (MACOS) server.\n"));
 
-	} else if (strncmp(response_text+4, "Windows_NT", 10) == 0) {
+	} else if (strncmp(response_text + 4, "Windows_NT", 10) == 0) {
 	    server_type = WINDOWS_NT_SERVER;
 	    CTRACE((tfp, "HTFTP: Treating as Window_NT server.\n"));
 	    set_unix_dirstyle(&server_type, &use_list);
 
-	} else if (strncmp(response_text+4, "Windows2000", 11) == 0) {
+	} else if (strncmp(response_text + 4, "Windows2000", 11) == 0) {
 	    server_type = WINDOWS_2K_SERVER;
 	    CTRACE((tfp, "HTFTP: Treating as Window_2K server.\n"));
 	    set_unix_dirstyle(&server_type, &use_list);
 
-	} else if (strncmp(response_text+4, "MS Windows", 10) == 0) {
+	} else if (strncmp(response_text + 4, "MS Windows", 10) == 0) {
 	    server_type = MS_WINDOWS_SERVER;
 	    use_list = TRUE;
 	    CTRACE((tfp, "HTFTP: Treating as MS Windows server.\n"));
 
-	} else if (strncmp(response_text+4,
+	} else if (strncmp(response_text + 4,
 			   "MACOS AppleShare IP FTP Server", 30) == 0) {
 	    server_type = APPLESHARE_SERVER;
 	    use_list = TRUE;
 	    set_mac_binary(server_type);
 	    CTRACE((tfp, "HTFTP: Treating as AppleShare server.\n"));
 
-	} else	{
+	} else {
 	    server_type = GENERIC_SERVER;
 	    CTRACE((tfp, "HTFTP: Ugh!  A Generic server.\n"));
 	    get_ftp_pwd(&server_type, &use_list);
 	    unsure_type = TRUE;
-	 }
+	}
     } else {
 	/* SYST fails :(  try to get the type from the PWD command */
-	 get_ftp_pwd(&server_type, &use_list);
+	get_ftp_pwd(&server_type, &use_list);
     }
 
 /*  Now we inform the server of the port number we will listen on
@@ -1034,24 +1087,24 @@
 #ifdef NOTREPEAT_PORT
     {
 	int status = response(port_command);
+
 	if (status != 2) {
 	    if (control->socket)
 		close_connection(control->socket);
-	    return -status;		/* Bad return */
+	    return -status;	/* Bad return */
 	}
 	CTRACE((tfp, "HTFTP: Port defined.\n"));
     }
 #endif /* NOTREPEAT_PORT */
-    return con->socket;			/* Good return */
+    return con->socket;		/* Good return */
 }
 
-
 /*	Close Master (listening) socket
-**	-------------------------------
-**
-**
-*/
-PRIVATE int close_master_socket NOARGS
+ *	-------------------------------
+ *
+ *
+ */
+static int close_master_socket(void)
 {
     int status;
 
@@ -1066,51 +1119,50 @@
 	return status;
 }
 
-
 /*	Open a master socket for listening on
-**	-------------------------------------
-**
-**	When data is transferred, we open a port, and wait for the server to
-**	connect with the data.
-**
-** On entry,
-**	master_socket	Must be negative if not set up already.
-** On exit,
-**	Returns		socket number if good
-**			less than zero if error.
-**	master_socket	is socket number if good, else negative.
-**	port_number	is valid if good.
-*/
-PRIVATE int get_listen_socket NOARGS
+ *	-------------------------------------
+ *
+ *	When data is transferred, we open a port, and wait for the server to
+ *	connect with the data.
+ *
+ * On entry,
+ *	master_socket	Must be negative if not set up already.
+ * On exit,
+ *	Returns		socket number if good
+ *			less than zero if error.
+ *	master_socket	is socket number if good, else negative.
+ *	port_number	is valid if good.
+ */
+static int get_listen_socket(void)
 {
 #ifdef INET6
     struct sockaddr_storage soc_address;	/* Binary network address */
-    struct sockaddr_in* soc_in = (struct sockaddr_in *)&soc_address;
+    struct sockaddr_in *soc_in = (struct sockaddr_in *) &soc_address;
     int af;
-    int slen;
+    LY_SOCKLEN slen;
+
 #else
     struct sockaddr_in soc_address;	/* Binary network address */
-    struct sockaddr_in* soc_in = &soc_address;
+    struct sockaddr_in *soc_in = &soc_address;
 #endif /* INET6 */
-    int new_socket;			/* Will be master_socket */
-
+    int new_socket;		/* Will be master_socket */
 
     FD_ZERO(&open_sockets);	/* Clear our record of open sockets */
     num_sockets = 0;
 
 #ifndef REPEAT_LISTEN
     if (master_socket >= 0)
-	return master_socket;  /* Done already */
+	return master_socket;	/* Done already */
 #endif /* !REPEAT_LISTEN */
 
 #ifdef INET6
     /* query address family of control connection */
     slen = sizeof(soc_address);
-    if (getsockname(control->socket, (struct sockaddr *)&soc_address,
-		&slen) < 0) {
+    if (getsockname(control->socket, (struct sockaddr *) &soc_address,
+		    &slen) < 0) {
 	return HTInetStatus("getsockname failed");
     }
-    af = ((struct sockaddr *)&soc_address)->sa_family;
+    af = ((struct sockaddr *) &soc_address)->sa_family;
     memset(&soc_address, 0, sizeof(soc_address));
 #endif /* INET6 */
 
@@ -1131,30 +1183,32 @@
 */
 #ifdef INET6
     memset(&soc_address, 0, sizeof(soc_address));
-    ((struct sockaddr *)&soc_address)->sa_family = af;
+    ((struct sockaddr *) &soc_address)->sa_family = af;
     switch (af) {
     case AF_INET:
 #ifdef SIN6_LEN
-	((struct sockaddr *)&soc_address)->sa_len = sizeof(struct sockaddr_in);
+	((struct sockaddr *) &soc_address)->sa_len = sizeof(struct sockaddr_in);
 #endif /* SIN6_LEN */
 	break;
     case AF_INET6:
 #ifdef SIN6_LEN
-	((struct sockaddr *)&soc_address)->sa_len = sizeof(struct sockaddr_in6);
+	((struct sockaddr *) &soc_address)->sa_len = sizeof(struct sockaddr_in6);
 #endif /* SIN6_LEN */
 	break;
     default:
 	HTInetStatus("AF");
     }
 #else
-    soc_in->sin_family = AF_INET;	    /* Family = internet, host order  */
-    soc_in->sin_addr.s_addr = INADDR_ANY;   /* Any peer address */
+    soc_in->sin_family = AF_INET;	/* Family = internet, host order  */
+    soc_in->sin_addr.s_addr = INADDR_ANY;	/* Any peer address */
 #endif /* INET6 */
 #ifdef POLL_PORTS
     {
 	PortNumber old_port_number = port_number;
-	for (port_number = (old_port_number+1); ; port_number++) {
+
+	for (port_number = (old_port_number + 1);; port_number++) {
 	    int status;
+
 	    if (port_number > LAST_TCP_PORT)
 		port_number = FIRST_TCP_PORT;
 	    if (port_number == old_port_number) {
@@ -1167,100 +1221,104 @@
 #endif /* INET6 */
 #ifdef SOCKS
 	    if (socks_flag)
-		if ((status=Rbind(new_socket,
-			(struct sockaddr*)&soc_address,
-			    /* Cast to generic sockaddr */
-			SOCKADDR_LEN(soc_address)
+		if ((status = Rbind(new_socket,
+				    (struct sockaddr *) &soc_address,
+		/* Cast to generic sockaddr */
+				    SOCKADDR_LEN(soc_address)
 #ifndef SHORTENED_RBIND
-			,socks_bind_remoteAddr
+				    ,socks_bind_remoteAddr
 #endif /* !SHORTENED_RBIND */
-						)) == 0) {
+		     )) == 0) {
 		    break;
 		} else
 #endif /* SOCKS */
-	    if ((status=bind(new_socket,
-		    (struct sockaddr*)&soc_address,
-			    /* Cast to generic sockaddr */
-		    SOCKADDR_LEN(soc_address)
-		    )) == 0) {
-		break;
-	    }
+		    if ((status = bind(new_socket,
+				       (struct sockaddr *) &soc_address,
+		    /* Cast to generic sockaddr */
+				       SOCKADDR_LEN(soc_address)
+			 )) == 0) {
+		    break;
+		}
 	    CTRACE((tfp, "TCP bind attempt to port %d yields %d, errno=%d\n",
-		port_number, status, SOCKET_ERRNO));
-	} /* for */
+		    port_number, status, SOCKET_ERRNO));
+	}			/* for */
     }
 #else
     {
 	int status;
-	int address_length = sizeof(soc_address);
+	LY_SOCKLEN address_length = sizeof(soc_address);
+
 #ifdef SOCKS
 	if (socks_flag)
 	    status = Rgetsockname(control->socket,
-				  (struct sockaddr *)&soc_address,
-				  (void *)&address_length);
+				  (struct sockaddr *) &soc_address,
+				  &address_length);
 	else
 #endif /* SOCKS */
-	status = getsockname(control->socket,
-			     (struct sockaddr *)&soc_address,
-			     (void *)&address_length);
-	if (status<0) return HTInetStatus("getsockname");
+	    status = getsockname(control->socket,
+				 