/*****************************************************************************/
/*
                                  WATCH.c

The WATCH facility is a powerful adjunct in server administration.  From the
administration menu it provides an online, real-time, in-browser-window view of
request processing in the running server.  The ability to observe live request
processing on an ad hoc basis, without changing server configuration or
shutting-down/restarting the server process, makes this facility a great
configuration and problem resolution tool.  It allows (amongst other uses)

  o  assessment of mapping rules
  o  assessment of authorization rules
  o  investigation of request processing problems
  o  general observation of server behaviour

A single client per server process can access the WATCH facility at any one
time. The report can be generated for a user-specified number of seconds or
aborted at any time using the browser's stop button.

An event is considered any significant point for which the server code has a
reporting call provided.  These have been selected to provide maximum
information with minimum clutter and impact on server performance.  Obvious
examples are connection acceptance and closure, request path resolution, error
report generation, network reads and writes, etc.  These events may be selected
on a "category" basis from the WATCH menu.

This module also provides functions to display a process using SHOW PROCESS
/ALL via the DCL.C module, and to delete a process, as well as a function to
"peek" at selected fields in the data structures of any request during
processing (intended more as a diagnosis and development tool).

The "module" WATCHing functionality is basically for low-level, on-line
debugging.  It is not intended as a general site administration tool.

There is mention of a "rabbit hole" associated with WATCH.  For HTTP/2 much
more code was required to manage network I/O and managing self-referential
WATCHing around these code paths became a rapid descent into madness.  In
v11.0.0 any concurrent sharing of an HTTP/2 stream by WATCHing and being
WATCHed requests was not supported and reported as a "rabbit hole".  With
v11.1.1 this has been relaxed somewhat to permit WATCHing all items EXCEPT
[x]HTTP/2, [x]SSL and [x]network, any of which result in a "rabbit hole".


EXCLUDING WATCH
---------------
The WATCH menu and associated functionality can be compiled-out of the server
executable using appropriate macros.  The obvious one for elimination is
"module" WATCHing (as mentioned ab ove, generally intended for low-level
debugging).  By default this is not a compile-time inclusion and requires a
WATCH_MOD=1 definition during building.  "Category" WATCHing is intended as a
general site administration tool and so for all but the most demanding sites
should be left compiled in (as it is by default).  To exclude build using a
WATCH_CAT=0 macro.


COMMAND-LINE WATCH
------------------
The command-line version of WATCH accepts a number of variants.

   /WATCH[=NOSTARTUP,][ITEMS=([NO]item[,[NO]item)][,client[,service[,path]]]

The leading keyword NOSTARTUP suppresses WATCH output during server startup.
Items can be any category or module item name (e.g. MAPPING, _MAPURL,
AUTHORIZATION, _AUTH), or ALLCAT or ALLMOD for all categories or modules, and
NOwhatever to turn off a particular WATCH item.  The convenience keyword LIST
provides a list of all category and module keywords that may be used.

   /WATCH=ITEMS=(ALLCAT,NOMAPPING,ALLMOD,NO_FAO)
   /WATCH=NOSTARTUP,ITEMS=(MAPPING,AUTHORIZATION,_CONFIG,_AUTH..)
   /WATCH=ITEMS=(ALLCAT,ALLMOD,NO_FAO,NO_DETAIL),*,*,/HT_ROOT/SRC/*
   /WATCH=LIST


VERSION HISTORY
---------------
30-NOV-2019  MGD  bugfix; WatchDataDump() CHARS_PER_LINE calculation (sigh)
26-SEP-2019  MGD  more fiddling with WATCH report data delivery
15-JUL-2019  MGD  move WatchSystemPlus() functionality to sysPLUS.c module
25-AUG-2018  MGD  WatchSystemPlus() et.al.
06-JUL-2018  MGD  WatchPeek() add VM and Zone data
28-APR-2018  MGD  refactor Admin..() AST delivery
05-APR-2018  MGD  refactor WatchWrite() using NetWriteBuffered()
                  bugfix; WatchDataDump() CHARS_PER_LINE calculation
03-JAN-2018  MGD  make WATCH item width flexible using initial value 6 digits
                    with leading 3 digits HTTP/2 stream ID followed by 3 digits
                    connection ID number and on overflow increment by 2
18-NOV-2017  MGD  refactor WatchEnd() (yet again)
25-SEP-2017  MGD  WatchReport() move SSL item into Network group
                  WatchShowCluster() and WatchShowSystem() VMS V6.2 obsolete
                  bugfix; WatchEnd() misplaced use of |rqptr|
08-AUG-2017  MGD  relax HTTP/2 "rabbit hole"
                  bugfix; WatchEnd() remove conditional
                  bugfix; WatchBreakDetect() remove WatchEnd() parameter
18-AUG-2016  MGD  bugfix; WatchPeek() |HeaderFao| data
05-AUG-2015  MGD  HTTP/2 support
                  allow browser WATCH to piggyback on CLI WATCH
                  category TIMER moved to INTERNAL and purpose expanded
10-JUL-2007  MGD  add HTTP status filter
27-JUN-2007  MGD  WatchShowCluster()
31-DEC-2006  MGD  add "WebDAV" item
14-OCT-2006  MGD  significantly enhance original filtering
                  StringMatchRegex() instead of decc$match_wild() for filtering
                    (changes the syntax slightly and adds regex matching)
                  added REG_NEWLINE to REGEX_C_FLAGS so that anchors match
                    newlines in strings to support 'Request' filter in WATCH
10-NOV-2004  MGD  WatchNoticed() and WASD_WATCH_INTERNAL to improve diagnostics
20-JUL-2004  MGD  HTTP/1.1 compliance data
16-JUL-2004  MGD  remove potential %DCL-W-TKNOVF in WatchShowSystem()
19-JUL-2003  MGD  revise detached process candidate identification,
                  revise process report format
05-MAY-2003  MGD  remove 'quotas' WATCH item, add (string) 'match'
25-MAR-2003  MGD  WatchShowProcess() username
31-JAN-2003  MGD  DCL and DECnet record building items,
                  additional items in WatchShowSystem(),
                  no menu difference between category and module WATCHing
08-OCT-2002  MGD  add scripting account information
15-JUN-2002  MGD  bugfix; RequestUriPtr formatting in WatchPeek()
04-JUN-2002  MGD  reserve WATCH across all instances
31-MAR-2002  MGD  add CC command-line
03-FEB-2002  MGD  add server process log options
03-JAN-2002  MGD  refine command-line interface
29-OCT-2001  MGD  PERSONA_MACRO reporting
15-SEP-2001  MGD  WatchShowSystem(),
                  per-node and per-cluster instances
04-AUG-2001  MGD  support module WATCHing (WATCH_MOD),
                  conditional compilation of both WATCH_CAT and WATCH_MOD,
                  bugfix; check ParseQueryField() in WatchBegin() for NULL
18-APR-2001  MGD  move TCP/IP agent analysis to NetTcpIpAgentInfo()
14-MAR-2001  MGD  add WatchPeek() throttle, proxy authorization
06-JAN-2001  MGD  DETAIL category
01-OCT-2000  MGD  DCL task changes
26-AUG-2000  MGD  integrate WATCH peek and processing into WatchBegin()
17-JUN-2000  MGD  add "quotas" as a WATCH item,
                  bugfix; WatchCliSettings() storage
28-MAY-2000  MGD  add process quotas, using $getjpi ...lm values from startup
08-MAY-2000  MGD  make path filter a path/track filter
04-MAR-2000  MGD  use FaolToNet(), et.al.
02-JAN-2000  MGD  add ODS to WatchPackageInfo()
10-NOV-1999  MGD  use decc$match_wild() for the WatchFilter()
30-OCT-1999  MGD  dignified with a module of its own (unbundled from ADMIN.C)
07-NOV-1998  MGD  initial (as part of ADMIN.C)
*/
/*****************************************************************************/

#ifdef WASD_VMS_V7
#undef _VMS__V6__SOURCE
#define _VMS__V6__SOURCE
#undef __VMS_VER
#define __VMS_VER 70000000
#undef __CRTL_VER
#define __CRTL_VER 70000000
#endif

/* standard C header files */
#include <ctype.h>
#include <errno.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>

/* VMS related header files */
#include <descrip.h>
#include <dvidef.h>
#include <dvsdef.h>
#include <iodef.h>
#include <jpidef.h>
#include <libdef.h>
#include <libdtdef.h>
#include <lnmdef.h>
#include <prvdef.h>
#include <ssdef.h>
#include <stsdef.h>
#include <syidef.h>

/* application related header files */
#include "wasd.h"

/* some extra prototypes required for 'watchfunc.h' */
SesolaClientGetCert (void*);
SesolaNetAccept (void*);
SesolaNetEnd (void*);
SesolaNetClientConnect (void*);
SesolaNetClientShutdown (void*);

#include "watchfunc.h"

#define WASD_MODULE "WATCH"

#define DBUG 0

/******************/
/* global storage */
/******************/

char  WatchItemHeader [] =
"|Time_______|Module__|Line|Item!#*_|Category__|Event...|\n";

char  ErrorWatchAuthNeeded [] =
         "Authorization must be enabled to access WATCH!",
      ErrorWatchPersonaNeeded [] =
          "/PERSONA must be enabled to attempt to show this process.",
      ErrorWatchBufferOvf [] = "*ERROR* sys$fao() BUFFEROVF",
      ErrorWatchNumber [] = "Not found in request or HTTP/2 lists.",
#if !WATCH_CAT
      ErrorWatchNoCategory [] = "Category WATCHing is not a compiled option!",
#endif /* !WATCH_CAT */
#if !WATCH_MOD
      ErrorWatchNoModule [] = "Module WATCHing is not a compiled option!",
#endif /* !WATCH_MOD */
      ErrorWatchCannotPeek [] = "Cannot PEEK!",
      ErrorWatchRabbitHole [] = "HTTP/2 rabbit hole!",
      ErrorWatchSelf [] = "Cannot WATCH yourself!",
      ErrorWatchQueryString [] = "WATCH query string problem (no such item).",
      ErrorWatchSysFao [] = "*ERROR* sys$fao()";

static ulong  WatchRmiMemErrs;

WATCH_STRUCT  Watch;

/********************/
/* external storage */
/********************/

extern BOOL  DclPersonaServicesAvailable,
             DclScriptDetachProcess,
             LoggingEnabled,
#if ODS_DIRECT
             OdsDirect,
#endif /* ODS_DIRECT */
             OdsExtended,
             OperateWithSysPrv,
             PersonaMacro,
             ProtocolHttpsConfigured,
             ProxyCacheEnabled,
             ProxyServingEnabled;

extern int  DclMailboxBytLmRequired,
            EfnWait,
            GzipFindImageStatus,
            HttpdTickSecond,
            InstanceNodeCurrent,
            NetAcceptBytLmRequired,
            NetListenBytLmRequired,
            SesolaGblSecStructSize;

extern int  ToLowerCase[],
            ToUpperCase[];

extern ulong  HttpdTime64[],
              MailboxMask[],
              ProcessRightsIdent[],
              WorldMask[];

extern char  BuildDateTime[],
             CliScriptAs[],
             CommandLine[],
             ErrorSanityCheck[],
             HttpdScriptAsUserName[],
             ServerHostPort[],
             SoftwareID[],
             TcpIpAgentInfo[],
             TimeGmtString[];

extern char  *GzipZlibNamePtr,
             *GzipZlibVersionPtr;

extern CONFIG_STRUCT  Config;
extern MSG_STRUCT  Msgs;
extern LIST_HEAD  Http2List;
extern HTTPD_GBLSEC  *HttpdGblSecPtr;
extern HTTPD_PROCESS  HttpdProcess;
extern LIST_HEAD  RequestList;
extern SUPERVISOR_LIST  SupervisorListArray[];
extern SYS_INFO  SysInfo;

/*****************************************************************************/
/*
Check if the watch facility is already in use, report error if it is.  Provide
form for selection of WATCH parameters.
*/ 

void WatchReport (REQUEST_STRUCT *rqptr)

{
#if WATCH_CAT

   static char  ResponseFao [] =
"<style type=\"text/css\">\n\
.sbttl { display:inline-block; padding-top:0.3em; }\n\
input[type=radio] { margin:0 0 0 0.4em; vertical-align:text-top; }\n\
input[type=text] { font-family:monospace; margin:0; \
vertical-align:text-bottom; }\n\
</style>\n\
<form action=\"!AZ\">\n\
<p><table class=\"ctgry\">\n\
<tr><th class=\"ctttl\">Select WATCH Criteria</th></tr>\n\
<tr><td>\n\
\
<table class=\"lftlft\">\n\
<tr><td>\n\
<a href=\"" ADMIN_REPORT_WATCH_STRUCT "\" \
style=\"color:#000000;text-decoration:none;\">\
\
<span class=\"sbttl\">Request</span></a>\n\
<br><input type=\"checkbox\" name=\"rqp\" value=\"1\" checked> Processing\n\
<br><input type=\"checkbox\" name=\"rqh\" value=\"1\"> Header\n\
<br><input type=\"checkbox\" name=\"rqb\" value=\"1\"> Body\n\
<br><span class=\"sbttl\">Response</span></b><sup>&nbsp;</sup>\n\
<br><input type=\"checkbox\" name=\"rsp\" value=\"1\" checked> Processing\n\
<br><input type=\"checkbox\" name=\"rsh\" value=\"1\"> Header\n\
<br><input type=\"checkbox\" name=\"rsb\" value=\"1\"> Body\n\
</td><td>\n\
\
<span class=\"sbttl\">General</span>\n\
<br><input type=\"checkbox\" name=\"con\" value=\"1\" checked> Connection\n\
<br><input type=\"checkbox\" name=\"map\" value=\"1\"> Mapping\n\
<br><input type=\"checkbox\" name=\"aut\" value=\"1\"> Authorization\n\
<br><input type=\"checkbox\" name=\"err\" value=\"1\" checked> Error\n\
<br><input type=\"checkbox\" name=\"cgi\" value=\"1\"> CGI\n\
<br><input type=\"checkbox\" name=\"dcl\" value=\"1\"> DCL\n\
<br><input type=\"checkbox\" name=\"dnt\" value=\"1\"> DECnet\n\
<br><input type=\"checkbox\" name=\"dav\" value=\"1\"> WebDAV\n\
</nobr></td><td>\n\
\
<span class=\"sbttl\">Network</span>\n\
<br><input type=\"checkbox\" name=\"net\" value=\"1\"> Activity\n\
<br><input type=\"checkbox\" name=\"oct\" value=\"1\"> Data\n\
<br><input type=\"checkbox\" name=\"ht2\" value=\"1\"> HTTP/2\n\
<br><input type=\"checkbox\" name=\"ssl\" value=\"1\"> !AZSSL!AZ\n\
\
<br><span class=\"sbttl\">Other</span><sup>&nbsp;</sup>\n\
<br><input type=\"checkbox\" name=\"log\" value=\"1\"> !AZLogging!AZ\
<br><input type=\"checkbox\" name=\"mat\" value=\"1\"> Match\n\
<br><input type=\"checkbox\" name=\"scr\" value=\"1\"> Script\n\
&nbsp;&nbsp;&nbsp;&nbsp;\n\
<br><input type=\"checkbox\" name=\"int\" value=\"1\"> Internal\n\
</td><td>\n\
\
<span class=\"sbttl\">Proxy</span>\n\
!AZ\
<br><input type=\"checkbox\" name=\"pxy\" value=\"1\"> Processing\n\
<br><input type=\"checkbox\" name=\"prh\" value=\"1\"> Request Header\n\
<br><input type=\"checkbox\" name=\"prb\" value=\"1\"> Request Body\n\
<br><input type=\"checkbox\" name=\"psh\" value=\"1\"> Response Header\n\
<br><input type=\"checkbox\" name=\"psb\" value=\"1\"> Response Body\n\
!AZ\
!AZ\
<br><input type=\"checkbox\" name=\"pca\" value=\"1\"> Cache\n\
!AZ\
</td></tr>\n\
</table>\n\
\
!AZ\
\
<table class=\"lftlft\" style=\"margin-top:-0.7em;\">\n\
<tr><td>\n\
<table class=\"lftlft\">\n\
<tr><td colspan=\"2\"><span class=\"sbttl\">Filtering</span></td>\
<td colspan=\"2\" style=\"vertical-align:bottom;\">\
&nbsp;in&nbsp;out</td></tr>\n\
\
<tr><td colspan=\"2\">\n\
<input type=\"checkbox\" name=\"htp2\" value=\"2\">&nbsp;2&nbsp;\n\
<input type=\"checkbox\" name=\"htp11\" value=\"11\">&nbsp;1.1&nbsp;\n\
<input type=\"checkbox\" name=\"htp10\" value=\"10\">&nbsp;1.0&nbsp;\n\
<input type=\"checkbox\" name=\"htp09\" value=\"09\">&nbsp;0.9\n\
</td><td>\n\
<input type=\"radio\" name=\"htp\" value=\"i\" checked>\
<input type=\"radio\" name=\"htp\" value=\"o\">&nbsp;</td>\
<td>Protocol</td></tr>\n\
\
<tr><td colspan=\"2\">\
<input type=\"text\" name=\"clf\" size=\"40\" value=\"\" \
onfocus=\"this.select()\">\
</td><td>\
<input type=\"radio\" name=\"clo\" value=\"i\" checked>\
<input type=\"radio\" name=\"clo\" value=\"o\"></td>\
<td>Client</td></tr>\n\
\
<tr><td colspan=\"2\">\
<input type=\"text\" name=\"sef\" size=\"40\" value=\"\" \
onfocus=\"this.select()\">\
</td><td>\
<input type=\"radio\" name=\"seo\" value=\"i\" checked>\
<input type=\"radio\" name=\"seo\" value=\"o\"></td>\
<td>Service</td></tr>\n\
\
<tr><td colspan=\"2\">\
<input type=\"text\" name=\"rhf\" size=\"40\" value=\"\" \
onfocus=\"this.select()\">\
</td><td>\
<input type=\"radio\" name=\"rho\" value=\"i\" checked>\
<input type=\"radio\" name=\"rho\" value=\"o\"></td>\
<td>Request</td></tr>\n\
\
<tr><td colspan=\"2\">\
<input type=\"text\" name=\"paf\" size=\"40\" value=\"\" \
onfocus=\"this.select()\">\
</td><td>\
<input type=\"radio\" name=\"uro\" value=\"i\" checked>\
<input type=\"radio\" name=\"uro\" value=\"o\"></td>\
<td>URI</td></tr>\n\
\
<tr><td style=\"margin-right:0;padding-right:0;\">\
<input type=\"text\" name=\"arf\" size=\"18\" value=\"\" \
onfocus=\"this.select()\">\
</td><td class=\"targht\" style=\"margin-left:0;padding-left:0;\">\
<input type=\"text\" name=\"auf\" size=\"18\" value=\"\" \
onfocus=\"this.select()\"></td>\
<td><input type=\"radio\" name=\"auo\" value=\"i\" checked>\
<input type=\"radio\" name=\"auo\" value=\"o\"></td>\
<td>Realm &amp; User&nbsp;</td></tr>\n\
\
<tr><td colspan=\"2\">\
<input type=\"text\" name=\"sts\" size=\"40\" maxlength=\"3\" value=\"\" \
onfocus=\"this.select()\">\
</td><td>\
<input type=\"radio\" name=\"sto\" value=\"i\" checked>\
<input type=\"radio\" disabled=\"disabled\"></td>\
<td>HTTP Status</td></tr>\n\
\
</table>\n\
</td></tr>\n\
</table>\n\
\
<table class=\"lftlft\">\n\
<tr><td>\n\
<select name=\"dul\">\n\
<option> 30\n\
<option selected> 60\n\
<option> 120\n\
<option> 300\n\
<option> 600\n\
</select> or\n\
<input type=\"text\" name=\"dut\" size=\"5\" value=\"\"> Seconds Duration\n\
<br><input type=\"checkbox\" name=\"stdout\" value=\"1\"> \
Include (<input type=\"checkbox\" name=\"only\" value=\"1\">only) \
in Server Process Log\n\
<p><input type=\"submit\" value=\" WATCH \"> &nbsp; \
<input type=reset value=\" reset \">\n\
</td></tr>\n\
</table>\n\
\
</td></tr>\n\
</table>\n\
\
</form>\n\
\
</div>\n\
</body>\n\
</html>\n";

#if WATCH_MOD

   static char  WatchModFao [] =
"<table class=\"lftlft\" style=\"margin-top:-0.7em;\">\n\
<tr><td colspan=\"5\"><span class=\"sbttl\">Module</span></td></tr>\n\
<tr><td>\n\
<input type=\"checkbox\" name=\"_aut\" value=\"1\"> AUTH..\n\
<br><input type=\"checkbox\" name=\"_bod\" value=\"1\"> BODY\n\
<br><input type=\"checkbox\" name=\"_cac\" value=\"1\"> CACHE\n\
<br><input type=\"checkbox\" name=\"_cgi\" value=\"1\"> CGI\n\
<br><input type=\"checkbox\" name=\"_con\" value=\"1\"> CONFIG&nbsp;\n\
<br><input type=\"checkbox\" name=\"_dcl\" value=\"1\"> DCL\n\
</td><td>\n\
<input type=\"checkbox\" name=\"_dec\" value=\"1\"> DECNET\n\
<br><input type=\"checkbox\" name=\"_dir\" value=\"1\"> DIR\n\
<br><input type=\"checkbox\" name=\"_fao\" value=\"1\"> FAO\n\
<br><input type=\"checkbox\" name=\"_fil\" value=\"1\"> FILE\n\
<br><input type=\"checkbox\" name=\"_hta\" value=\"1\"> HTADMIN\n\
<br><input type=\"checkbox\" name=\"_ht2\" value=\"1\"> HTTP2..\n\
</td><td>\n\
<input type=\"checkbox\" name=\"_ins\" value=\"1\"> INSTANCE\n\
<br><input type=\"checkbox\" name=\"_map\" value=\"1\"> MAPURL\n\
<br><input type=\"checkbox\" name=\"_met\" value=\"1\"> METACON\n\
<br><input type=\"checkbox\" name=\"_msg\" value=\"1\"> MSG\n\
<br><input type=\"checkbox\" name=\"_net\" value=\"1\"> NET\n\
<br><input type=\"checkbox\" name=\"_ods\" value=\"1\"> ODS\n\
</td><td>\n\
<input type=\"checkbox\" name=\"_pro\" value=\"1\"> PROXY..\n\
<br><input type=\"checkbox\" name=\"_put\" value=\"1\"> PUT\n\
<br><input type=\"checkbox\" name=\"_req\" value=\"1\"> REQUEST\n\
<br><input type=\"checkbox\" name=\"_res\" value=\"1\"> RESPONSE\n\
<br><input type=\"checkbox\" name=\"_ser\" value=\"1\"> SERVICE\n\
<br><input type=\"checkbox\" name=\"_ses\" value=\"1\"> SESOLA..\n\
</td><td>\n\
<input type=\"checkbox\" name=\"_ssi\" value=\"1\"> SSI\n\
<br><input type=\"checkbox\" name=\"_thr\" value=\"1\"> THROTTLE\n\
<br><input type=\"checkbox\" name=\"_upd\" value=\"1\"> UPD\n\
<br><input type=\"checkbox\" name=\"_vm\" value=\"1\"> VM\n\
<br><input type=\"checkbox\" name=\"_dav\" value=\"1\"> WebDAV\n\
<br><input type=\"checkbox\" name=\"_oth\" value=\"1\"> other\n\
<br><input type=\"checkbox\" name=\"_det\" value=\"1\"> detail\n\
</td></tr>\n\
</table>\n";

#else

   static char  WatchModFao [] = "";

#endif /* WATCH_MOD */

   int  status;
   ulong  FaoVector [32];
   ulong  *vecptr;

   /*********/
   /* begin */
   /*********/

   if (Watch.Disabled)
   {
      rqptr->rqResponse.HttpStatus = 403;
      ErrorGeneral (rqptr, MsgFor(rqptr,MSG_GENERAL_DISABLED), FI_LI);
      AdminEnd (rqptr);
      return;
   }

   if (!rqptr->RemoteUser[0])
   {
      rqptr->rqResponse.HttpStatus = 403;
      ErrorGeneral (rqptr, ErrorWatchAuthNeeded, FI_LI);
      AdminEnd (rqptr);
      return;
   }

   if (WatchInUse (rqptr, false))
   {
      AdminEnd (rqptr);
      return;
   }

   AdminPageTitle (rqptr, "WATCH Report");

   vecptr = FaoVector;
   *vecptr++ = ADMIN_REPORT_WATCH;

   if (ProtocolHttpsConfigured)
   {
      *vecptr++ = "";
      *vecptr++ = "";
   }
   else
   {
      *vecptr++ = "<i>";
      *vecptr++ = "</i>";
   }

   if (LoggingEnabled)
   {
      *vecptr++ = "";
      *vecptr++ = "";
   }
   else
   {
      *vecptr++ = "<i>";
      *vecptr++ = "</i>";
   }

   if (ProxyServingEnabled)
   {
      *vecptr++ = "";
      *vecptr++ = "";
   }
   else
   {
      *vecptr++ = "<i>\n";
      *vecptr++ = "</i>\n";
   }

   if (ProxyCacheEnabled)
   {
      *vecptr++ = "";
      *vecptr++ = "";
   }
   else
   {
      *vecptr++ = "<i>\n";
      *vecptr++ = "</i>\n";
   }

#if WATCH_MOD
   *vecptr++ = WatchModFao;
#else
   *vecptr++ = "";
#endif

   status = FaolToNet (rqptr, ResponseFao, &FaoVector);
   if (VMSnok (status)) ErrorNoticed (rqptr, status, NULL, FI_LI);

   ResponseHeader200 (rqptr, "text/html", &rqptr->NetWriteBufferDsc);

   AdminEnd (rqptr);

#else /* WATCH_CAT */

   rqptr->rqResponse.HttpStatus = 403;
   ErrorGeneral (rqptr, ErrorWatchNoCategory, FI_LI);
   AdminEnd (rqptr);

#endif /* WATCH_CAT */
}

/*****************************************************************************/
/*
This function provides both a WATCH-processing report, and a WATCH-peek report.
This can be a WATCH-only report, peek-only, or peek-then-WATCH. If we're going
to use the WATCH-processing report then we have to do it exclusively, check if
the WATCH facility is already in use, report error if it is.  Parse the query
string WATCH parameters.  Report any errors.  Place the parameters into the
WATCH global storage.  This reserves the WATCH facility for this client via the
'Watch.RequestPtr' (and indicate this with a flag in the request structure,
which will be detected as the request concludes and the WATCH facility released
for reuse).  Generate a plain-text HTTP header and output a WATCH report
heading.  If a WATCH-peek report is requested call WatchPeek() to generate it. 
For a peek-only report we declares the next function AST there.  If
WATCH-processing was only/also requested generate a WATCH-processing header
then return BUT do not declare any AST to continue processing.  The client will
just "hang" there receiving output from WatchThis() via the structure pointed
to by 'Watch.RequestPtr'.  Can be used to WATCH all new requests (matching any
filter criteria of course) or in a "one-shot" mode where a single request is
selected to display all categories at any point during it's processing.
*/ 

void WatchBegin (REQUEST_STRUCT *rqptr)

{
   /* easiest just to wrap with WatchNone() */
   WatchNone (true);
   WatchBegin2 (rqptr);
   WatchNone (false);
}

void WatchBegin2 (REQUEST_STRUCT *rqptr)

{
#if WATCH_CAT

   static char  ResponseFao [] =
"!20%D  WATCH REPORT  !AZ\n\
!#*-\n\
!AZ (!AZ)\n\
!AZ\n\
!AZ\
$ CC (!#AZ/!UL) !AZ\n\
!AZ with !UL CPU!%s and !ULMB running VMS !AZ \
(!AZ, !AZ, !AZ, ODS-DIRECT !AZ, !&@, REGEX !AZ, lksb$b_valblk[!UL])!AZ\n\
$ HTTPD !AZ\n\
!AZ\
!&@\
Process: !AZ !AZ !AZ !AZ\n\
!&@\
!&@\
!&@";

   int  eolcnt, status;
   char  *cptr, *qptr, *sptr, *zptr,
         *InstanceClusterPtr,
         *InstanceNodePtr;
   char  Buffer [8192],
         CategoryList [WATCH_CATEGORY_LIST_SIZE],
         FieldName [256],
         FieldValue [WATCH_FILTER_SIZE];
   ushort  Length;
   ulong  ucnt;
   ulong  *vecptr;
   ulong  FaoVector [64];
   HTTP2_STRUCT  *h2ptr;
   REQUEST_STRUCT  *rqeptr;
   WATCH_STRUCT  WatchConfig;

   /*********/
   /* begin */
   /*********/

   if (Watch.Disabled)
   {
      rqptr->rqResponse.HttpStatus = 403;
      ErrorGeneral (rqptr, MsgFor(rqptr,MSG_GENERAL_DISABLED), FI_LI);
      AdminEnd (rqptr);
      return;
   }

   if (!rqptr->RemoteUser[0])
   {
      rqptr->rqResponse.HttpStatus = 403;
      ErrorGeneral (rqptr, ErrorWatchAuthNeeded, FI_LI);
      AdminEnd (rqptr);
      return;
   }

   if (WatchInUse (rqptr, true))
   {
      AdminEnd (rqptr);
      return;
   }

   memset (&WatchConfig, 0, sizeof(WatchConfig));
   WatchConfig.StatusFilter = -1;

   if (rqptr->rqHeader.QueryStringLength)
   {
      /***************************/
      /* build report parameters */
      /***************************/

      qptr = rqptr->rqHeader.QueryStringPtr;
      while (*qptr)
      {
         status = StringParseQuery (&qptr, FieldName, sizeof(FieldName),
                                           FieldValue, sizeof(FieldValue));
         if (VMSnok (status))
         {
            WatchReset ();
            if (status == SS$_IVCHAR) rqptr->rqResponse.HttpStatus = 400;
            rqptr->rqResponse.ErrorTextPtr = "parsing query string";
            ErrorVmsStatus (rqptr, status, FI_LI);
            AdminEnd (rqptr);
            return;
         }

         if (strsame (FieldName, "at", -1) && FieldValue[0])
         {
            WatchConfig.DoPeek = true;
            WatchConfig.ConnectNumber = strtol (FieldValue, NULL, 10);
         }
         else
         if (strsame (FieldName, "this", -1) && FieldValue[0])
         {
            WatchConfig.Category = WATCH_ONE_SHOT_CAT;
#if WATCH_MOD
            WatchConfig.Module = WATCH_ONE_SHOT_MOD;
#endif /* WATCH_MOD */
            WatchConfig.ConnectNumber = strtol (FieldValue, NULL, 10);
         }
         else
         if (strsame (FieldName, "aut", -1) && FieldValue[0])
            WatchConfig.Category |= WATCH_AUTH;
         else
         if (strsame (FieldName, "cgi", -1) && FieldValue[0])
            WatchConfig.Category |= WATCH_CGI;
         else
         if (strsame (FieldName, "con", -1) && FieldValue[0])
            WatchConfig.Category |= WATCH_CONNECT;
         else
         if (strsame (FieldName, "dcl", -1) && FieldValue[0])
         WatchConfig.Category |= WATCH_DCL;
         else
         if (strsame (FieldName, "dnt", -1) && FieldValue[0])
            WatchConfig.Category |= WATCH_DECNET;
         else
         if (strsame (FieldName, "err", -1) && FieldValue[0])
            WatchConfig.Category |= WATCH_ERROR;
         else
         if (strsame (FieldName, "ht2", -1) && FieldValue[0])
            WatchConfig.Category |= WATCH_HTTP2;
         else
         if (strsame (FieldName, "log", -1) && FieldValue[0])
            WatchConfig.Category |= WATCH_LOG;
         else
         if (strsame (FieldName, "map", -1) && FieldValue[0])
            WatchConfig.Category |= WATCH_MAPPING;
         else
         if (strsame (FieldName, "mat", -1) && FieldValue[0])
            WatchConfig.Category |= WATCH_MATCH;
         else
         if (strsame (FieldName, "net", -1) && FieldValue[0])
            WatchConfig.Category |= WATCH_NETWORK;
         else
         if (strsame (FieldName, "oct", -1) && FieldValue[0])
            WatchConfig.Category |= WATCH_NETWORK_OCTETS;
         else
         if (strsame (FieldName, "pxy", -1) && FieldValue[0])
            WatchConfig.Category |= WATCH_PROXY;
         else
         if (strsame (FieldName, "pca", -1) && FieldValue[0])
            WatchConfig.Category |= WATCH_PROXY_CACHE;
         else
         if (strsame (FieldName, "prh", -1) && FieldValue[0])
            WatchConfig.Category |= WATCH_PROXY_REQU_HDR;
         else
         if (strsame (FieldName, "prb", -1) && FieldValue[0])
            WatchConfig.Category |= WATCH_PROXY_REQU_BDY;
         else
         if (strsame (FieldName, "psh", -1) && FieldValue[0])
            WatchConfig.Category |= WATCH_PROXY_RESP_HDR;
         else
         if (strsame (FieldName, "psb", -1) && FieldValue[0])
            WatchConfig.Category |= WATCH_PROXY_RESP_BDY;
         else
         if (strsame (FieldName, "rqp", -1) && FieldValue[0])
            WatchConfig.Category |= WATCH_REQUEST;
         else
         if (strsame (FieldName, "rqb", -1) && FieldValue[0])
            WatchConfig.Category |= WATCH_REQUEST_BODY;
         else
         if (strsame (FieldName, "rqh", -1) && FieldValue[0])
            WatchConfig.Category |= WATCH_REQUEST_HEADER;
         else
         if (strsame (FieldName, "rsp", -1) && FieldValue[0])
            WatchConfig.Category |= WATCH_RESPONSE;
         else
         if (strsame (FieldName, "rsb", -1) && FieldValue[0])
            WatchConfig.Category |= WATCH_RESPONSE_BODY;
         else
         if (strsame (FieldName, "rsh", -1) && FieldValue[0])
            WatchConfig.Category |= WATCH_RESPONSE_HEADER;
         else
         if (strsame (FieldName, "scr", -1) && FieldValue[0])
            WatchConfig.Category |= WATCH_SCRIPT;
         else
         if (strsame (FieldName, "ssl", -1) && FieldValue[0])
            WatchConfig.Category |= WATCH_SESOLA;
         else
         if (strsame (FieldName, "int", -1) && FieldValue[0])
            WatchConfig.Category |= WATCH_INTERNAL;
         else
         if (strsame (FieldName, "dav", -1) && FieldValue[0])
            WatchConfig.Category |= WATCH_WEBDAV;
         else
         if (strsame (FieldName, "htp09", -1)) {
            if (FieldValue[0]) WatchConfig.HttpFilter09 = true;
         }
         else
         if (strsame (FieldName, "htp10", -1)) {
            if (FieldValue[0]) WatchConfig.HttpFilter10 = true;
         }
         else
         if (strsame (FieldName, "htp11", -1)) {
            if (FieldValue[0]) WatchConfig.HttpFilter11 = true;
         }
         else
         if (strsame (FieldName, "htp2", -1)) {
            if (FieldValue[0]) WatchConfig.HttpFilter2 = true;
         }
         else
         if (strsame (FieldName, "htp", -1)) {
            if (FieldValue[0] == 'o') WatchConfig.FilterOutHttp = true;
         }
         else
         if (strsame (FieldName, "clf", -1))
            strcpy (WatchConfig.ClientFilter, FieldValue);
         else
         if (strsame (FieldName, "clo", -1)) {
            if (FieldValue[0] == 'o') WatchConfig.FilterOutClient = true;
         }
         else
         if (strsame (FieldName, "sef", -1))
            strcpy (WatchConfig.ServiceFilter, FieldValue);
         else
         if (strsame (FieldName, "seo", -1)) {
            if (FieldValue[0] == 'o') WatchConfig.FilterOutService = true;
         }
         else
         if (strsame (FieldName, "rhf", -1))
            strcpy (WatchConfig.RequestFilter, FieldValue);
         else
         if (strsame (FieldName, "rho", -1)) {
            if (FieldValue[0] == 'o') WatchConfig.FilterOutRequest = true;
         }
         else
         if (strsame (FieldName, "paf", -1))
            strcpy (WatchConfig.PathFilter, FieldValue);
         else
         if (strsame (FieldName, "uro", -1) ||
             /* pre-v11 compatibility */ 
             strsame (FieldName, "pao", -1)) {
            if (FieldValue[0] == 'o') WatchConfig.FilterOutURI = true;
         }
         else
         if (strsame (FieldName, "sts", -1)) {
            if (isdigit(FieldValue[0]))
               WatchConfig.StatusFilter = atoi(FieldValue);
         }
         else
         if (strsame (FieldName, "sto", -1)) {
            /* do absolutely nothing! */
         }
         else
         if (strsame (FieldName, "arf", -1))
            strcpy (WatchConfig.RealmFilter, FieldValue);
         else
         if (strsame (FieldName, "aro", -1)) {
            if (FieldValue[0] == 'o') WatchConfig.FilterOutRealm = true;
         }
         else
         if (strsame (FieldName, "auf", -1))
            strcpy (WatchConfig.UserFilter, FieldValue);
         else
         if (strsame (FieldName, "auo", -1)) {
            if (FieldValue[0] == 'o') WatchConfig.FilterOutUser = true;
         }
         else
         if (strsame (FieldName, "stdout", -1))
            WatchConfig.StdoutToo = true;
         else
         if (strsame (FieldName, "only", -1))
            WatchConfig.StdoutOnly = true;
         else
         if (strsame (FieldName, "dul", -1) ||
             strsame (FieldName, "dut", -1) ||
             strsame (FieldName, "sec", -1) ||
             strsame (FieldName, "seconds", -1))
         {
            for (cptr = FieldValue; *cptr && !isdigit(*cptr); cptr++);
            if (*cptr) WatchConfig.DurationSeconds = atoi (cptr);
         }
         else

#if WATCH_MOD

         if (strsame (FieldName, "_aut", -1) && FieldValue[0])
            WatchConfig.Module |= WATCH_MOD_AUTH;
         else
         if (strsame (FieldName, "_bod", -1) && FieldValue[0])
            WatchConfig.Module |= WATCH_MOD_BODY;
         else
         if (strsame (FieldName, "_cac", -1) && FieldValue[0])
            WatchConfig.Module |= WATCH_MOD_CACHE;
         else
         if (strsame (FieldName, "_cgi", -1) && FieldValue[0])
            WatchConfig.Module |= WATCH_MOD_CGI;
         else
         if (strsame (FieldName, "_con", -1) && FieldValue[0])
            WatchConfig.Module |= WATCH_MOD_CONFIG;
         else
         if (strsame (FieldName, "_dcl", -1) && FieldValue[0])
            WatchConfig.Module |= WATCH_MOD_DCL;
         else
         if (strsame (FieldName, "_det", -1) && FieldValue[0])
            WatchConfig.Module |= WATCH_MOD__DETAIL;
         else
         if (strsame (FieldName, "_dec", -1) && FieldValue[0])
            WatchConfig.Module |= WATCH_MOD_DECNET;
         else
         if (strsame (FieldName, "_dir", -1) && FieldValue[0])
            WatchConfig.Module |= WATCH_MOD_DIR;
         else
         if (strsame (FieldName, "_fao", -1) && FieldValue[0])
            WatchConfig.Module |= WATCH_MOD_FAO;
         else
         if (strsame (FieldName, "_fil", -1) && FieldValue[0])
            WatchConfig.Module |= WATCH_MOD_FILE;
         else
         if (strsame (FieldName, "_hta", -1) && FieldValue[0])
            WatchConfig.Module |= WATCH_MOD_HTADMIN;
         else
         if (strsame (FieldName, "_ht2", -1) && FieldValue[0])
            WatchConfig.Module |= WATCH_MOD_HTTP2;
         else
         if (strsame (FieldName, "_ins", -1) && FieldValue[0])
            WatchConfig.Module |= WATCH_MOD_INSTANCE;
         else
         if (strsame (FieldName, "_map", -1) && FieldValue[0])
            WatchConfig.Module |= WATCH_MOD_MAPURL;
         else
         if (strsame (FieldName, "_met", -1) && FieldValue[0])
            WatchConfig.Module |= WATCH_MOD_METACON;
         else
         if (strsame (FieldName, "_msg", -1) && FieldValue[0])
            WatchConfig.Module |= WATCH_MOD_MSG;
         else
         if (strsame (FieldName, "_net", -1) && FieldValue[0])
            WatchConfig.Module |= WATCH_MOD_NET;
         else
         if (strsame (FieldName, "_ods", -1) && FieldValue[0])
            WatchConfig.Module |= WATCH_MOD_ODS;
         else
         if (strsame (FieldName, "_oth", -1) && FieldValue[0])
            WatchConfig.Module |= WATCH_MOD__OTHER;
         else
         if (strsame (FieldName, "_pro", -1) && FieldValue[0])
            WatchConfig.Module |= WATCH_MOD_PROXY;
         else
         if (strsame (FieldName, "_put", -1) && FieldValue[0])
            WatchConfig.Module |= WATCH_MOD_PUT;
         else
         if (strsame (FieldName, "_req", -1) && FieldValue[0])
            WatchConfig.Module |= WATCH_MOD_REQUEST;
         else
         if (strsame (FieldName, "_res", -1) && FieldValue[0])
            WatchConfig.Module |= WATCH_MOD_RESPONSE;
         else
         if (strsame (FieldName, "_ser", -1) && FieldValue[0])
            WatchConfig.Module |= WATCH_MOD_SERVICE;
         else
         if (strsame (FieldName, "_ses", -1) && FieldValue[0])
            WatchConfig.Module |= WATCH_MOD_SESOLA;
         else
         if (strsame (FieldName, "_ssi", -1) && FieldValue[0])
            WatchConfig.Module |= WATCH_MOD_SSI;
         else
         if (strsame (FieldName, "_thr", -1) && FieldValue[0])
            WatchConfig.Module |= WATCH_MOD_THROTTLE;
         else
         if (strsame (FieldName, "_upd", -1) && FieldValue[0])
            WatchConfig.Module |= WATCH_MOD_UPD;
         else
         if (strsame (FieldName, "_vm", -1) && FieldValue[0])
            WatchConfig.Module |= WATCH_MOD_VM;
         else
         if (strsame (FieldName, "_dav", -1) && FieldValue[0])
            WatchConfig.Module |= WATCH_MOD_WEBDAV;
         else

#else

         if (FieldName[0] == '_')
         {
            WatchReset ();
            rqptr->rqResponse.HttpStatus = 403;
            ErrorGeneral (rqptr, ErrorWatchNoModule, FI_LI);
            AdminEnd (rqptr);
            return;
         }
         else

#endif /* WATCH_MOD */

         {
            WatchReset ();
            rqptr->rqResponse.HttpStatus = 403;
            ErrorGeneral (rqptr, ErrorWatchQueryString, FI_LI);
            AdminEnd (rqptr);
            return;
         }
      }
   }

   if (WatchConfig.Category || WatchConfig.Module) WatchConfig.DoWatch = true;

   if (!WatchConfig.DurationSeconds) WatchConfig.DurationSeconds = 60 * 60 * 24;
 
   if (!WatchConfig.DoPeek && !WatchConfig.DoWatch)
   {
      WatchReset ();
      rqptr->rqResponse.HttpStatus = 403;
      ErrorGeneral (rqptr, ErrorWatchQueryString, FI_LI);
      AdminEnd (rqptr);
      return;
   }

   WatchSetWatch (rqptr, 0);

   if (WatchConfig.ConnectNumber)
   {
      /* find this connection number in the current request list */
      h2ptr = NULL;
      for (rqeptr = LIST_GET_HEAD(&RequestList);
           rqeptr != NULL;
           rqeptr = LIST_GET_NEXT(rqeptr))
         if (rqeptr->ConnectNumber == WatchConfig.ConnectNumber) break;
      if (rqeptr == NULL)
      {
         /* if not in the request list look in the HTTP/2 list */
         for (h2ptr = LIST_GET_HEAD(&Http2List);
              h2ptr != NULL;
              h2ptr = LIST_GET_NEXT(h2ptr))
            if (h2ptr->ConnectNumber == WatchConfig.ConnectNumber) break;
      }

      if (rqeptr == NULL && h2ptr == NULL)
      {
         WatchReset ();
         rqptr->rqResponse.HttpStatus = 400;
         ErrorGeneral (rqptr, ErrorWatchNumber, FI_LI);
         AdminEnd (rqptr);
         return;
      }

      if (rqeptr == rqptr)
      {
         WatchReset ();
         rqptr->rqResponse.HttpStatus = 400;
         ErrorGeneral (rqptr, ErrorWatchSelf, FI_LI);
         AdminEnd (rqptr);
         return;
      }

      if (h2ptr != NULL &&
          rqptr->Http2Stream.Http2Ptr != NULL &&
          rqptr->Http2Stream.Http2Ptr->ConnectNumber == h2ptr->ConnectNumber)
      {
         WatchReset ();
         rqptr->rqResponse.HttpStatus = 400;
         ErrorGeneral (rqptr, ErrorWatchSelf, FI_LI);
         AdminEnd (rqptr);
         return;
      }

      if (WatchConfig.Category == WATCH_ONE_SHOT_CAT)
      {
         if (rqeptr)
         {
            rqeptr->WatchItem = WatchSetWatch (NULL, WATCH_NEW_ITEM);
            rqeptr->WatchItem |= WATCH_ITEM_ONE_SHOT_FLAG;
            WatchSetWatch (rqeptr, rqeptr->WatchItem);
            if (rqeptr->DclTaskPtr)
               rqeptr->DclTaskPtr->WatchItem = rqeptr->WatchItem;
            if (rqeptr->DECnetTaskPtr)
               rqeptr->DECnetTaskPtr->WatchItem = rqeptr->WatchItem;
            if (rqeptr->ProxyTaskPtr)
               rqeptr->ProxyTaskPtr->WatchItem = rqeptr->WatchItem;
            if (rqeptr->Http2Stream.Http2Ptr)
               rqeptr->Http2Stream.Http2Ptr->WatchItem = rqeptr->WatchItem;
         }
         else
         {
            h2ptr->WatchItem = WatchSetWatch (NULL, WATCH_NEW_ITEM);
            h2ptr->WatchItem |= WATCH_ITEM_HTTP2_FLAG;
         }
      }
   }
   else
      rqeptr = NULL;

   if (WatchConfig.DoPeek)
   {
      if (!rqeptr && !h2ptr)
      {
         WatchReset ();
         rqptr->rqResponse.HttpStatus = 400;
         ErrorGeneral (rqptr, ErrorWatchCannotPeek, FI_LI);
         AdminEnd (rqptr);
         return;
      }
   }

   if (WatchRabbitHole (&WatchConfig, rqeptr))
   {
      WatchReset ();
      rqptr->rqResponse.HttpStatus = 403;
      ErrorGeneral (rqptr, ErrorWatchRabbitHole, FI_LI);
      AdminEnd (rqptr);
      return;
   }

   WatchConfig.FilterSet =
      (WatchConfig.HttpFilter09 || WatchConfig.HttpFilter10 ||
       WatchConfig.HttpFilter11 || WatchConfig.HttpFilter2 ||
       WatchConfig.RealmFilter[0] || WatchConfig.UserFilter[0] ||
       WatchConfig.ClientFilter[0] || WatchConfig.PathFilter[0] ||
       WatchConfig.RequestFilter[0] || WatchConfig.ServiceFilter[0] ||
       WatchConfig.StatusFilter >= 0);

   /***********************/
   /* build report header */
   /***********************/

   if (WatchConfig.Category == WATCH_ONE_SHOT_CAT)
      strcpy (CategoryList, "ALL");
   else
   {
      if (WatchConfig.CliEnabled) eolcnt = 80; else eolcnt = 255;
      zptr = (sptr = CategoryList) + eolcnt;
      /* first the categories */
      for (ucnt = 1; ucnt; ucnt = ucnt << 1)
      {
         cptr = WatchWhatCategory (WatchConfig.Category & ucnt);
         if (cptr)
         {
            if (sptr > CategoryList)
            {
               *sptr++ = ',';
               if (sptr > zptr)
               {
                  zptr = sptr + eolcnt;
                  *sptr++ = '\n';
               }
               else
                  *sptr++ = ' ';
            }
            while (*cptr) *sptr++ = TOLO(*cptr++);
         }
      }
      /* then any modules */
      for (ucnt = 1; ucnt; ucnt = ucnt << 1)
      {
#if WATCH_MOD
         cptr = WatchWhatModule (WatchConfig.Module & ucnt);
#endif
         if (cptr)
         {
            if (sptr > CategoryList)
            {
               *sptr++ = ',';
               if (sptr > zptr)
               {
                  zptr = sptr + eolcnt;
                  *sptr++ = '\n';
               }
               else
                  *sptr++ = ' ';
            }
            while (*cptr) *sptr++ = TOLO(*cptr++);
         }
      }
      *sptr = '\0';
   }

   vecptr = FaoVector;
   *vecptr++ = 0;
   *vecptr++ = ServerHostPort;
   *vecptr++ = 36 + strlen(ServerHostPort);
   *vecptr++ = HttpdProcess.ImageInfo;
   *vecptr++ = BuildDateTime;
   *vecptr++ = TcpIpAgentInfo;
   *vecptr++ = SesolaVersion(true);
   *vecptr++ = strchr(__VMS_VERSION, ' ') - __VMS_VERSION;
   *vecptr++ = __VMS_VERSION;
   *vecptr++ = __DECC_VER;
   *vecptr++ = WatchFuncCc;
   *vecptr++ = SysInfo.HwName;
   *vecptr++ = SysInfo.AvailCpuCnt;
   *vecptr++ = SysInfo.MemoryMB;
   *vecptr++ = SysInfo.Version;

#ifdef ODS_EXTENDED
   if (OdsExtended)
      *vecptr++ = "ODS-5 enabled";
   else
   if (SysInfo.VersionInteger >= 720)
      *vecptr++ = "ODS-5 disabled";
   else
      *vecptr++ = "ODS-5 unavailable";
#else /* ODS_EXTENDED */
   *vecptr++ = "ODS-5 unavailable";
#endif /* ODS_EXTENDED */

   *vecptr++ = ENAMEL_NAML_USED;
   *vecptr++ = ENAMEL_FIB_USED;
#if ODS_DIRECT
   *vecptr++ = OdsDirect ? "enabled" : "disabled";
#else
   *vecptr++ = "not compiled";
#endif /* ODS_DIRECT */

   if (Config.cfMisc.GzipResponseCompLevel)
   {
      if (VMSok(GzipFindImageStatus))
      {
         *vecptr++ = "!AZ V!AZ";
         *vecptr++ = GzipZlibNamePtr;
         *vecptr++ = GzipZlibVersionPtr;
      }
      else
      {
         *vecptr++ = "ZLIB !&S";
         *vecptr++ = GzipFindImageStatus;
      }
   }
   else
      *vecptr++ = "ZLIB disabled";

   *vecptr++ = Config.cfMisc.RegexSyntax ? "enabled" : "disabled";

   *vecptr++ = SysInfo.LockValueBlockSize;
   if (OperateWithSysPrv)
      *vecptr++ = ", SYSPRV";
   else
      *vecptr++ = "";
   *vecptr++ = CommandLine;
   *vecptr++ = WatchServerQuotas();

   if (DclScriptDetachProcess)
   {
      *vecptr++ = "DCL Scripting: detached, !&@PERSONA!AZ !AZ\n";
      if (HttpdScriptAsUserName[0])
      {
         if (CliScriptAs[0])
            *vecptr++ = "/script=as=!AZ, ";
         else
            *vecptr++ = "as !AZ, ";
         *vecptr++ = HttpdScriptAsUserName;
      }
      else
         *vecptr++ = "";
      if (PersonaMacro)
         *vecptr++ = "_MACRO";
      else
         *vecptr++ = "";
      if (DclPersonaServicesAvailable)
         *vecptr++ = "enabled";
      else
         *vecptr++ = "disabled";
   }
   else
   {
      *vecptr++ =
"DCL Scripting: subprocess\n\
BYTLM-available:!UL BYTLM-per-subproc:!&@ (approx !&@ subprocesses) \
BYTLM-net-accept:!UL BYTLM-net-listen:!UL\n";
      *vecptr++ = HttpdProcess.BytLmAvailable;
      if (DclMailboxBytLmRequired)
      {
         *vecptr++ = "!UL";
         *vecptr++ = DclMailboxBytLmRequired;
         *vecptr++ = "!UL";
         *vecptr++ = (HttpdProcess.BytLmAvailable -
                       (NetAcceptBytLmRequired * Config.cfServer.ConnectMax)) /
                     DclMailboxBytLmRequired;
      }
      else
      {
         *vecptr++ = "?";
         *vecptr++ = "?";
      }
      *vecptr++ = NetAcceptBytLmRequired;
      *vecptr++ = NetListenBytLmRequired;
   }

   *vecptr++ = HttpdProcess.PrcNam;
   *vecptr++ = HttpdProcess.ModeName;
   *vecptr++ = HttpdProcess.SysInput;
   *vecptr++ = HttpdProcess.SysOutput;

   InstanceNodePtr = InstanceClusterPtr = NULL;
   if (InstanceNodeCurrent > 1)
   {
      InstanceLockList (INSTANCE_NODE, ", ", &InstanceNodePtr);
      if (InstanceNodePtr)
      {
         *vecptr++ = "Node: !AZ\n";
         *vecptr++ = InstanceNodePtr;
      }
      else
         *vecptr++ = "";
   }
   else
      *vecptr++ = "";

   InstanceLockList (INSTANCE_CLUSTER, ", ", &InstanceClusterPtr);
   if (InstanceClusterPtr)
   {
      *vecptr++ = "Instances: !AZ\n";
      *vecptr++ = InstanceClusterPtr;
   }
   else
      *vecptr++ = "";

   if (WatchConfig.DoWatch && !WatchConfig.DoPeek)
   {
      *vecptr++ = "Watching: !AZ (!SL!&@) via !AZ\n!&@";
      *vecptr++ = CategoryList;
      *vecptr++ = WatchConfig.Category;
      if (WatchConfig.Module)
      {
         *vecptr++ = ",!SL";
         *vecptr++ = WatchConfig.Module;
      }
      else
         *vecptr++ = "";

      if (HTTP2_REQUEST(rqptr))
         *vecptr++ = "HTTP/2";
      else
      if (rqptr->rqHeader.HttpVersion == HTTP_VERSION_1_1)
         *vecptr++ = "HTTP/1.1";
      else
      if (rqptr->rqHeader.HttpVersion == HTTP_VERSION_1_0)
         *vecptr++ = "HTTP/1.0";
      else
         *vecptr++ = "HTTP/0.9";

      if (WatchConfig.FilterSet)
      {
         *vecptr++ =
"Filter Protocol:!AZ!AZ!AZ!AZ!AZ \
Client:!AZ:\"!AZ\" Service:!AZ:\"!AZ\" Request:!AZ:\"!AZ\" \
URI:!AZ:\"!AZ\" Realm:!AZ:\"!AZ\" User:!AZ:\"!AZ\" Status:IN:\"!&@\"\n";
         *vecptr++ = WatchConfig.FilterOutHttp ? "OUT" : "IN";
         *vecptr++ = WatchConfig.HttpFilter2 ? ":2" : "";
         *vecptr++ = WatchConfig.HttpFilter11 ? ":1.1" : "";
         *vecptr++ = WatchConfig.HttpFilter10 ? ":1.0" : "";
         *vecptr++ = WatchConfig.HttpFilter09 ? ":0.9" : "";
         *vecptr++ = WatchConfig.FilterOutClient ? "OUT" : "IN";
         *vecptr++ = WatchConfig.ClientFilter;
         *vecptr++ = WatchConfig.FilterOutService ? "OUT" : "IN";
         *vecptr++ = WatchConfig.ServiceFilter;
         *vecptr++ = WatchConfig.FilterOutRequest ? "OUT" : "IN";
         *vecptr++ = WatchConfig.RequestFilter;
         *vecptr++ = WatchConfig.FilterOutURI ? "OUT" : "IN";
         *vecptr++ = WatchConfig.PathFilter;
         *vecptr++ = WatchConfig.FilterOutRealm ? "OUT" : "IN";
         *vecptr++ = WatchConfig.RealmFilter;
         *vecptr++ = WatchConfig.FilterOutUser ? "OUT" : "IN";
         *vecptr++ = WatchConfig.UserFilter;
         if (WatchConfig.StatusFilter >= 0)
         {
            *vecptr++ = "!UL";
            *vecptr++ = WatchConfig.StatusFilter;
         }
         else
            *vecptr++ = "";
      }
      else
         *vecptr++ = "Filter: NONE\n";
   }
   else
      *vecptr++ = "";

   FaoCheck (sizeof(FaoVector), &FaoVector, vecptr, FI_LI);
   status = FaolToBuffer (Buffer, sizeof(Buffer), &Length,
                          ResponseFao, &FaoVector);
   if (VMSnok (status) || status == SS$_BUFFEROVF)
      ErrorNoticed (rqptr, status, NULL, FI_LI);

   /*******************/
   /* enable WATCHing */
   /*******************/

   /* detect a client stopping WATCHing */
   WatchBreakDetect (rqptr);

   if (InstanceNodePtr) VmFree (InstanceNodePtr, FI_LI);
   if (InstanceClusterPtr) VmFree (InstanceClusterPtr, FI_LI);

   /* make sure we get the duration we asked for! */
   HttpdTimerSet (rqptr, TIMER_TERMINATE, WatchConfig.DurationSeconds);

   /* allow browser WATCH to piggyback on CLI WATCH */
   if (!Watch.CliEnabled)
   {
      /* so that WatchNone() "restores" the WATCH items  */
      WatchConfig.Category2 = WatchConfig.Category;
      WatchConfig.Module2 = WatchConfig.Module;
      /* copy the configuration WATCH structure onto the operating WATCH */
      memcpy (&Watch, &WatchConfig, sizeof(Watch));
   }

   rqptr->rqResponse.NoGzip = true;
   rqptr->rqResponse.PreExpired = PRE_EXPIRE_ADMIN;
   ResponseHeader200 (rqptr, "text/plain", NULL);

   NetWrite (rqptr, NULL, Buffer, Length);

   /* the request now just "hangs", reading WATCH plain-text output! */
   Watch.RequestPtr = rqptr;

   /*****************************/
   /* now we're WatchWrite()ing */
   /*****************************/

   if (Watch.DoPeek)
   {
      if (rqeptr)
         WatchPeek (rqptr, rqeptr);
      else
      if (h2ptr)
         WatchPeekHttp2 (rqptr, h2ptr, "|HTTP/2_connection...|");

      if (!Watch.DoWatch)
      {
         /* no more WatchReset() use WatchEnd() to finish  */
         WatchEnd ();
         return;
      }
   }

#else /* WATCH_CAT */

   rqptr->rqResponse.HttpStatus = 403;
   ErrorGeneral (rqptr, ErrorWatchNoCategory, FI_LI);
   AdminEnd (rqptr);

#endif /* WATCH_CAT */
}

/*****************************************************************************/
/*
Set WATCH item indicator to be the supplied value.

If |rqptr| is NULL then it's intended to return an item number for the original
(NetAccept()) network I/O structure, or for an HTTP/2 connection (see below).

When |rqptr| non-NULL then needs to be set for the request across the WATCH
items in various structures.

An HTTP/2 connection can be set for WATCHing via Http2Report().  This will set
the item in the associated NETIO structure and the (usually) associated TLS/SSL
I/O structure.  So when setting the request's WATCH item first check to see if
the associated I/O structures have an item set and DO NOT (RE)SET if not the
same as the current request number to be set.

Requests over HTTP/2 have the original HTTP/2 WATCH item (if any) in the least
significant digits and the stream ID in the most.
*/ 

int WatchSetWatch
(
REQUEST_STRUCT *rqptr,
int item
)
{
#if WATCH_CAT

   static char  divider [] = "****************************************";

   int  number;
   HTTP2_STRUCT  *h2ptr;

   /*********/
   /* begin */
   /*********/

   if (DBUG && Watch.CliEnabled)
      fprintf (stdout, "WatchSetWatch() %d %d\n", rqptr, item);

   if (!Watch.CliEnabled && !Watch.RequestPtr) return (0);

   if (item == WATCH_NEW_ITEM)
   {
      WatchItemSize (rqptr);
      if (rqptr)
      {
         if (h2ptr = rqptr->Http2Stream.Http2Ptr)
         {
            if (h2ptr->WatchItem)
            {
               number = h2ptr->WatchItem & WATCH_ITEM_NUMBER_MASK;
               number = number % Watch.ItemPower2;
            }
            else
               number = ++Watch.ItemCount % Watch.ItemPower2;
            number += rqptr->Http2Stream.Ident * Watch.ItemPower2;
         }
         else
            number = ++Watch.ItemCount;
      }
      else
         number = ++Watch.ItemCount;
   }
   else
      number = item;

   if (rqptr)
   {
      if (Watch.CliEnabled)
         fprintf (stdout, "%s\nWatchSetWatch() %u->%u\n%s\n",
                  divider, rqptr->WatchItem, number, divider);

      if (h2ptr = rqptr->Http2Stream.Http2Ptr)
      {
         /* if not WATCHing the HTTP/2 connection */
         if (!(h2ptr->WatchItem & WATCH_ITEM_HTTP2_FLAG))
            Http2SetWatch (h2ptr, number);
      }
      else
      if (rqptr->NetIoPtr->SesolaPtr)
         SesolaSetWatch (rqptr->NetIoPtr->SesolaPtr, number);
      else
         rqptr->NetIoPtr->WatchItem = number;

      /* after I/O WATCH item set/reset request item */
      rqptr->WatchItem = number; 
   }
   else
   if (Watch.CliEnabled)
      fprintf (stdout, "%s\nWatchSetWatch() %u\n%s\n",
               divider, number, divider);

   return (number);

#endif /* WATCH_CAT */
}

/*****************************************************************************/
/*
WATCH item width starts at 6 digits (3 HTTP/2 ident plus 3 connection) and if
either overflows increments by 2 each time.
*/ 

void WatchItemSize (REQUEST_STRUCT *rqptr)

{
#if WATCH_CAT

   /*********/
   /* begin */
   /*********/

   if (Watch.CliEnabled) fprintf (stdout, "WatchItemSize()\n");

   if (!Watch.ItemWidth)
      Watch.ItemWidth = 6;
   else
   if (Watch.ItemCount+1 >= Watch.ItemPower2 ||
       (rqptr && rqptr->Http2Stream.Ident >= Watch.ItemPower2))
      Watch.ItemWidth += 2;

   if (Watch.ItemWidth != Watch.ItemDigits)
      Watch.ItemPower2 = ipow (10, Watch.ItemWidth / 2);

#endif /* WATCH_CAT */
}

/*****************************************************************************/
/*
Return true if an HTTP/2 rabbit hole (see prologue).
*/ 

BOOL WatchRabbitHole
(
WATCH_STRUCT *WatchPtr,
REQUEST_STRUCT *rqptr
)
{
#if WATCH_CAT

   /*********/
   /* begin */
   /*********/

   if (Watch.CliEnabled)
#if WATCH_MOD
      return (false);
#else
      fprintf (stdout, "WatchRabbitHole() %d\n", rqptr);
#endif

   if (rqptr &&
       rqptr->Http2Stream.Http2Ptr &&
       WatchPtr->RequestPtr &&
       rqptr->Http2Stream.Http2Ptr ==
          WatchPtr->RequestPtr->Http2Stream.Http2Ptr)
   {
      if (WatchPtr->DoPeek ||
#if WATCH_MOD
          WatchPtr->Module ||
#endif
          (WatchPtr->Category & WATCH_HTTP2) ||
          (WatchPtr->Category & WATCH_SESOLA) ||
          (WatchPtr->Category & WATCH_NETWORK) ||
          (WatchPtr->Category & WATCH_NETWORK_OCTETS))
         return (true);
   }

   return (false);

#endif /* WATCH_CAT */
}

/*****************************************************************************/
/*
Check and report if the WATCH facility is already being used (locally or via
another instance).  If has been observed, particularly with HTTP/2 and it's low
inter-request latency, that moving from actively WATCHing back to the WATCH
report menu can occur before the WATCHing request has a chance to run-down and
release the WATCH report.  This results in the user getting a "watch in use". 
To workaround this the code checks for that same client in what is probably
this scenario and allows the access.  It will be blocked once the client clicks
[WATCH] anyway.
*/ 

#if WATCH_CAT

BOOL WatchInUse
(
REQUEST_STRUCT *rqptr,
BOOL ReserveWatch
)
{
   BOOL  InstanceWatchInUse,
         LocalWatchInUse,
         SameClient;
   int  status;
   ushort  Length;
   ulong  *vecptr;
   ulong  FaoVector [8];
   char  *uac1ptr, *uac2ptr;
   char  Buffer [256];

   /*********/
   /* begin */
   /*********/

   if (DBUG && Watch.CliEnabled)
      fprintf (stdout, "WatchInUse()\n");

   if (Watch.CliEnabled) return (false);

   if (!rqptr)
   {
      /* release WATCH */
      if (VMSnok (status = InstanceUnLock (INSTANCE_NODE_WATCH)))
         ErrorExitVmsStatus (status, "InstanceUnLock()", FI_LI);
      return (false);
   }

   LocalWatchInUse = InstanceWatchInUse = SameClient = false;

   /* attempt to obtain the WATCH lock */
   status = InstanceLockNoWait (INSTANCE_NODE_WATCH);
   if (status == SS$_NOTQUEUED)
   {
      /* the lock is already in use (WATCH is in use elsewhere) */
      if (Watch.RequestPtr || Watch.Category || Watch.Module)
         LocalWatchInUse = true;
      else
         InstanceWatchInUse = true;
   }
   else
   {
      /* allows for CLI WATCH */
      if (LocalWatchInUse = Watch.Category || Watch.Module)
         if (VMSnok (status = InstanceUnLock (INSTANCE_NODE_WATCH)))
            ErrorExitVmsStatus (status, "InstanceUnLock()", FI_LI);
   }

   /* if not actually engaging WATCH report and are the same client */
   if ((LocalWatchInUse || InstanceWatchInUse) && !ReserveWatch)
   {
      /* bit clumsy but minimised required coding */
      uac1ptr = UserAtClient (rqptr);
      uac2ptr = UserAtClient (Watch.RequestPtr);
      if (!strcmp (uac1ptr, uac2ptr)) SameClient = true;
   }

   if (!(LocalWatchInUse || InstanceWatchInUse) || SameClient)
   {
      if (ReserveWatch)
         Watch.RequestPtr = rqptr;
      else
      if (!SameClient)
         if (VMSnok (status = InstanceUnLock (INSTANCE_NODE_WATCH)))
            ErrorExitVmsStatus (status, "InstanceUnLock()", FI_LI);
      return (false);
   }

   /* allow browser WATCH to piggyback on CLI WATCH */
   if (Watch.CliEnabled)
   {
      if (ReserveWatch) Watch.RequestPtr = rqptr;
      return (false);
   }

   vecptr = FaoVector;
   if (InstanceWatchInUse)
      *vecptr++ = "via another instance.";
   else
   if (Watch.RequestPtr)
   {
      *vecptr++ = "by !AZ";
      *vecptr++ = UserAtClient(Watch.RequestPtr);
   }
   else
      *vecptr++ = "via /WATCH";

   status = FaolToBuffer (Buffer, sizeof(Buffer), &Length,
                          "WATCH is currently in use !&@", &FaoVector);
   if (VMSnok (status)) ErrorNoticed (rqptr, status, NULL, FI_LI);

   Buffer[Length] = '\0';
   rqptr->rqResponse.HttpStatus = 403;
   ErrorGeneral (rqptr, Buffer, FI_LI);
   return (true);
}                                   

#endif /* WATCH_CAT */

/*****************************************************************************/
/*
Request using the WATCH facility drops the connection.  Release WATCH.
*/ 

void WatchEnd ()

{
#if WATCH_CAT

   static char  BufferFao [] = "|!%T end|\n\0";

   ushort  slen;
   char  Buffer [32];

   /*********/
   /* begin */
   /*********/

   if (Watch.CliEnabled) fprintf (stdout, "WatchEnd()\n");

   if (!Watch.RequestPtr) return;

   WatchNone (true);
   FaoToBuffer (Buffer, sizeof(Buffer), &slen, BufferFao, 0);
   WatchWrite (Buffer, slen-1);
   WatchWrite (NULL, 0);
   Watch.EndWatch = true;
   WatchNone (false);

#endif /* WATCH_CAT */
}                                   

/*****************************************************************************/
/*
Reset the WATCH structure.
*/ 

void WatchReset ()

{
#if WATCH_CAT

   /*********/
   /* begin */
   /*********/

   if (Watch.CliEnabled) fprintf (stdout, "WatchReset()\n");

   if (!Watch.RequestPtr) return;

   if (Watch.CliEnabled)
      Watch.RequestPtr = NULL;
   else
   {
      /* reset WATCH environment */
      WatchSetWatch (NULL, 0);
      memset (&Watch, 0, sizeof(WATCH_STRUCT));
      WatchInUse (NULL, false);
   }

#endif /* WATCH_CAT */
}                                   

/*****************************************************************************/
/*
The WATCH client concluding the watching can only be detected via a break in
connection which in a quiescent system (no requests being processed) can in
turn only be detected by a broken network read I/O or a TLS/SSL shutdown
exchange initiated.
*/ 

void WatchBreakDetect (REQUEST_STRUCT *rqptr)

{
#if WATCH_CAT

   static uchar  buf [32];

   /*********/
   /* begin */
   /*********/

   if (Watch.CliEnabled)
      fprintf (stdout, "WatchBreakDetect() 0x%08.08X 0x%08.08X 0x%08.08X\n",
               rqptr, rqptr->NetIoPtr->ReadPtr, buf);

   if (rqptr->NetIoPtr->ReadPtr == buf)
      WatchEnd ();
   else
      NetRead (rqptr, &WatchBreakDetect, buf, sizeof(buf));

#endif /* WATCH_CAT */
}

/*****************************************************************************/
/*
Write WATCH report output to <stdout> and network client as appropriate.
To reduce network latency of the often highly granular WATCH data use two
dynamic string buffers, filling one while the other is being written to the
client.
*/

void WatchWrite
(
void *DataPtr,
uint DataLength
)
{
#if WATCH_CAT

#define WATCH_STRDSC_SIZE 16384

   int  length;
   STR_DSC_AUTO (DataDsc);
   REQUEST_STRUCT  *rqptr;

   /*********/
   /* begin */
   /*********/

   if (0 && Watch.CliEnabled)
      fprintf (stdout, "WatchWrite() %d %d\n", DataPtr, DataLength);

   if (DataPtr)
   {
      if (DataLength < 0) DataLength = strlen(DataPtr);
      if (Watch.CliEnabled || Watch.StdoutToo || Watch.StdoutOnly)
         fwrite (DataPtr, DataLength, 1, stdout);
   }

   if (!Watch.RequestPtr && !Watch.StdoutOnly) return;

   /******************/
   /* network client */
   /******************/

   WatchNone (true);

   rqptr = Watch.RequestPtr;

   /* do not continue adding to the buffer if finishing up */
   if (!Watch.EndWatch)
   {
      if (DataPtr)
      {
         if (!STR_DSC_SANITY(&Watch.BufferDsc))
            StrDscBegin (rqptr, &Watch.BufferDsc, WATCH_STRDSC_SIZE);
         if (!STR_DSC_SANITY(&rqptr->NetWriteBufferDsc))
            StrDscBegin (rqptr, &rqptr->NetWriteBufferDsc, 0);

         StrDscThis (NULL, &DataDsc, DataPtr, DataLength);
         StrDscBuild (&Watch.BufferDsc, &DataDsc, NULL);
      }
   }

   if (!Watch.AstInUse && STR_DSC_SANITY(&Watch.BufferDsc))
   {
      length = StrDscLength (&Watch.BufferDsc);
      if ((!DataPtr && length) || (DataPtr && length > WATCH_STRDSC_SIZE))
      {
         StrDscSwap (&Watch.BufferDsc, &rqptr->NetWriteBufferDsc);
         StrDscNoContent (&Watch.BufferDsc);
         NetWriteStrDsc (rqptr, Watch.AstInUse = WatchWriteAst);
      }
   }

   WatchNone (false);

#endif /* WATCH_CAT */
}

/*****************************************************************************/
/*
If the the WATCH request pointer has been NULLed indicating the ending of the
WATCH report then reset the WATCH configuration ending the request.
*/

void WatchWriteAst (REQUEST_STRUCT *rqptr)

{
   /*********/
   /* begin */
   /*********/

#if WATCH_CAT

   if (0 && Watch.CliEnabled)
      fprintf (stdout, "WatchWriteAst()\n");

   Watch.AstInUse = NULL;

   if (VMSok (rqptr->NetIoPtr->WriteStatus))
   {
      if (!Watch.EndWatch) return;

      if (STR_DSC_SANITY(&Watch.BufferDsc) &&
          StrDscLength (&Watch.BufferDsc))
      {
         /* buffer has remaining content */
         WatchWrite (NULL, 0);
         return;
      }
   }

   WatchNone (true);
   WatchReset ();
   AdminEnd (rqptr);
   WatchNone (false);

#endif /* WATCH_CAT */
}

/*****************************************************************************/
/*
Temporarily suppress category and module WATCHing while using routines that
provide WATCH points - or all hell breaks loose :-D   Note that WatchBegin()
actually puts the WATCH items into .Category2 and .Module2 while WatchNone() is
in effect and these are "restored" to the active flags.
*/ 

void WatchNone (BOOL none)

{
   static int  NoneDepth = 0;

   /*********/
   /* begin */
   /*********/

#if WATCH_CAT

   if (none)
   {
      if (NoneDepth++ == 0)
      {
         Watch.Category2 = Watch.Category;
         Watch.Module2 = Watch.Module;
         Watch.Category = Watch.Module = 0;
      }
   }
   else
   {
      if (NoneDepth == 0)
         ErrorExitVmsStatus (SS$_BUGCHECK, ErrorSanityCheck, FI_LI);
      if (--NoneDepth == 0)
      {
         Watch.Category = Watch.Category2;
         Watch.Module = Watch.Module2;
         Watch.Category2 = Watch.Module2 = 0;
      }
   }

#endif /* WATCH_CAT */
}                                   

/*****************************************************************************/
/*
Filter on the HTTP protocol.
*/ 

void WatchFilterHttpProtocol (REQUEST_STRUCT *rqptr)

{
   BOOL  hit;
   char  *aptr;

   /*********/
   /* begin */
   /*********/

#if WATCH_CAT

   /* can occur if ASTs are delivered after WATCH use is discontinued */
   if (!Watch.Category && !Watch.Module) return;

   if (Watch.Category == WATCH_ONE_SHOT_CAT) return;

   if (!Watch.FilterSet) return;

   if (HTTP2_REQUEST(rqptr))
   {
      hit = Watch.HttpFilter2;
      aptr = "HTTP/2";
   }
   else
   if (rqptr->rqResponse.HttpVersion == HTTP_VERSION_1_1)
   {
      hit = Watch.HttpFilter11;
      aptr = "HTTP/1.1";
   }
   else
   if (rqptr->rqResponse.HttpVersion == HTTP_VERSION_1_0)
   {
      hit = Watch.HttpFilter10;
      aptr = "HTTP/1.0";
   }
   else
   if (rqptr->rqResponse.HttpVersion == HTTP_VERSION_0_9)
   {
      hit = Watch.HttpFilter09;
      aptr = "HTTP/0.9";
   }
   else
   {
      hit = false;
      aptr = "*BUGCHECK*";
   }

   if (Watch.FilterOutHttp)
   {
      /* if matches filter out */
      if (hit && rqptr->WatchItem)
         WatchFilterDrop (rqptr, aptr);
      else
      /* if doesn't match filter in */
      if (!hit && !rqptr->WatchItem)
         WatchFilterAdd (rqptr, aptr);
   }
   else
   /* if matches filter in */
   if (hit)
      WatchFilterAdd (rqptr, aptr);

#endif /* WATCH_CAT */
}                                   

/*****************************************************************************/
/*
Filter first on the client host name or address, then second on the service
(virtual host) name.  If the filter begins with a scheme (i.e. "http:" or
"https:") then filter on that as well.
*/ 

void WatchFilterClientService (REQUEST_STRUCT *rqptr)

{
   BOOL  match;
   int  WatchItem;
   char  *aptr, *cptr, *sptr;

   /*********/
   /* begin */
   /*********/

#if WATCH_CAT

   /* can occur if ASTs are delivered after WATCH use is discontinued */
   if (!Watch.Category && !Watch.Module) return;

   if (Watch.Category == WATCH_ONE_SHOT_CAT) return;

   if (!Watch.FilterSet)
   {
      /* WATCH is enabled but no filters have been specified */
      if (!WATCHING (rqptr, WATCH_CONNECT)) return;
      if (rqptr != Watch.RequestPtr)
      {
         WatchItem = rqptr->WatchItem;
         WatchSetWatch (rqptr, WATCH_NEW_ITEM);
         if (HTTP2_REQUEST(rqptr))
         {
            WatchThis (WATCHITM(rqptr), WATCH_CONNECT,
                       "HTTP/2 begin !UL with !AZ,!UL on !AZ//!AZ,!UL (!&I)",
                       rqptr->Http2Stream.Ident,
                       rqptr->ClientPtr->Lookup.HostName,
                       rqptr->ClientPtr->IpPort, 
                       rqptr->ServicePtr->RequestSchemeNamePtr,
                       rqptr->ServicePtr->ServerHostName,
                       rqptr->ServicePtr->ServerPort,
                       &rqptr->ServicePtr->ServerIpAddress);
            if (WatchRabbitHole (&Watch, rqptr))
            {
               WatchThis (WATCHITM(rqptr), WATCH_CONNECT, "HTTP/2 rabbit hole");
               WatchSetWatch (rqptr, 0);
            }
         }
         else
         if (rqptr->rqNet.PersistentCount)
            WatchThis (WATCHITM(rqptr), WATCH_CONNECT,
                       "PERSISTENT (!#ZL) with !AZ,!UL on !AZ//!AZ,!UL (!&I)",
                       Watch.ItemWidth, WatchItem,
                       rqptr->ClientPtr->Lookup.HostName,
                       rqptr->ClientPtr->IpPort, 
                       rqptr->ServicePtr->RequestSchemeNamePtr,
                       rqptr->ServicePtr->ServerHostName,
                       rqptr->ServicePtr->ServerPort,
                       &rqptr->ServicePtr->ServerIpAddress);
      }
      else
         WatchSetWatch (rqptr, 0);
      return;
   }

   if (!Watch.ClientFilter[0] && !Watch.ServiceFilter[0]) return;

   if (Watch.ClientFilter[0])
   {
      aptr = "CLIENT";
      sptr = Watch.ClientFilter;
      if (isdigit(*sptr))
         cptr = rqptr->ClientPtr->IpAddressString;
      else
         cptr = rqptr->ClientPtr->Lookup.HostName;

      WatchNone (true);
      match = StringMatchRegex (rqptr, cptr, sptr);
      WatchNone (false);
      if (match)
      {
         if (Watch.FilterOutClient)
         {
            WatchFilterDrop (rqptr, aptr);
            return;
         }
      }
      else
      if (!Watch.FilterOutClient)
         return;
   }

   if (Watch.ServiceFilter[0])
   {
      if (Watch.ClientFilter[0])
         aptr = "CLIENT+SERVICE";
      else
         aptr = "SERVICE";
      sptr = Watch.ServiceFilter;
      /* filter on service */
      if (MATCH5 (sptr, "http:"))
      {
         if (rqptr->ServicePtr->RequestScheme == SCHEME_HTTP)
            if (Watch.FilterOutService)
            {
               WatchFilterDrop (rqptr, aptr);
               return;
            }
         sptr += 5;
      }
      else
      if (MATCH6 (sptr, "https:"))
      {
         if (rqptr->ServicePtr->RequestScheme == SCHEME_HTTPS)
            if (Watch.FilterOutService)
            {
               WatchFilterDrop (rqptr, aptr);
               return;
            }
         sptr += 6;
      }
      while (*sptr == '/') sptr++;
      cptr = rqptr->ServicePtr->ServerHostPort;
      WatchNone (true);
      match = StringMatchRegex (rqptr, cptr, sptr);
      WatchNone (false);
      if (match)
      {
         if (Watch.FilterOutService)
         {
            WatchFilterDrop (rqptr, aptr);
            return;
         }
      }
      else
      if (!Watch.FilterOutService)
         return;
   }

   if (rqptr->WatchItem) return;

   WatchFilterAdd (rqptr, aptr);

#endif /* WATCH_CAT */
}                                   

/*****************************************************************************/
/*
Filter on the request's path or URI if the path does not begin with a slash
(e.g. if a proxy request).  If the filter begins with a dollar and track IDs
are being generated consider a track has been specified.
*/ 

void WatchFilterPathTrack (REQUEST_STRUCT *rqptr)

{
   BOOL  match;
   char  *aptr, *cptr, *sptr;

   /*********/
   /* begin */
   /*********/

#if WATCH_CAT

   /* can occur if ASTs are delivered after WATCH use is discontinued */
   if (!Watch.Category && !Watch.Module) return;

   if (!Watch.FilterSet) return;
   if (!Watch.PathFilter[0]) return;
   /* if filtering-in and it's already being WATChed */
   if (!Watch.FilterOutURI && rqptr->WatchItem) return;

   sptr = Watch.PathFilter;
   cptr = NULL;
   aptr = "URI";
   cptr = rqptr->rqHeader.RequestUriPtr;
   if (!cptr)
   {
      if (Watch.FilterOutURI)
      {
         WatchFilterDrop (rqptr, aptr);
         return;
      }
   }

   WatchNone (true);
   match = StringMatchRegex (rqptr, cptr, sptr);
   WatchNone (false);
   if (match)
   {
      if (Watch.FilterOutURI)
      {
         WatchFilterDrop (rqptr, aptr);
         return;
      }
   }
   else
   if (!Watch.FilterOutURI)
      return;

   if (rqptr->WatchItem) return;

   WatchFilterAdd (rqptr, aptr);

   /* if wanting request header report then satisfy at this late stage */
   if (WATCHING(rqptr,WATCH_REQUEST_HEADER))
   {
      WatchThis (WATCHITM(rqptr), WATCH_REQUEST_HEADER, "DATA");
      DictWatchEntry (NULL);
      DictWatch (rqptr->rqDictPtr, DICT_TYPE_INTERNAL, "request_line");
      DictWatch (rqptr->rqDictPtr, DICT_TYPE_REQUEST, "*");
   }

#endif /* WATCH_CAT */
}                                   

/*****************************************************************************/
/*
Filter first on the *entire* request header.
*/ 

void WatchFilterRequestHeader (REQUEST_STRUCT *rqptr)

{
   BOOL  match;
   char  *aptr, *cptr, *sptr;
   DICT_ENTRY_STRUCT  *denptr;

   /*********/
   /* begin */
   /*********/

#if WATCH_CAT

   /* can occur if ASTs are delivered after WATCH use is discontinued */
   if (!Watch.Category && !Watch.Module) return;

   if (Watch.Category == WATCH_ONE_SHOT_CAT) return;

   if (!Watch.FilterSet) return;
   if (!Watch.RequestFilter[0]) return;
   /* if filtering-in and it's already being WATChed */
   if (!Watch.FilterOutRequest && rqptr->WatchItem) return;

   if (!(cptr = rqptr->rqHeader.RequestHeaderPtr))
   {
      if ((denptr = RequestDictHeader (rqptr)) == NULL) return;
      cptr = DICT_GET_VALUE(denptr);
   }

   aptr = "REQUEST";
   sptr = Watch.RequestFilter;
   WatchNone (true);
   match = StringMatchRegex (rqptr, cptr, sptr);
   WatchNone (false);
   if (match)
   {
      if (Watch.FilterOutRequest)
      {
         WatchFilterDrop (rqptr, aptr);
         return;
      }
   }
   else
   if (!Watch.FilterOutRequest)
      return;

   if (rqptr->WatchItem) return;

   WatchFilterAdd (rqptr, aptr);

   /* if wanting request header report then satisfy at this late stage */
   if (WATCH_CATEGORY(WATCH_REQUEST_HEADER))
   {
      WatchThis (WATCHITM(rqptr), WATCH_REQUEST_HEADER, "DATA");
      DictWatchEntry (NULL);
      DictWatch (rqptr->rqDictPtr, DICT_TYPE_INTERNAL, "request_line");
      DictWatch (rqptr->rqDictPtr, DICT_TYPE_REQUEST, "*");
   }

#endif /* WATCH_CAT */
}                                   

/*****************************************************************************/
/*
Filter on the HTTP status value (late in the request I know).
*/ 

void WatchFilterHttpStatus (REQUEST_STRUCT *rqptr)

{
   char  *aptr; 

   /*********/
   /* begin */
   /*********/

#if WATCH_CAT

   /* can occur if ASTs are delivered after WATCH use is discontinued */
   if (!Watch.Category && !Watch.Module) return;

   if (Watch.Category == WATCH_ONE_SHOT_CAT) return;

   if (!Watch.FilterSet) return;
   if (Watch.StatusFilter < 0) return;
   /* if it's already being WATChed */
   if (rqptr->WatchItem) return;

   aptr = "STATUS";
   if ((Watch.StatusFilter && Watch.StatusFilter <= 5 &&
        rqptr->rqResponse.HttpStatus / 100 == Watch.StatusFilter) ||
       rqptr->rqResponse.HttpStatus == Watch.StatusFilter)
   {
      if (Watch.FilterOutRequest)
      {
         WatchFilterDrop (rqptr, aptr);
         return;
      }
   }
   else
   if (!Watch.FilterOutRequest)
      return;

   if (rqptr->WatchItem) return;

   WatchFilterAdd (rqptr, aptr);

   /* if wanting request header report then satisfy at this late stage */
   if (WATCH_CATEGORY(WATCH_REQUEST_HEADER))
   {
      WatchThis (WATCHITM(rqptr), WATCH_REQUEST_HEADER, "DATA");
      DictWatchEntry (NULL);
      DictWatch (rqptr->rqDictPtr, DICT_TYPE_INTERNAL, "request_line");
      DictWatch (rqptr->rqDictPtr, DICT_TYPE_REQUEST, "*");
   }

   /* same for authorisation data */
   if (WATCH_CATEGORY(WATCH_AUTH))
      if (rqptr->RemoteUser[0])
         WatchThis (WATCHITM(rqptr), WATCH_AUTH,
"user:\'!AZ\' details:\'!AZ\' can:!AZ remote:\'!AZ\' realm:\'!AZ\'",
                    rqptr->RemoteUser,
                    rqptr->rqAuth.UserDetailsPtr,
                    AuthCanString (rqptr->rqAuth.RequestCan,
                                   AUTH_CAN_FORMAT_LONG),
                    rqptr->rqAuth.RemoteUser,
                    rqptr->rqAuth.RealmPtr);

#endif /* WATCH_CAT */
}                                   

/*****************************************************************************/
/*
Filter first on authentication realm (if applicable) then on authenticated
(remote) user (if applicable). 
*/ 

void WatchFilterRealmUser (REQUEST_STRUCT *rqptr)

{
   BOOL  match;
   char  *aptr, *cptr, *sptr;

   /*********/
   /* begin */
   /*********/

#if WATCH_CAT

   /* can occur if ASTs are delivered after WATCH use is discontinued */
   if (!Watch.Category && !Watch.Module) return;

   if (Watch.Category == WATCH_ONE_SHOT_CAT) return;

   if (!Watch.FilterSet) return;
   if (!Watch.RealmFilter[0] && !Watch.UserFilter[0]) return;
   /* if filtering-in and it's already being WATChed */
   if (!Watch.FilterOutRealm &&
       !Watch.FilterOutUser &&
       rqptr->WatchItem) return;

   if (Watch.RealmFilter[0])
   {
      aptr = "REALM";
      sptr = Watch.RealmFilter;
      cptr = rqptr->rqAuth.RealmPtr;
      WatchNone (true);
      match = StringMatchRegex (rqptr, cptr, sptr);
      WatchNone (false);
      if (match)
      {
         if (Watch.FilterOutRealm)
         {
            WatchFilterDrop (rqptr, aptr);
            return;
         }
      }
      else
      if (!Watch.FilterOutRealm)
         return;
   }

   if (Watch.UserFilter[0])
   {
      if (Watch.RealmFilter[0])
         aptr = "REALM+USER";
      else
         aptr = "USER";
      sptr = Watch.UserFilter;
      cptr = rqptr->RemoteUser;
      WatchNone (true);
      match = StringMatchRegex (rqptr, cptr, sptr);
      WatchNone (false);
      if (match)
      {
         if (Watch.FilterOutUser)
         {
            WatchFilterDrop (rqptr, aptr);
            return;
         }
      }
      else
      if (!Watch.FilterOutUser)
         return;
   }

   if (rqptr->WatchItem) return;

   WatchFilterAdd (rqptr, aptr);

   /* if wanting request header report then satisfy at this late stage */
   if (WATCH_CATEGORY(WATCH_REQUEST_HEADER))
   {
      WatchThis (WATCHITM(rqptr), WATCH_REQUEST_HEADER, "DATA");
      DictWatchEntry (NULL);
      DictWatch (rqptr->rqDictPtr, DICT_TYPE_INTERNAL, "request_line");
      DictWatch (rqptr->rqDictPtr, DICT_TYPE_REQUEST, "*");
   }

#endif /* WATCH_CAT */
}                                   

/*****************************************************************************/
/*
If the request is not already being WATCHED then allocate a WATCH item number
and report it's addition.
*/ 

void WatchFilterAdd
(
REQUEST_STRUCT *rqptr,
char *AddingThis
)
{
   /*********/
   /* begin */
   /*********/

#if WATCH_CAT

   if (rqptr != Watch.RequestPtr)
   {
      WatchSetWatch (rqptr, WATCH_NEW_ITEM);
      WatchThis (WATCHITM(rqptr), WATCH_FILTER,
                 "!AZ adding !AZ,!UL on !AZ//!AZ,!UL (!&I)",
                 AddingThis,
                 rqptr->ClientPtr->Lookup.HostName,
                 rqptr->ClientPtr->IpPort, 
                 rqptr->ServicePtr->RequestSchemeNamePtr,
                 rqptr->ServicePtr->ServerHostName,
                 rqptr->ServicePtr->ServerPort,
                 &rqptr->ServicePtr->ServerIpAddress);
      if (WatchRabbitHole (&Watch, rqptr))
      {
         WatchThis (WATCHITM(rqptr), WATCH_FILTER, "HTTP/2 rabbit hole");
         WatchSetWatch (rqptr, 0);
      }
   }

#endif /* WATCH_CAT */
}                                   

/*****************************************************************************/
/*
If the request is currently being WATCHED then report it's removal and reset
the WATCH item number.
*/ 

void WatchFilterDrop
(
REQUEST_STRUCT *rqptr,
char *DroppingThis
)
{
   /*********/
   /* begin */
   /*********/

#if WATCH_CAT

   if (rqptr->WatchItem)
      WatchThis (WATCHITM(rqptr), WATCH_FILTER,
                 "!AZ dropping from WATCH", DroppingThis);
   rqptr->WatchItem = 0;

#endif /* WATCH_CAT */
}                                   

/*****************************************************************************/
/*
Provide a formatted WATCH entry.  |ReportFormat| parameter must be in a
sys$fao() acceptable format and sufficient variable number parameters be
supplied to satisfy any FAO directives in that format string.  The |WatchItem|,
|SourceModuleName| and |SourceLineNumber| are passed by the macros |WATCHITM|
and |WATCHALL|.  These macros provide compile time flexibility in the various
data structures (e.g. request, HTTP/2, network IO) that can be used to initiate
WATCH points.  All the |WATCHITM| structures need is a |->WatchItem| field. 
The |WATCHALL| just uses the item number zero.
*/ 

void WatchThis
(
int WatchItem,
char *SourceModuleName,
int SourceLineNumber,
int Category,
char *ReportFormat,
...
)
{
#if WATCH_CAT

   static char  BufferFao [] = "!&@!AZ|!%T !8AZ !4ZL !#ZL !10AZ !&@|\n";

   int  argcnt, status;
   ushort  slen;
   ulong  *vecptr;
   ulong  FaoVector [128];
   char  *cptr;
   char  Buffer [8192];
   va_list  argptr;
   WATCH_STRUCT  WatchBuffer;

   /*********/
   /* begin */
   /*********/

   if (DBUG && Watch.CliEnabled)
      fprintf (stdout, "WatchThis() %d |%s|\n", argcnt, ReportFormat);

   /* this can occur if ASTs are delivered after WATCH use is discontinued */
   if (!Watch.Category && !Watch.Module) return;

   WatchNone (true);

   /* fudge for SESOLANET and SESOLANETIO within 8 chars */
   if (MATCH8 (SourceModuleName+3, "OLANETIO")) SourceModuleName += 3;

   vecptr = FaoVector;

   if (!Watch.ItemWidth ||
       Watch.ItemWidth != Watch.ItemDigits)
   {
      WatchItemSize (NULL);
      Watch.ItemDigits = Watch.ItemWidth;
      *vecptr++ = WatchItemHeader;
      *vecptr++ = Watch.ItemWidth - 4;
   }
   else
      *vecptr++ = "";

   if (Category & WATCH_INTERNAL)
      *vecptr++ = WatchServerQuotas ();
   else
      *vecptr++ = "";

   *vecptr++ = 0;
   *vecptr++ = SourceModuleName;
   *vecptr++ = SourceLineNumber;
   *vecptr++ = Watch.ItemWidth; 
   *vecptr++ = WatchItem & WATCH_ITEM_NUMBER_MASK;
#if WATCH_MOD
   if (Category & WATCH_MODULE_FLAG)
      cptr = WatchWhatModule (Category);
   else
#endif /* WATCH_MOD */
      cptr = WatchWhatCategory (Category);
   if (!cptr) cptr = "????????";
   *vecptr++ = cptr;

   /* append the report format string and it's parameters */
   *vecptr++ = ReportFormat;
   va_count (argcnt);
   va_start (argptr, ReportFormat);
   for (argcnt -= 5; argcnt; argcnt--)
      *vecptr++ = va_arg (argptr, unsigned long);
   va_end (argptr);

   if (Category & WATCH_INTERNAL)
      *vecptr++ = WatchServerQuotas ();
   else
      *vecptr++ = "";

   FaoCheck (sizeof(FaoVector), &FaoVector, vecptr, FI_LI);
   status = FaolToBuffer (Buffer, sizeof(Buffer), &slen,
                          BufferFao, &FaoVector);

   if (VMSnok (status) || status == SS$_BUFFEROVF)
      fprintf (stdout, "%%HTTPD-W-NOTICED2, %s:%d FaolToBuffer() %%X%08.08X\n",
               FI_LI, status);

   WatchWrite (Buffer, slen);

   WatchNone (false);

#endif /* WATCH_CAT */
}

/*****************************************************************************/
/*
Function to provide a formatted data WATCH entry, with trailing information
from the caller.  'DataFormat' parameter must be in a sys$fao() acceptable
format and sufficient variable number parameters be supplied to satisfy any FAO
directives in that format string.  Should include appropriate carriage-control.
*/ 

void WatchDataFormatted
(
char *DataFormat,
...
)
{
#if WATCH_CAT

   int  status,
        argcnt;
   ushort  slen;
   ulong  *vecptr;
   ulong  FaoVector [64];
   char  Buffer [65535];
   va_list  argptr;

   /*********/
   /* begin */
   /*********/

   va_count (argcnt);

   if (DBUG && Watch.CliEnabled)
      fprintf (stdout, "WatchDataFormatted() %d\n", argcnt);

   /* this can occur if ASTs are delivered after WATCH use is discontinued */
   if (!Watch.Category && !Watch.Module) return;

   vecptr = FaoVector;
   va_start (argptr, DataFormat);
   for (argcnt -= 1; argcnt; argcnt--)
      *vecptr++ = va_arg (argptr, ulong);
   va_end (argptr);

   WatchNone (true);

   status = FaolToBuffer (Buffer, sizeof(Buffer), &slen,
                          DataFormat, &FaoVector);
   if (VMSnok (status) || status == SS$_BUFFEROVF)
      ErrorNoticed (NULL, status, NULL, FI_LI);
   Buffer[slen] = '\0';

   WatchNone (false);

   WatchWrite (Buffer, slen);

#endif /* WATCH_CAT */
}

/*****************************************************************************/
/*
Output the supplied, non-formatted data in the WATCH report.  Allows any
printable output to be included as a block in the WATCH output.
*/ 

void WatchData
(
char *DataPtr,
int DataLength
)
{
#if WATCH_CAT

   /* see comment against StrDscThis() */
   char  newline = '\n';

   /*********/
   /* begin */
   /*********/

   if (DBUG && Watch.CliEnabled)
      fprintf (stdout, "WatchData() %d\n", DataLength);

   /* this can occur if ASTs are delivered after WATCH use is discontinued */
   if (!Watch.Category && !Watch.Module) return;

   if (!DataPtr) return;

   if (DataLength == -1) DataLength = strlen(DataPtr);

   WatchWrite (DataPtr, DataLength);

   if (DataLength && DataPtr[DataLength-1] != '\n')
      WatchWrite (&newline, 1);

#endif /* WATCH_CAT */
}

/*****************************************************************************/
/*
Output the supplied data using WATCH as a hex and printable character dump.
If the data length is negative dump to <stdout>.
*/ 

void WatchDataDump
(
char *DataPtr,
int DataLength
)
{
#if WATCH_CAT

#define MAX_LINES 128
#define BYTES_PER_LINE 32
#define HEX_PER_LINE (BYTES_PER_LINE * 2)
#define BYTES_PER_GROUP 4
#define GROUPS_PER_LINE (BYTES_PER_LINE / BYTES_PER_GROUP)
#define CHARS_PER_LINE ((HEX_PER_LINE + GROUPS_PER_LINE + BYTES_PER_LINE) + 1)

   static char  HexDigits [] = "0123456789ABCDEF";

   BOOL  ToStdout;
   int  ByteCount,
        CurrentDataCount,
        DataCount;
   char  *cptr, *sptr, *zptr,
         *CurrentDataPtr,
         *CurrentDumpPtr;
   char  DumpBuffer [(CHARS_PER_LINE * MAX_LINES) + 1];

   /*********/
   /* begin */
   /*********/

   if (DBUG && Watch.CliEnabled)
      fprintf (stdout, "WatchDataDump() %d\n", DataLength);

   if (ToStdout = DataLength < 0) DataLength *= -1;

   /* this can occur if ASTs are delivered after WATCH use is discontinued */
   if (!Watch.Category && !Watch.Module && !ToStdout) return;

   if (!DataPtr) return;

   zptr = (sptr = DumpBuffer) + sizeof(DumpBuffer)-1;
   cptr = DataPtr;
   DataCount = DataLength;

   while (DataCount)
   {
      CurrentDumpPtr = sptr;
      CurrentDataPtr = cptr;
      CurrentDataCount = DataCount;

      ByteCount = BYTES_PER_LINE;
      while (ByteCount && DataCount)
      {
         if (sptr >= zptr)
         {
            ErrorNoticed (NULL, SS$_BUFFEROVF, NULL, FI_LI);
            return;
         }
         *sptr++ = HexDigits[*(uchar*)cptr >> 4];
         *sptr++ = HexDigits[*(uchar*)cptr & 0xf];
         cptr++;
         DataCount--;
         ByteCount--;
         if (!(ByteCount % BYTES_PER_GROUP)) *sptr++ = ' ';
      }
      while (ByteCount)
      {
         if (sptr >= zptr)
         {
            ErrorNoticed (NULL, SS$_BUFFEROVF, NULL, FI_LI);
            return;
         }
         *sptr++ = ' ';
         *sptr++ = ' ';
         ByteCount--;
         if (!(ByteCount % BYTES_PER_GROUP)) *sptr++ = ' ';
      }

      cptr = CurrentDataPtr;
      DataCount = CurrentDataCount;

      ByteCount = BYTES_PER_LINE;
      while (ByteCount && DataCount)
      {
         if (sptr >= zptr)
         {
            ErrorNoticed (NULL, SS$_BUFFEROVF, NULL, FI_LI);
            return;
         }
         if (*cptr >= 32 && *cptr <= 126)
            *sptr++ = *cptr++;
         else
         {
            *sptr++ = '.';
            cptr++;
         }
         DataCount--;
         ByteCount--;
      }
      *sptr++ = '\n';

      if (!DataCount || !ByteCount)
      {
         *sptr = '\0';
         if (ToStdout)
            fputs (DumpBuffer, stdout);
         else
            WatchData (DumpBuffer, sptr - DumpBuffer);
         zptr = (sptr = DumpBuffer) + sizeof(DumpBuffer)-1;
      }
   }

   if (ToStdout) fflush (stdout);

#endif /* WATCH_CAT */
}

/*****************************************************************************/
/*
Return a pointer to a static string containing current server process quotas
compared to what the server originally started with.
*/ 

#if WATCH_CAT

char* WatchServerQuotas ()

{
   static $DESCRIPTOR (QuotasFaoDsc,
"AST:!UL/!UL BIO:!UL/!UL BYT:!UL/!UL DIO:!UL/!UL ENQ:!UL/!UL \
FIL:!UL/!UL PGFL:!UL/!UL PRC:!UL/!UL TQ:!UL/!UL\n\0");
   static char  Buffer [256];

   static int  JpiAstCnt,
               JpiBioCnt,
               JpiBytCnt,
               JpiDioCnt,
               JpiEnqCnt,
               JpiFilCnt,
               JpiPagFilCnt,
               JpiPrcCnt,
               JpiTqCnt;

   static struct {
      ushort  BufferLength;
      ushort  ItemCode;
      ulong  BufferAddress;
      ulong  ReturnLengthAddress;
   }
      JpiItem [] =
   { { sizeof(JpiAstCnt), JPI$_ASTCNT, &JpiAstCnt, 0 },
     { sizeof(JpiBioCnt), JPI$_BIOCNT, &JpiBioCnt, 0 },
     { sizeof(JpiBytCnt), JPI$_BYTCNT, &JpiBytCnt, 0 },
     { sizeof(JpiDioCnt), JPI$_DIOCNT, &JpiDioCnt, 0 },
     { sizeof(JpiEnqCnt), JPI$_ENQCNT, &JpiEnqCnt, 0 },
     { sizeof(JpiFilCnt), JPI$_FILCNT, &JpiFilCnt, 0 },
     { sizeof(JpiPagFilCnt), JPI$_PAGFILCNT, &JpiPagFilCnt, 0 },
     { sizeof(JpiPrcCnt), JPI$_PRCCNT, &JpiPrcCnt, 0 },
     { sizeof(JpiTqCnt), JPI$_TQCNT, &JpiTqCnt, 0 },
     { 0,0,0,0 }
   };

   int  status;
   ulong  *vecptr;
   ulong  FaoVector [32];
   struct dsc$descriptor_s  *faoptr;
   $DESCRIPTOR (BufferDsc, Buffer);
   IO_SB  IOsb;

   /*********/
   /* begin */
   /*********/

   status = sys$getjpiw (EfnWait, 0, 0, &JpiItem, &IOsb, 0, 0);
   if (VMSok (status)) status = IOsb.Status;
   if (VMSnok (status))
   {
      fprintf (stdout, "%%HTTPD-W-NOTICED2, %s:%d sys$getjpiw() %%X%08.08X\n",
               FI_LI, status);
      return ("sys$getjpiw() failed!");
   }

   vecptr = &FaoVector;

   *vecptr++ = JpiAstCnt;
   *vecptr++ = HttpdProcess.AstLm;
   *vecptr++ = JpiBioCnt;
   *vecptr++ = HttpdProcess.BioLm;
   *vecptr++ = JpiBytCnt;
   *vecptr++ = HttpdProcess.BytLm;
   *vecptr++ = JpiDioCnt;
   *vecptr++ = HttpdProcess.DioLm;
   *vecptr++ = JpiEnqCnt;
   *vecptr++ = HttpdProcess.EnqLm;
   *vecptr++ = JpiFilCnt;
   *vecptr++ = HttpdProcess.FilLm;
   *vecptr++ = JpiPagFilCnt;
   *vecptr++ = HttpdProcess.PgFlQuo;
   *vecptr++ = JpiPrcCnt;
   *vecptr++ = HttpdProcess.PrcLm;
   *vecptr++ = JpiTqCnt;
   *vecptr++ = HttpdProcess.TqLm;

   status = sys$faol (&QuotasFaoDsc, NULL, &BufferDsc, &FaoVector);
   if (VMSnok (status) || status == SS$_BUFFEROVF)
      fprintf (stdout, "%%HTTPD-W-NOTICED2, %s:%d sys$faol() %%X%08.08X\n",
               FI_LI, status);

   return (Buffer);
}

#endif /* WATCH_CAT */

/*****************************************************************************/
/*
Return a string corresponding to the function name of the address passed in
'FunctionPtr'.  The '#include watchfunc.h" below provides a static array
containing function address and name details that during module WATCHing can be
used by the FAO.C ('!&F') '!&A' directive to provide function names rather than
just address information.  Returns NULL if the address is unknown.  The
'watchfunc.h' file is generated by the BUILD_WATCHFUNC.COM procedure.
*/ 

char* WatchFunction (void *FunctionPtr)

{
   int  idx;

   /*********/
   /* begin */
   /*********/

   if (!FunctionPtr) return (NULL);
   for (idx = 0; WatchFunc[idx].Address; idx++)
      if (WatchFunc[idx].Address == FunctionPtr) break;
   return (WatchFunc[idx].Name);
}

/*****************************************************************************/
/*
Return a string corresponding to the bit set in the parameter.
*/ 

#if WATCH_CAT

char* WatchWhatCategory (uint number)

{
   /*********/
   /* begin */
   /*********/

   switch (number)
   {
      case WATCH_AUTH             : return ("AUTHORIZE");
      case WATCH_CONNECT          : return ("CONNECT");
      case WATCH_CGI              : return ("CGI");
      case WATCH_DCL              : return ("DCL");
      case WATCH_DECNET           : return ("DECNET");
      case WATCH_ERROR            : return ("ERROR");
      case WATCH_FILTER           : return ("FILTER");
      case WATCH_HTTP2            : return ("HTTP/2");
      case WATCH_INTERNAL         : return ("INTERNAL");
      case WATCH_LOG              : return ("LOG");
      case WATCH_MAPPING          : return ("MAPPING");
      case WATCH_MATCH            : return ("MATCH");
      case WATCH_NETWORK          : return ("NETWORK");
      case WATCH_NETWORK_OCTETS   : return ("NET-OCTETS");
      case WATCH_PROXY            : return ("PROXY");
      case WATCH_PROXY_CACHE      : return ("PRO-CACHE");
      case WATCH_PROXY_REQU_HDR   : return ("PRO-REQ-HEADER");
      case WATCH_PROXY_REQU_BDY   : return ("PRO-REQ-BODY");
      case WATCH_PROXY_RESP_HDR   : return ("PRO-RES-HEADER");
      case WATCH_PROXY_RESP_BDY   : return ("PRO-RES-BODY");
      case WATCH_REQUEST          : return ("REQUEST");
      case WATCH_REQUEST_BODY     : return ("REQ-BODY");
      case WATCH_REQUEST_HEADER   : return ("REQ-HEADER");
      case WATCH_RESPONSE         : return ("RESPONSE");
      case WATCH_RESPONSE_BODY    : return ("RES-BODY");
      case WATCH_RESPONSE_HEADER  : return ("RES-HEADER");
      case WATCH_SCRIPT           : return ("SCRIPT");
      case WATCH_SESOLA           : return ("SSL");
      case WATCH_WEBDAV           : return ("WEBDAV");
   }

   return (NULL);
}

#endif /* WATCH_CAT */

/*****************************************************************************/
/*
Return a string corresponding to the bit set in the parameter.
*/ 

#if WATCH_MOD

char* WatchWhatModule (uint number)

{
   /*********/
   /* begin */
   /*********/

   switch (number)
   {
      case WATCH_MOD_AUTH         : return ("_AUTH..");
      case WATCH_MOD_BODY         : return ("_BODY");
      case WATCH_MOD_CACHE        : return ("_CACHE");
      case WATCH_MOD_CGI          : return ("_CGI");
      case WATCH_MOD_CONFIG       : return ("_CONFIG");
      case WATCH_MOD_DCL          : return ("_DCL");
      case WATCH_MOD_DECNET       : return ("_DECNET");
      case WATCH_MOD_DIR          : return ("_DIR");
      case WATCH_MOD_FAO          : return ("_FAO");
      case WATCH_MOD_FILE         : return ("_FILE");
      case WATCH_MOD_HTADMIN      : return ("_HTADMIN");
      case WATCH_MOD_HTTP2        : return ("_HTTP2..");
      case WATCH_MOD_INSTANCE     : return ("_INSTANCE");
      case WATCH_MOD_MAPURL       : return ("_MAPURL");
      case WATCH_MOD_METACON      : return ("_METACON");
      case WATCH_MOD_MSG          : return ("_MSG");
      case WATCH_MOD_NET          : return ("_NET");
      case WATCH_MOD_REQUEST      : return ("_REQUEST");
      case WATCH_MOD_ODS          : return ("_ODS");
      case WATCH_MOD_PUT          : return ("_PUT");
      case WATCH_MOD_PROXY        : return ("_PROXY..");
      case WATCH_MOD_RESPONSE     : return ("_RESPONSE");
      case WATCH_MOD_SERVICE      : return ("_SERVICE");
      case WATCH_MOD_SESOLA       : return ("_SESOLA..");
      case WATCH_MOD_SSI          : return ("_SSI");
      case WATCH_MOD_THROTTLE     : return ("_THROTTLE");
      case WATCH_MOD_UPD          : return ("_UPD");
      case WATCH_MOD_VM           : return ("_VM");
      case WATCH_MOD_WEBDAV       : return ("_WEBDAV");
      /* special cases (no pun intended) */
      case WATCH_MOD__DETAIL      : return ("_detail");
      case WATCH_MOD__OTHER       : return ("_other");
   }

   return (NULL);
}

#endif /* WATCH_MOD */

/*****************************************************************************/
/*
Parse the /WATCH= qualifier string for command-line startup control. General
format is "/WATCH=[NOSTARTUP,]items[,module][,client][,service][,URI/track]". 
The first mandatory parameter, 'items', may be preceded by an optional
NOSTARTUP keyword.  This suppresses all WATCH output until the server is ready
to accept requests (reducing the some WATCH item output considerably).  The
'items' parameter can be one or two numbers representing the items to be
displayed (these may be found in the WATCH report output) or more conveniently
can be a parenthesized, comma-separated list of item names.  For example,
"/WATCH=ITEM=(MAPPING,REQUEST,RESPONSE)" and/or module names,
"/WATCH=ITEM=(REQUEST,RESPONSE,_AUTH..,_MAPURL,_METACON)".  The item names can
be any found in WatchWhat() immediately above and must be supplied exactly as
the strings appear in the switch() statement above (i.e. note some have
trailing "..").
*/ 

BOOL WatchCliParse (char *String)

{
#if WATCH_CAT

   BOOL  EndItemList,
         Include_Fao,
         Include_Instance,
         Include_Other,
         NoItem;
   ulong  ucnt;
   char  *cptr, *sptr, *zptr;

   /*********/
   /* begin */
   /*********/

   if (strsame (String, "/NOWATCH", 6))
   {
      Watch.Disabled = -1;
      return (true);
   }
   if (Watch.Disabled < 0) return (true);
   Watch.CliEnabled = true;
   Watch.StatusFilter = -1;
   Include_Fao = Include_Instance = Include_Other = false;

   cptr = String;
   while (*cptr && *cptr != '=') cptr++;
   while (*cptr == '=' || *cptr == '\"') cptr++;
   if (!*cptr) return (true);
   if (*cptr == '(') cptr++;

   if (strsame (cptr, "LIST", -1))
   {
      char  CategoryList [WATCH_CATEGORY_LIST_SIZE];
      sptr = CategoryList;
      for (ucnt = 1; ucnt; ucnt = ucnt << 1)
      {
         cptr = WatchWhatCategory (ucnt);
         if (cptr)
         {
            if (sptr > CategoryList) { *sptr++ = ','; *sptr++ = ' '; }
            while (*cptr) *sptr++ = TOLO(*cptr++);
         }
      }
#if WATCH_MOD
      /* then any modules */
      for (ucnt = 1; ucnt; ucnt = ucnt << 1)
      {
         cptr = WatchWhatModule (ucnt);
         if (cptr)
         {
            if (sptr > CategoryList) { *sptr++ = ','; *sptr++ = ' '; }
            while (*cptr) *sptr++ = TOLO(*cptr++);
         }
      }
#endif /* WATCH_MOD */
      *sptr = '\0';
      FaoToStdout ("%HTTPD-I-WATCH, !AZ\n", CategoryList);
      exit (SS$_NORMAL);
   }

   if (strsame (cptr, "NOSTARTUP", 7))
   {
      Watch.CliNoStartup = true;
      while (isalpha(*cptr)) cptr++;
      if (*cptr == ',' || *cptr == '=') cptr++;
   }

   if (strsame (cptr, "ITEM=(", 6) ||
       strsame (cptr, "ITEMS=(", 7))
   {
      cptr += 6;
      if (*cptr == '(') cptr++;
      Watch.Category = Watch.Module = 0;
      EndItemList = false;
      while (*cptr && *cptr != ')' && !EndItemList)
      {
         sptr = cptr;
         while (*cptr && *cptr != ',' && *cptr != ')') cptr++;
         if (*cptr == ')') EndItemList = true;
         if (*cptr) *cptr++ = '\0';
         if (strsame (sptr, "NO", 2) && !strsame (sptr, "NOTICED", -1))
         {
            NoItem = true;
            sptr += 2;
         }
         else
            NoItem = false;
         for (ucnt = 1; ucnt; ucnt = ucnt << 1)
         {
            zptr = WatchWhatCategory (ucnt);
            if (zptr && strsame (sptr, zptr, -1))
            {
               if (NoItem)
                  Watch.Category &= ~ucnt;
               else
                  Watch.Category |= ucnt;
               break;
            }
#if WATCH_MOD
            zptr = WatchWhatModule (ucnt);
            if (zptr && strsame (sptr, zptr, -1))
            {
               if (NoItem)
                  Watch.Module &= ~ucnt;
               else
                  Watch.Module |= ucnt;
               break;
            }
#endif /* WATCH_MOD */
         }
         if (!ucnt)
         {
            if (strsame (sptr, "ALLCAT", -1))
               Watch.Category |= (ucnt = 0x7fffffff);
            else
            if (strsame (sptr, "ALLMOD", -1))
               Watch.Module |= (ucnt = 0x7fffffff);
#if WATCH_MOD
            /* unless specifically included these are always excluded */
            else
            if (strsame (sptr, "_FAO", -1))
               Include_Fao = true;
            else
            if (strsame (sptr, "_INSTANCE", -1))
               Include_Instance = true;
            else
            if (strsame (sptr, "_OTHER", -1))
               Include_Other = true;
#endif /* WATCH_MOD */
         }
         if (!ucnt)
         {
            FaoToStdout ("%HTTPD-E-WATCH, unknown item\n \\!AZ\\\n", sptr);
            return (false);
         }
         if (*cptr == ',') cptr++;
      }
   }
   else
   {
      if (!(Watch.Category = atoi(cptr)))
      {
         FaoToStdout ("%HTTPD-E-WATCH, invalid category number");
         return (false);
      }
      while (*cptr && (*cptr == '-' || isdigit(*cptr))) cptr++;
      if (*cptr == ',') cptr++;
      if (*cptr == '-' || isdigit(*cptr))
      {
         if (!(Watch.Module = atoi(cptr)))
         {
            FaoToStdout ("%HTTPD-E-WATCH, invalid module number");
            return (false);
         }
         while (*cptr && (*cptr == '-' || isdigit(*cptr))) cptr++;
         if (*cptr == ',') cptr++;
      }
   }

   Watch.Category = Watch.Category & ~WATCH_reserved1;
   Watch.Category = Watch.Category & ~WATCH_reserved2;

#if WATCH_MOD
   /* unless specifically included these are always excluded */
   if (!Include_Fao) Watch.Module = Watch.Module & ~WATCH_MOD_FAO;
//   if (!Include_Instance) Watch.Module = Watch.Module & ~WATCH_MOD_INSTANCE;
//   if (!Include_Other) Watch.Module = Watch.Module & ~WATCH_MOD__OTHER;
   Watch.Module |= WATCH_MODULE_FLAG;
#endif /* WATCH_MOD */

   if (*cptr == ')') return (true);
   zptr = (sptr = Watch.ClientFilter) + sizeof(Watch.ClientFilter);
   while (*cptr && *cptr != ',' && *cptr != '\"' && sptr < zptr)
      *sptr++ = *cptr++;
   if (sptr >= zptr)
   {
      FaoToStdout ("%HTTPD-E-WATCH, invalid client filter");
      return (false);
   }
   *sptr = '\0';
   if (*cptr == ',') cptr++;

   if (*cptr == ')') return (true);
   zptr = (sptr = Watch.ServiceFilter) + sizeof(Watch.ServiceFilter);
   while (*cptr && *cptr != ',' && *cptr != '\"' && sptr < zptr)
      *sptr++ = *cptr++;
   if (sptr >= zptr)
   {
      FaoToStdout ("%HTTPD-E-WATCH, invalid service filter");
      return (false);
   }
   *sptr = '\0';
   if (*cptr == ',') cptr++;

   if (*cptr == ')') return (true);
   zptr = (sptr = Watch.PathFilter) + sizeof(Watch.PathFilter);
   while (*cptr && *cptr != ',' && *cptr != '\"' && sptr < zptr)
      *sptr++ = *cptr++;
   if (sptr >= zptr)
   {
      FaoToStdout ("%HTTPD-E-WATCH, invalid URI/track filter");
      return (false);
   }
   *sptr = '\0';

   if (!Watch.ClientFilter[0]) strcpy (Watch.ClientFilter, "*");
   if (!Watch.PathFilter[0]) strcpy (Watch.PathFilter, "*");
   if (!Watch.ServiceFilter[0]) strcpy (Watch.ServiceFilter, "*");

   return (true);

#else /* WATCH_CAT */

   FaoToStdout ("%HTTPD-E-WATCH, is not a compiled option");
   return (false);

#endif /* WATCH_CAT */
}

/*****************************************************************************/
/*
*/ 

void WatchCliSettings (BOOL StartUpComplete)

{
#if WATCH_CAT

   static int  WatchCategory,
               WatchModule;

   ulong  ucnt;
   char  *cptr, *sptr;
   char  CategoryList [WATCH_CATEGORY_LIST_SIZE];

   /*********/
   /* begin */
   /*********/

   if (!StartUpComplete)
   {
      WatchCategory = Watch.Category;
      WatchModule = Watch.Module;
      if (Watch.CliNoStartup) Watch.Category = Watch.Module = 0;
      return;
   }
   Watch.Category = WatchCategory;
   Watch.Module = WatchModule;

   if (Watch.Disabled)
   {
      FaoToStdout ("%HTTPD-I-WATCH, disabled\n");
      return;
   }

   if (!Watch.Category && !Watch.Module) return;

   sptr = CategoryList;
   /* first any categories */
   for (ucnt = 1; ucnt; ucnt = ucnt << 1)
   {
      cptr = WatchWhatCategory (Watch.Category & ucnt);
      if (cptr)
      {
         if (sptr > CategoryList) { *sptr++ = ','; *sptr++ = ' '; }
         while (*cptr) *sptr++ = TOLO(*cptr++);
      }
   }
#if WATCH_MOD
   /* then any modules */
   for (ucnt = 1; ucnt; ucnt = ucnt << 1)
   {
      cptr = WatchWhatModule (Watch.Module & ucnt);
      if (cptr)
      {
         if (sptr > CategoryList) { *sptr++ = ','; *sptr++ = ' '; }
         while (*cptr) *sptr++ = TOLO(*cptr++);
      }
   }
#endif /* WATCH_MOD */
   *sptr = '\0';

   FaoToStdout (
"%HTTPD-I-WATCH, !&?NOSTARTUP \r\r(!SL,!SL) !AZ\n\
-WATCH-I-CLIENT, client filter \"!AZ\"\n\
-WATCH-I-SERVICE, service filter \"!AZ\"\n\
-WATCH-I-PATH, URI/track filter \"!AZ\"\n",
            Watch.CliNoStartup,
            Watch.Category, Watch.Module, CategoryList,
            Watch.ClientFilter,
            Watch.ServiceFilter,
            Watch.PathFilter);

#endif /* WATCH_CAT */
}

/*****************************************************************************/
/*
Generate a report page listing all of the processes belonging to the server
process.
*/

/* seems a lot but I recall some site having a HUGE number of IDs */
#define JPI_PROCESS_RIGHTS_MAX 1024

#define PSCAN$_GETJPI_BUFFER_SIZE 24

WatchProcessReport (REQUEST_STRUCT *rqptr)

{
   static char  BeginPage [] =
"<p><table class=\"lftlft\">\n\
<tr><th></th>\
<th>PID</th>\
<th>User</u></th>\
<th>Process Name</th>\
<th>Image</th>\
<th>Mode</th>\
<th>State</th>\
<th>Priority</th>\
</tr>\n";

   static char  ProcessFao [] =
"<tr!AZ>\
<td><a href=\"!AZ?pid=!8XL&puser=!AZ\">!3ZL</a></td>\
<td>!8XL</td>\
<td>!AZ</td>\
<td>!AZ</td>\
<td>!AZ</td>\
<td>!AZ</td>\
<td>!AZ</td>\
<td>!UL&nbsp;/&nbsp;!UL</td>\
</tr>\n";

   static char  EndPageFao [] =
"</table>\n\
!AZ\
</body>\n\
</html>\n";

   static char  *StateNameArray [] = {
                "1234","COLPG","MWAIT","CEF","PFW","LEF","LEFO",
                "HIB","HIBO","SUSP","SUSPO","FPG","COM","COMO","CUR" };

   static ulong  GetJpiControlFlags = JPI$M_IGNORE_TARGET_STATUS;

   static ulong  JpiMode,
                 JpiPid,
                 JpiPri,
                 JpiPrib,
                 JpiRightsSize,
                 JpiState;
   static char  JpiImagName [256],
                JpiNodeName [32],
                JpiPrcNam [16],
                JpiUserName [13];

   static struct
   {
      ushort  buf_len;
      ushort  item;
      uchar   *buf_addr;
      ushort  *short_ret_len;
   }
      JpiItems [] =
   {
      { sizeof(GetJpiControlFlags), JPI$_GETJPI_CONTROL_FLAGS,
        &GetJpiControlFlags, 0 },
      { sizeof(JpiPid), JPI$_PID, &JpiPid, 0 },
      { sizeof(JpiPri), JPI$_PRI, &JpiPri, 0 },
      { sizeof(JpiPrib), JPI$_PRIB, &JpiPrib, 0 },
      { sizeof(JpiMode), JPI$_MODE, &JpiMode, 0 },
      { sizeof(JpiImagName), JPI$_IMAGNAME, &JpiImagName, 0 },
      { sizeof(JpiPrcNam), JPI$_PRCNAM, &JpiPrcNam, 0 },
      { sizeof(JpiUserName), JPI$_USERNAME, &JpiUserName, 0 },
      { sizeof(JpiState), JPI$_STATE, &JpiState, 0 },
      { sizeof(JpiRightsSize), JPI$_RIGHTS_SIZE, &JpiRightsSize, 0 },
#define JPI_PROCESS_RIGHTS_ITEM 10
      { 0, JPI$_PROCESS_RIGHTS, 0, 0 },
      { 0,0,0,0 }
   },
      ScanItems [] =
   {
      { 0, PSCAN$_GETJPI_BUFFER_SIZE, 2048, 0},
      { 0,0,0,0 }
   };

   int  idx, status,
        IdentCount,
        ProcessCount,
        SetPrvStatus;
   ulong  *vecptr;
   ulong  ProcessContext;
   ulong  FaoVector [32];
   char  *cptr, *sptr;
   ulong  JpiProcessRights [JPI_PROCESS_RIGHTS_MAX*2];
   IO_SB  IOsb;

   /*********/
   /* begin */
   /*********/

   if (WATCH_MODULE(WATCH_MOD__OTHER))
      WatchThis (WATCHALL, WATCH_MOD__OTHER, "WatchProcessReport()");

   JpiItems[JPI_PROCESS_RIGHTS_ITEM].buf_len = sizeof(JpiProcessRights);
   JpiItems[JPI_PROCESS_RIGHTS_ITEM].buf_addr = &JpiProcessRights;

   ProcessContext = 0;
   status = sys$process_scan (&ProcessContext, &ScanItems);
   if (VMSnok (status))
   {
      rqptr->rqResponse.ErrorTextPtr = "sys$process_scan()";
      ErrorVmsStatus (rqptr, status, FI_LI);
      AdminEnd (rqptr);
      return;
   }

   AdminPageTitle (rqptr, "Process Report", BeginPage);

   /* detached scripts (possibly executing as a non-server username) */
   if (DclScriptDetachProcess)
      if (VMSnok (SetPrvStatus = sys$setprv (1, &MailboxMask, 0, 0)))
         ErrorExitVmsStatus (SetPrvStatus, "sys$setprv()", FI_LI);

   ProcessCount = 0;

   for (;;)
   {
      status = sys$getjpiw (EfnWait, &ProcessContext, 0,
                            &JpiItems, &IOsb, 0, 0);
      if (VMSok (status)) status = IOsb.Status;
      if (VMSnok (status)) break;

      JpiPrcNam[15] = '\0';
      for (cptr = JpiPrcNam; *cptr && *cptr != ' '; cptr++);
      *cptr = '\0';

      JpiUserName[12] = '\0';
      for (cptr = JpiUserName; *cptr && *cptr != ' '; cptr++);
      *cptr = '\0';

      if (WATCH_MODULE(WATCH_MOD__OTHER))
         WatchThis (WATCHALL, WATCH_MOD__OTHER, "!8XL !&Z !&Z !UL",
                    JpiPid, JpiUserName, JpiPrcNam, JpiRightsSize);

      if (DclScriptDetachProcess &&
          JpiPid != HttpdProcess.Pid)
      {
         if (JpiRightsSize > sizeof(JpiProcessRights))
         {
            char  Buffer [32];
            sprintf (Buffer, "sys$getjpiw() %08.08X", JpiPid);
            ErrorNoticed (rqptr, SS$_BUFFEROVF, Buffer, FI_LI);
         }

         /* look through each of the identifiers in the list */
         idx = 0;
         for (IdentCount = JpiRightsSize / 8;
              IdentCount && JpiProcessRights[idx] != ProcessRightsIdent[0];
              IdentCount--) idx += 2;

         /* if we didn't find the identifier then continue */
         if (!IdentCount) continue;
      }

      ProcessCount++;

      for (cptr = JpiImagName; *cptr && *cptr != ';'; cptr++);
      if (*cptr == ';') *cptr-- = '\0';
      while (cptr > JpiImagName && *cptr != ']') cptr--;
      if (*cptr == ']') cptr++;

      if (JpiState > 0 && JpiState <= 14)
         sptr = StateNameArray[JpiState];
      else
         sprintf (sptr = StateNameArray[0], "%04.04X", JpiState);

      vecptr = FaoVector;
      if (ProcessCount % 2)
         *vecptr++ = "";
      else
         *vecptr++ = " class=\"hlght\"";
      *vecptr++ = ADMIN_REPORT_SHOW_PROCESS;
      *vecptr++ = JpiPid;
      *vecptr++ = JpiUserName;
      *vecptr++ = ProcessCount;
      *vecptr++ = JpiPid;
      *vecptr++ = JpiUserName;
      *vecptr++ = JpiPrcNam;
      if (*cptr)
         *vecptr++ = cptr;
      else
         *vecptr++ = "[<font size=\"-1\">DCL</font>]";
      switch (JpiMode)
      {
         case JPI$K_BATCH : *vecptr++ = "BAT"; break;
         case JPI$K_INTERACTIVE : *vecptr++ = "INT"; break;
         case JPI$K_NETWORK : *vecptr++ = "NET"; break;
         case JPI$K_OTHER : *vecptr++ = "OTH"; break;
         default : *vecptr++ = "?";
      }
      *vecptr++ = sptr;
      *vecptr++ = JpiPri;
      *vecptr++ = JpiPrib;

      status = FaolToNet (rqptr, ProcessFao, &FaoVector);
      if (VMSnok (status)) ErrorNoticed (rqptr, status, NULL, FI_LI);
   }

   if (DclScriptDetachProcess)
      if (VMSnok (SetPrvStatus = sys$setprv (0, &MailboxMask, 0, 0)))
         ErrorExitVmsStatus (SetPrvStatus, "sys$setprv()", FI_LI);

   if (status != SS$_NOMOREPROC)
   {
      rqptr->rqResponse.ErrorTextPtr = "sys$getjpiw()";
      ErrorVmsStatus (rqptr, status, FI_LI);
   }

   vecptr = FaoVector;
   *vecptr++ = AdminRefresh();

   status = FaolToNet (rqptr, EndPageFao, &FaoVector);
   if (VMSnok (status)) ErrorNoticed (rqptr, status, NULL, FI_LI);

   rqptr->rqResponse.PreExpired = PRE_EXPIRE_ADMIN;
   ResponseHeader200 (rqptr, "text/html", &rqptr->NetWriteBufferDsc);

   AdminEnd (rqptr);
}

/*****************************************************************************/
/*
Using a scripting script process do a SHOW PROCESS /ALL on the specified
process.  Used from the DclReport() but actually could be used on any process
the server has access to, including the server!
*/

void WatchShowProcess
(
REQUEST_STRUCT *rqptr,
char *ProcessIdString,
char *ProcessIdUserName
)
{
   static char  DclCommand [512];
   static ulong  JpiServerPid;
   static $DESCRIPTOR (DclCommandDsc, DclCommand);
   static $DESCRIPTOR (DclCommandFaoDsc,
"SHOW PROCESS /ALL /IDENT=!AZ\n\
SV=$SEVERITY\n\
IF SV THEN MO=F$GETJPI(\"!AZ\",\"MODE\")\n\
JT=\"\"\n\
IF SV THEN IF F$GETJPI(\"!AZ\",\"PID\").NES.F$GETJPI(\"!AZ\",\"MASTER_PID\") \
THEN JT=\" (subprocess)\"\n\
IF SV THEN IF JT.EQS.\"\".AND.F$GETJPI(\"!AZ\",\"JOBTYPE\").EQ.0 \
THEN JT=\" (detached)\"\n\
IF SV THEN IM=F$GETJPI(\"!AZ\",\"IMAGNAME\")\n\
IF SV THEN IF IM.EQS.\"\" THEN IM=\"[DCL]\"\n\
LF[0,8]=10\n\
IF SV THEN WRITE SYS$OUTPUT LF+\"Mode: \"+MO+JT+LF+LF+\"Image: \"+IM\n\
\0");

   static char  BeginPage [] =
"<p><table class=\"ctgry\">\n\
<tr><td>\n\
<table class=\"lftlft\">\n\
<tr><td><pre>";

   int  status;
   ulong  *vecptr;
   ulong  ProcessId;
   ulong  FaoVector [32];
   char  *cptr, *sptr;
   REQUEST_AST EndPageFunction;

   /*********/
   /* begin */
   /*********/

   if (ProcessIdUserName[0])
   {
      if (strsame (ProcessIdUserName, HttpdScriptAsUserName, -1))
         rqptr->rqPathSet.ScriptAsPtr = HttpdScriptAsUserName;
      else
      if (strsame (ProcessIdUserName, HttpdProcess.UserName, -1))
         rqptr->rqPathSet.ScriptAsPtr = HttpdProcess.UserName;
      else
      {
         if (!DclPersonaServicesAvailable)
         {
            rqptr->rqResponse.HttpStatus = 403;
            ErrorGeneral (rqptr, ErrorWatchPersonaNeeded, FI_LI);
            AdminEnd (rqptr);
            return;
         }
         rqptr->rqPathSet.ScriptAsPtr = cptr =
            VmGetHeap (rqptr, strlen(ProcessIdUserName)+1);
         strcpy (cptr, ProcessIdUserName);
      }
   }

   ProcessId = strtol (ProcessIdString, NULL, 16);

   /* suppress the [delete] button for the main server process!! */
   if (ProcessId == HttpdProcess.Pid)
      EndPageFunction = &WatchShowEnd;
   else
      EndPageFunction = &WatchShowProcessDeleteEnd;

   vecptr = FaoVector;
   *vecptr++ = ProcessIdString;
   *vecptr++ = ProcessIdString;
   *vecptr++ = ProcessIdString;
   *vecptr++ = ProcessIdString;
   *vecptr++ = ProcessIdString;
   *vecptr++ = ProcessIdString;

   status = sys$faol (&DclCommandFaoDsc, 0, &DclCommandDsc, &FaoVector);
   if (VMSnok (status) || status == SS$_BUFFEROVF)
   {
      rqptr->rqResponse.ErrorTextPtr = "sys$faol()";
      ErrorVmsStatus (rqptr, status, FI_LI);
      AdminEnd (rqptr);
      return;
   }

   rqptr->rqResponse.PreExpired = PRE_EXPIRE_ADMIN;
   ResponseHeader200 (rqptr, "text/html", NULL);
   AdminPageTitle (rqptr, "Show Process", BeginPage);

   rqptr->rqCgi.BufferRecords = rqptr->NetWriteEscapeHtml = true;

   DclBegin (rqptr, EndPageFunction, DclCommand,
             NULL, NULL, NULL, NULL, NULL, NULL);
}

/*****************************************************************************/
/*
Called when the scripting script process is complete.  Output the last portion
of the report page and AST to wherever was the buffered end-of-report function.
*/

void WatchShowProcessDeleteEnd (REQUEST_STRUCT *rqptr)

{
   static char  EndPageFao [] =
"</pre></td></tr>\n\
</table>\n\
</td></tr>\n\
</table>\n\
<p><form method=\"GET\" action=\"!AZ\">\n\
<input type=\"hidden\" name=\"pid\" value=\"!AZ\">\n\
<input type=\"submit\" value=\" Force Delete \">\n\
</form>\n\
</body>\n\
</html>\n";

   int  status;
   ulong  *vecptr;
   ulong  FaoVector [8];
   char  ProcessIdString [32];

   /*********/
   /* begin */
   /*********/

   rqptr->NetWriteEscapeHtml = false;

   if (!rqptr->rqHeader.QueryStringLength ||
       !strsame (rqptr->rqHeader.QueryStringPtr, "pid=", 4))
   {
      WatchShowEnd (rqptr);
      return;
   }
   strzcpy (ProcessIdString,
            rqptr->rqHeader.QueryStringPtr+4,
            sizeof(ProcessIdString));

   vecptr = FaoVector;
   *vecptr++ = ADMIN_CONTROL_DELETE_PROCESS;
   *vecptr++ = ProcessIdString;

   FaoCheck (sizeof(FaoVector), &FaoVector, vecptr, FI_LI);
   status = FaolToNet (rqptr, EndPageFao, &FaoVector);
   if (VMSnok (status)) ErrorNoticed (rqptr, status, NULL, FI_LI);

   AdminEnd (rqptr);
}

/*****************************************************************************/
/*
Using a scripting script process to display relevant cluster details.
*/

void WatchShowCluster (REQUEST_STRUCT *rqptr)

{
   static $DESCRIPTOR (DclFaoDsc,
"HAR=F$SEARCH(\"CGI-BIN:[000000]HTTPD_ADMIN_REPORT_CLUSTER.COM\")\n\
IF HAR.NES.\"\" THEN @\'HAR\'\n\
SAY=\"WRITE SYS$OUTPUT\"\n\
NL=\"\'\'SAY\' \"\"\"\"\"\n\
H80=\"\'\'SAY\' F$FAO(\"\"!!/!80*-!!/\"\")\"\n\
SYS=\"SHOW SYSTEM/FULL/CLUSTER\"\n\
SYS\n\
H80\n\
SAY F$FAO(\"!!/Server Process(es):!!/!!/\")\n\
SYS/OWNER=!AZ\n\
SAY F$FAO(\"!!/(Default) Scripting Process(es):!!/!!/\")\n\
SYS/OWNER=!AZ\n\
H80\n\
NL\n\
SHOW USER/CLUSTER/INT/NET/BAT/SUB\n\
NL\n\
SHOW USER/CLUSTER/INT/NET/BAT/SUB/FULL/NOHEAD\n\
NL");

   static char  BeginPage [] =
"<p><table class=\"ctgry\">\n\
<tr><td>\n\
<table class=\"lftlft\">\n\
<tr><td><pre>";

   int  status;
   char  DclBuffer [1024];
   $DESCRIPTOR (DclBufferDsc, DclBuffer);

   /*********/
   /* begin */
   /*********/

   rqptr->rqResponse.PreExpired = PRE_EXPIRE_ADMIN;
   ResponseHeader200 (rqptr, "text/html", NULL);
   AdminPageTitle (rqptr, "Cluster Report", BeginPage);

   /* filter-null required, V7.3 (at least) SHOW CPU/FULL contains them!! */
   rqptr->rqCgi.BufferRecords = 
      rqptr->rqCgi.FilterStream =
      rqptr->NetWriteEscapeHtml = true;

   sys$fao (&DclFaoDsc, NULL, &DclBufferDsc,
            HttpdProcess.UserName,
            HttpdScriptAsUserName);

   DclBegin (rqptr, &WatchShowEnd, DclBuffer,
             NULL, NULL, NULL, NULL, NULL, NULL);
}

/*****************************************************************************/
/*
Using a scripting script process to display relevant system details.
*/

void WatchShowSystem (REQUEST_STRUCT *rqptr)

{
   static $DESCRIPTOR (DclFaoDsc,
"HAR=F$SEARCH(\"CGI-BIN:[000000]HTTPD_ADMIN_REPORT_SYSTEM.COM\")\n\
IF HAR.NES.\"\" THEN @\'HAR\'\n\
SAY=\"WRITE SYS$OUTPUT\"\n\
NL=\"\'\'SAY\' \"\"\"\"\"\n\
H80=\"\'\'SAY\' F$FAO(\"\"!!/!!80*-!!/\"\")\"\n\
SYI=F$FAO(\"!!AS, a !!AS with !!UL CPU and !!ULMB running VMS !!AS\",\
F$GETSYI(\"NODENAME\"),F$EDIT(F$GETSYI(\"HW_NAME\"),\"COMPRESS,TRIM\"),\
F$GETSYI(\"AVAILCPU_CNT\"),\
(F$GETSYI(\"MEMSIZE\")*(F$GETSYI(\"PAGE_SIZE\")/512)/2048),\
F$EDIT(F$GETSYI(\"VERSION\"),\"COLLAPSE\"))\n\
HDR=F$FAO(\"  Pid    Process Name    State  Pri      I/O\
       CPU       Page flts  Pages!!/\")\n\
SAY SYI\n\
SAY F$FAO(\"!!#*-!!/!!/!!AS\",F$LENGTH(SYI),HDR)\n\
SYS=\"SHOW SYSTEM/FULL/NOHEAD\"\n\
SYS\n\
H80\n\
SAY F$FAO(\"!!/Server Process(es):!!/!!/\")\n\
SYS/OWNER=!AZ\n\
SAY F$FAO(\"!!/(Default) Scripting Process(es):!!/!!/\")\n\
SYS/OWNER=!AZ\n\
H80\n\
NL\n\
SHOW USER/NODE/INT/NET/BAT/SUB\n\
NL\n\
SHOW USER/NODE/INT/NET/BAT/SUB/FULL/NOHEAD\n\
H80\n\
NL\n\
SHOW MEMORY/FULL\n\
H80\n\
SHOW CPU/FULL\n\
H80\n\
SHOW DEVICE/BRIEF\n\
DEFINE/USER SYS$ERROR NL:\n\
DEFINE/USER SYS$OUTPUT NL:\n\
SHOW ERROR\n\
OK=F$INTEGER(F$EXTRACT(3,7,$STATUS)).EQ.1\n\
IF OK THEN NL\n\
IF OK THEN SHOW ERROR\n\
H80\n\
SHOW NET\n\
SHOW NET/FULL\n");

   static char  BeginPage [] =
"<p><table class=\"ctgry\">\n\
<tr><td>\n\
<table class=\"lftlft\">\n\
<tr><td><pre>";

   int  status;
   ushort  slen;
   char  DclBuffer [2048],
         SystemBuffer [256];
   $DESCRIPTOR (DclBufferDsc, DclBuffer);
   $DESCRIPTOR (SystemBufferDsc, SystemBuffer);

   /*********/
   /* begin */
   /*********/

   rqptr->rqResponse.PreExpired = PRE_EXPIRE_ADMIN;
   ResponseHeader200 (rqptr, "text/html", NULL);
   AdminPageTitle (rqptr, "System Report", BeginPage);

   /* filter-null required, V7.3 (at least) SHOW CPU/FULL contains them!! */
   rqptr->rqCgi.BufferRecords = 
      rqptr->rqCgi.FilterStream =
      rqptr->NetWriteEscapeHtml = true;

   status = sys$fao (&DclFaoDsc, NULL, &DclBufferDsc,
                     HttpdProcess.UserName,
                     HttpdScriptAsUserName);
   if (VMSnok (status)) ErrorNoticed (rqptr, status, NULL, FI_LI);

   DclBegin (rqptr, &WatchShowEnd, DclBuffer,
             NULL, NULL, NULL, NULL, NULL, NULL);
}

/*****************************************************************************/
/*
Called when the scripting script process is complete.  Output the last portion
of the report page and AST to wherever was the buffered end-of-report function.
*/

void WatchShowEnd (REQUEST_STRUCT *rqptr)

{
   static char  EndPageFao [] =
"</pre></td></tr>\n\
</table>\n\
</td></tr>\n\
</table>\n\
</div>\n\
</body>\n\
</html>\n";

   int  status;

   /*********/
   /* begin */
   /*********/

   rqptr->NetWriteEscapeHtml = false;

   if (rqptr->rqResponse.HttpStatus != 200) sysPlusReport (rqptr);

   status = FaolToNet (rqptr, EndPageFao, NULL);
   if (VMSnok (status)) ErrorNoticed (rqptr, status, NULL, FI_LI);

   AdminEnd (rqptr);
}

/*****************************************************************************/
/*
Just delete the process specified by 'ProcessIdString'.
*/

void WatchDeleteProcess (REQUEST_STRUCT *rqptr)

{
   int  status,
        SetPrvStatus;
   ulong  ProcessId;

   /*********/
   /* begin */
   /*********/

   if (rqptr->rqHeader.QueryStringLength &&
       strsame (rqptr->rqHeader.QueryStringPtr, "pid=", 4))
      ProcessId = strtol (rqptr->rqHeader.QueryStringPtr+4, NULL, 16);
   else
      ProcessId  = 0;

   if (ProcessId)
   {
      if (DclScriptDetachProcess)
      {
         /* detached scripts, possibly executing as a non-server username */
         if (VMSnok (SetPrvStatus = sys$setprv (1, &WorldMask, 0, 0)))
            ErrorExitVmsStatus (SetPrvStatus, "sys$setprv()", FI_LI);
         status = sys$delprc (&ProcessId, 0);
         if (VMSnok (SetPrvStatus = sys$setprv (0, &WorldMask, 0, 0)))
            ErrorExitVmsStatus (SetPrvStatus, "sys$setprv()", FI_LI);
      }
      else
         status = sys$delprc (&ProcessId, 0);
   }
   else
      status = SS$_BUGCHECK;

   if (VMSnok (status))
   {
      rqptr->rqResponse.HttpStatus = 409;
      rqptr->rqResponse.ErrorTextPtr = "when deleting";
      ErrorVmsStatus (rqptr, status, FI_LI);
      AdminEnd (rqptr);
      return;
   }

   rqptr->rqResponse.PreExpired = PRE_EXPIRE_ADMIN;
   ReportSuccess (rqptr, "Server !AZ deleted process !8XL.",
                  ServerHostPort, ProcessId);

   AdminEnd (rqptr);
}

/*****************************************************************************/
/*
This is a development tool.

OpenVMS System Services Reference Manual (V8.4): $RPCC_64:

"On Alpha and I64 systems, returns a 64-bit long version of the current process
cycle counter.  On Alpha systems, this service must be called at least once
within each wrap period of the least significant 32 bits of the counter.  For
more information, see the RPCC() C-language built-in documentation and the RPCC
instruction in the Alpha Architecture Handbook."

The Alpha Architecture Book (1992):

"The low-order 32 bits of the process cycle counter is an unsigned 32-bit
integer that increments once per N CPU cycles, where N is an implementation-
specific integer in the range 1..16.  The cycle counter frequency is the number
of times the process cycle counter gets incremented per second, rounded to a
64-bit integer.  The integer count wraps to 0 from a count of FFFF FFFF16?  The
counter wraps no more frequently than 1.5 times the implementation's interval
clock interrupt period (which is two thirds of the interval clock interrupt
frequency).  The high-order 32 bits of the process cycle counter are an offset
that when added to the low-order 32 bits gives the cycle count for this
process.  The process cycle counter is suitable for timing intervals on the
order of nanoseconds and may be used for detailed performance characterization.
It is required on all implementations.  PCC is required for every processor,
and each processor in a multiprocessor system has its own private, independent
PCC."

Calls to this function need to be embedded into code between points measuring
CPU clock counts.  Up to eight such measurements may concurrently be performed. 
The |index| parameter is used to specify 1..8.  This calculates a delta with
the previous value (from reset or previous call), reports that and the
percentage of total counts.  The same |index| value but negative resets that
count and reports the same.  If |index| is zero all elements are reinitialised
to the current CPU count.

Not quite convinced this is as useful as originally hoped for but as it was a
bit of a tease to get working, and does not bloat code in a production
environment, will leave in place for possible future use.
*/

#if WATCH_MOD

#ifndef __VAX

unsigned __int64 WatchRPCC
(
NETIO_STRUCT *ioptr,
int index,
char *module,
int line
)
{
#define INDEX_MAX 8

   static int  watching;
   static unsigned __int64  ctx64, init64;
   static unsigned __int64  delta64 [INDEX_MAX+1],
                            prev64 [INDEX_MAX+1];

   int  bsize, cnt, idx;
   ushort  slen;
   unsigned __int64  drpcc64, rpcc64;
   double  fpercent;
   char  *bptr;
   char  buf [256],
         pbuf [32];

   /*********/
   /* begin */
   /*********/

   /* apparently the context is unnecessary but innocuous from Alpha V8.4 */
   rpcc64 = sys$rpcc_64 (&ctx64);

   if (index == 0 || !init64)
   {
      /* initialise */
      init64 = rpcc64;
      for (idx = 0; idx < INDEX_MAX+1; idx++) prev64[idx] = rpcc64;
      /* enable RPCC WATCHing is logical name exists */
      bptr = SysTrnLnm ("WASD_WATCH_RPCC");
      watching = 0;
      if (bptr) watching = atoi(bptr);
      if (index == 0) return (0);
   }

   if (index > INDEX_MAX || -index > INDEX_MAX)
      ErrorExitVmsStatus (SS$_BUGCHECK, ErrorSanityCheck, FI_LI);

   /* then reset this array element to the current count */
   if (index < 0) prev64[-index] = rpcc64;

   if (watching)
   {
      cnt = 0;
      drpcc64 = rpcc64 - init64;
      for (idx = 0; idx < INDEX_MAX+1; idx++)
      {
         if (prev64[idx] == init64)
            delta64[idx] = 0;
         else
         {
            delta64[idx] = rpcc64 - prev64[idx];
            cnt++;
         }
      }
      bptr = buf;
      bsize = sizeof(buf)-2;
      FaoToBuffer (bptr, bsize, &slen, "RPCC !SL !&,@SQ", index, &drpcc64);
      bptr += slen;
      bsize -= slen;
      for (idx = 0; idx < cnt; idx++)
      {
         if (idx > 0)
            fpercent = ((double)delta64[idx] * 100.0) / (double)delta64[0];
         else
            fpercent = ((double)delta64[0] * 100.0) / (double)drpcc64;
         sprintf (pbuf, "(%.1f%%)", fpercent);
         FaoToBuffer (bptr, bsize, &slen, " [!UL]!&,@SQ!AZ",
                      idx, &delta64[idx], pbuf);
         bptr += slen;
         bsize -= slen;
      }

      if (ioptr)
         if (WATCHING (ioptr, WATCH_REQUEST))
            WatchThis (ioptr->WatchItem, module, line, WATCH_REQUEST,
                       "!AZ", buf);

      if (watching > 0)
         FaoToStdout ("|!%T !8AZ !4ZL|!AZ\n", 0, module, line, buf);
   }

   prev64[index] = prev64[0] = rpcc64;

   return (rpcc64);
}

#else /* __VAX */

ulong WatchRPCC
(
NETIO_STRUCT *ioptr,
int index,
char *module,
int line
)
{
   return (0);
}

#endif /* __VAX */

#endif /* WATCH_MOD */

/*****************************************************************************/
/*
Called from WatchBegin().  Provide a plain-text dump displaying some of the
essential fields from various data structures in an executing request. 
Intended as a diagnosis and development tool.  If 'rqptr' is NULL then the
information is written to SYS$OUTPUT (and in this case leaks a little memory).
*/

void WatchPeek
(
REQUEST_STRUCT *rqptr,
REQUEST_STRUCT *rqeptr
)
{
#define WATCH_NULL_STRING "(null)"
#define WATCH_NULL(string) (!string ? WATCH_NULL_STRING : string)

   static char  VmZoneFao [] =
"|\n\
!33<HttpdTickSecond!> !UL\n\
!33<ConnectNumber!> !UL\n\
!33<VmHeapZoneId!> !8XL\n\
\n";

   static char  ServiceFao [] =
"|\n\
!33<ServicePtr!> !&X\n\
!33<->ServerChannel!> !UL (!AZ)\n\
!33<->ServerHostPort!> !&Z\n\
!33<->ServerIpAddressString!> !&Z\n\
!33<->RequestSchemeNamePtr!> !&Z\n\
!33<->ProxyTunnel!> !UL\n\
!33<->RawSocket!> !UL\n\
!33<->SSLserverPtr!> !&X\n\
!33<->SSLclientPtr!> !&X\n\
|\n\
!33<RequestState!> !UL !AZ\n\
!33<NotePadPtr!> !&Z\n\
!33<ProxyReverseLocationPtr!> !&Z\n\
|\n\
!33<Http2Stream.Depend!> !UL\n\
!33<Http2Stream.Http2Ptr!> !&X\n\
!33<Http2Stream.RequestPtr!> !&X\n\
!33<Http2Stream.ContinPtr!> !&X\n\
!33<Http2Stream.ContinSize!> !UL\n\
!33<Http2Stream.FlowControl!> !UL\n\
!33<Http2Stream.HeaderSent!> !&B\n\
!33<Http2Stream.Ident!> !UL\n\
!33<Http2Stream.Priority!> !UL\n\
!33<Http2Stream.DataReadPtr!> !&X\n\
!33<Http2Stream.DataReadSize!> !UL\n\
!33<Http2Stream.DataReadLength!> !UL\n\
!33<Http2Stream.ReadWindowSize!> !UL\n\
!33<Http2Stream.RequestEnd!> !&B\n\
!33<Http2Stream.State!> !UL\n\
!33<Http2Stream.Weight!> !UL\n\
!33<Http2Stream.WriteWindowSize!> !UL\n\
!33<Http2Stream.QueuedWriteCount!> !UL\n\
|\n\
!33<rqNet.ReadErrorCount!> !UL\n\
!33<rqNet.ReadErrorStatus!> !&S\n\
!33<rqNet.WriteErrorCount!> !UL\n\
!33<rqNet.WriteErrorStatus!> !&S\n\
!33<rqNet.GzipDataLength!> !UL\n\
!33<rqNet.GzipAstFunction!> !&A\n\
!33<rqNet.PipelineBufferPtr!> !&X\n\
!33<rqNet.PipelineBufferCount!> !UL\n\
!33<rqNet.PipelineBufferSize!> !UL\n\
!33<rqNet.PipelineRequestCount!> !UL\n\
!33<rqNet.PersistentCount!> !UL\n";

   static char  TimerFao [] =
"|\n\
!33<BytesRx!> !@SQ\n\
!33<BytesTx!> !@SQ\n\
!33<BytesRawRx!> !@SQ\n\
!33<BytesRawTx!> !@SQ\n\
!33<PersistentRequest!> !&B\n\
!33<PersistentResponse!> !&B\n\
!33<rqTmr.InputSecond!> !UL\n\
!33<rqTmr.PersistentSecond!> !UL\n\
!33<rqTmr.ListIndex!> !UL!&@\n\
!33<rqTmr.NoProgressBytesTx!> !UL\n\
!33<rqTmr.NoProgressSecond!> !UL\n\
!33<rqTmr.NoProgressPeriod!> !UL\n\
!33<rqTmr.OutputSecond!> !UL\n\
!33<rqTmr.TimeoutCount!> !UL !AZ\n\
!33<rqTmr.ThrottleSecond!> !UL\n\
!33<rqPathSet.ThrottleSet!> !&B\n\
!33<rqPathSet.ThrottleFrom!> !UL/!UL!AZ\n\
!33<rqPathSet.ThrottleTo!> !UL\n\
!33<rqPathSet.ThrottleResume!> !UL\n\
!33<rqPathSet.ThrottleBusy!> !UL\n\
!33<rqPathSet.ThrottleIndex!> !UL!&@\n\
!33<throttlePerUser!> !&B\n\
|\n\
!33<rqTime.BeginTime64!> !%D (!AZ ago)\n\
!33<rqTime.GmDateTime!> !&Z\n";

   static char  HeaderFao [] =
"!33<rqHeader.RequestHeaderPtr!> {!UL}|!-!#AZ|\n\
!33<rqHeader.RequestBodyPtr!> {!UL}|!-!#AZ|\n\
!33<rqHeader.MethodName!> !&Z\n\
!33<rqHeader.RequestUriPtr!> {!UL}!&P\n\
!33<rqHeader.HttpVersion!> !UL.!UL\n\
!33<rqHeader.AcceptPtr!> !&Z\n\
!33<rqHeader.AcceptCharsetPtr!> !&Z\n\
!33<rqHeader.AcceptEncodingPtr!> !&Z\n\
!33<rqHeader.AcceptLangPtr!> !&Z\n\
!33<rqHeader.AuthorizationPtr!> !&Z\n\
!33<rqHeader.CacheControl!> no-cache:!&B no-store:!&B max-age=0:!&B\n\
!33<rqHeader.ContentLength!> !UL\n\
!33<rqHeader.ContentTypePtr!> !&Z\n\
!33<rqHeader.CookiePtr!> !&Z\n\
!33<rqHeader.ForwardedPtr!> !&Z\n\
!33<rqHeader.HostPtr!> !&Z\n\
!33<rqHeader.IfMatchPtr!> !&Z\n\
!33<rqHeader.IfNoneMatchPtr!> !&Z\n\
!33<rqHeader.OriginPtr!> !&Z\n\
!33<rqHeader.ProxyAuthorizationPtr!> !&Z\n\
!33<rqHeader.RefererPtr!> !&Z\n\
!33<rqHeader.UserAgentPtr!> !&Z\n\
!33<rqHeader.XForwardedForPtr!> !&Z\n";

   static char  BodyFao [] =
"!33<rqBody.UnEncodeStream!> !&B\n\
!33<rqBody.ChunkState!> !UL\n\
!33<rqBody.ChunkCount!> !UL\n\
!33<rqBody.ChunkSize!> !UL\n\
!33<rqBody.ChunkSizeString!> !&Z\n\
!33<rqBody.ChunkedTrailerBufferCount!> !UL\n\
!33<rqBody.ChunkedTrailerBufferSize!> !UL\n\
!33<rqBody.ChunkedTrailerBufferPtr!> !&X\n\
!33<rqBody.ChunkedTrailerNewLineCount!> !UL\n\
!33<rqBody.ContentLength!> !UL\n\
!33<rqBody.ContentCount!> !UL\n\
!33<rqBody.DataVBN!> !UL\n\
!33<rqBody.DataPtr!> 0x!XL\n\
!33<rqBody.DataCount!> !UL\n\
!33<rqBody.DataSize!> !UL\n\
!33<rqBody.DataStatus!> !&S\n\
!33<rqBody.DiscardReadCount!> !UL\n\
!33<rqBody.AstFunction!> !&A\n\
!33<rqBody.ProcessFunction!> !&A\n\
!33<rqBody.ProcessPtr!> !&X\n\
|\n";

   static char  PathInfoFao [] =
"!33<rqHeader.PathInfoPtr!> !&Z\n\
!33<rqHeader.QueryStringPtr!> !&Z\n\
!33<Md5HashPath!> |!16&H|\n\
!33<MappedPathPtr!> !&Z\n\
!33<RequestMappedFile!> !&Z\n\
!33<ParseOds.ExpFileName!> !&Z\n\
!33<ScriptName!> !&Z\n\
!33<RequestMappedScript!> !&Z\n\
!33<RequestMappedRunTime!> !&Z\n\
!33<IsCgiPlusScript!> !&B\n\
!33<rqPathSet.PathOds!> !UL !AZ\n\
!33<PathOds!> !UL !AZ\n\
!33<PathOdsExtended!> !&B\n\
|\n\
!33<rqResponse.HeaderGenerated!> !&B\n\
!33<rqResponse.HeaderSent!> !&B\n\
!33<rqResponse.ErrorReportPtr!> !&Z\n\
!33<rqResponse.LocationPtr!> !&Z\n\
!33<rqResponse.ContentEncodeAsGzip!> !&B\n\
!33<rqResponse.ContentIsEncodedGzip!> !&B\n\
!33<rqResponse.ChunkedBufferPtr!> !&X\n\
!33<rqResponse.ChunkedBufferSize!> !UL\n\
!33<rqResponse.TransferEncodingChunke!> !&B\n\
|\n\
!33<rqWebSocket.ScriptProcessPid!> !8XL\n\
!33<rqWebSocket.InputSize!> !UL\n\
!33<rqWebSocket.InputChannel!> !UL (!AZ)\n\
!33<rqWebSocket.InputIOsb!> !&S !UL\n\
!33<rqWebSocket.QueuedInput!> !UL\n\
!33<rqWebSocket.QueuedNetRead!> !UL\n\
!33<rqWebSocket.OutputSize!> !UL\n\
!33<rqWebSocket.OutputChannel!> !UL (!AZ)\n\
!33<rqWebSocket.OutputIOsb!> !&S !UL\n\
!33<rqWebSocket.QueuedOutput!> !UL\n\
!33<rqWebSocket.QueuedNetWrite!> !UL\n\
|\n\
!33<RemoteUser!> !&Z\n\
!33<RemoteUserPassword!> |!#**|\n\
!33<ResolvedRemoteUser!> !&B\n\
!33<rqAuth.FinalStatus!> !&S\n\
!33<rqAuth.RequestCan!> 0x!4XL (!AZ)\n\
!33<rqAuth.UserCan!> 0x!4XL (!AZ)\n\
!33<rqAuth.GroupCan!> 0x!4XL (!AZ)\n\
!33<rqAuth.WorldCan!> 0x!4XL (!AZ)\n\
!33<rqAuth.Type!> !&Z\n\
!33<rqAuth.UserDetailsPtr!> !&Z\n\
!33<rqAuth.HttpsOnly!> !&B\n\
!33<rqAuth.SkelKeyAuthenticated!> !&B\n\
!33<rqAuth.SysUafAuthenticated!> !&B\n\
!33<rqAuth.VmsIdentifiersCount!> !UL\n\
!33<rqAuth.VmsIdentifiersPtr!> 0x!XL\n\
!33<rqAuth.VmsUserProfile!> !&B\n\
!33<rqAuth.VmsUserProfileLength!> !UL\n\
!33<rqAuth.VmsUserProfilePtr!> 0x!XL\n\
!33<rqAuth.VmsUserScriptAs!> !&B\n\
!33<rqAuth.DirectoryPtr!> !&Z\n\
!33<rqAuth.RealmPtr!> !&Z (!AZ)\n\
!33<rqAuth.RealmDescrPtr!> !&Z\n\
!33<rqAuth.PathParameterPtr!> !&Z\n\
!33<rqAuth.GroupWritePtr!> !&Z (!AZ)\n\
!33<rqAuth.GroupReadPtr!> !&Z (!AZ)\n\
!33<rqAuth.GroupRestrictListPtr!> !&Z\n\
!33<rqAuth.WorldRestrictListPtr!> !&Z\n\
!33<rqAuth.ProxyStringPtr!> !&Z\n\
!33<rqAuth.RemoteUser!> !&Z\n\
|\n\
!33<rqCgi.BufferLength!> !UL\n\
!33<rqCgi.BufferRemaining!> !UL\n\
!33<rqCgi.BufferPtr!> 0x!XL\n\
!33<rqCgi.BufferCurrentPtr!> 0x!XL\n\
!33<rqCgi.CalloutInProgress!> !&B\n\
!33<rqCgi.CalloutOutputCount!> !UL\n\
!33<rqCgi.CalloutOutputPtr!> 0x!XL !&Z\n\
!33<rqCgi.ContentEncodingGzip!> !UL\n\
!33<rqCgi.ContentTypeText!> !&B\n\
!33<rqCgi.EofStr!> !&Z\n\
!33<rqCgi.EotStr!> !&Z\n\
!33<rqCgi.EscStr!> !&Z\n\
!33<rqCgi.Header100Continue!> !&B\n\
!33<rqCgi.Header100ContinueDone!> !&B\n\
!33<rqCgi.HeaderLineCount!> !UL\n\
!33<rqCgi.IsCliDcl!> !&B\n\
!33<rqCgi.OutputMode!> !UL (!AZ)\n\
!33<rqCgi.ProcessingBody!> !&B\n\
!33<rqCgi.RecordCount!> !UL\n\
!33<rqCgi.ScriptRetryCount!> !UL\n\
!33<rqCgi.TransferEncoding!> !&B\n\
!33<rqCgi.TransferEncodingChunked!> !UL\n\
!33<rqCgi.XVMSRecordMode!> !&B\n\
";

   static char  CacheFao [] =
"|\n\
!33<rqCache.EntryPtr!> 0x!XL\n\
|\n\
!33<DclTaskPtr->!> 0x!XL\n";

   static char  DECnetFao [] = "!33<DECnetTaskPtr!> !&X\n";

   static char  DECnetTaskFao [] =
"!33<DECnetChannel!> !UL\n\
!33<DECnetConnectIOsb!> !&S !UL\n\
!33<DECnetReadIOsb!> !&S !UL\n\
!33<DECnetWriteIOsb!> !&S !UL\n\
!33<QueuedDECnetIO!> !UL\n\
!33<ScriptResponded!> !&B\n\
!33<BuildRecords!> !&B\n\
!33<BuildCount!> !UL\n\
!33<CgiDialogState!> !UL\n\
!33<OsuDialogState!> !UL\n\
!33<OsuDnetCgi!> !&B\n\
|\n";

   static char  DescrFao [] =
"!33<DescrTaskPtr!> !&X\n\
!33<DirTaskPtr!> !&X\n\
!33<FileTaskPtr!> !&X\n\
!33<HTAdminTaskPtr!> !&X\n\
|\n\
!33<ProxyTaskPtr!> !&X\n";

   static char  ProxyTaskFao [] =
"!33<NetIoPtr->Channel!> !UL (!AZ)\n\
!33<NetIoPtr->QioMaxSeg!> !UL\n\
!33<NetIoPtr->ReadIOsb!> !&S !UL\n\
!33<NetIoPtr->ReadStatus!> !&S\n\
!33<NetIoPtr->ReadCount!> !UL\n\
!33<NetIoPtr->ReadAstFunction!> !&A\n\
!33<NetIoPtr->ReadPtr!> !&X\n\
!33<NetIoPtr->ReadSize!> !UL\n\
!33<NetIoPtr->WriteIOsb!> !&S !UL\n\
!33<NetIoPtr->WriteStatus!> !&S\n\
!33<NetIoPtr->WriteCount!> !UL\n\
!33<NetIoPtr->WriteAstFunction!> !&A\n\
!33<NetIoPtr->WritePtr!> !&X\n\
!33<NetIoPtr->WriteLength!> !UL\n\
!33<NetIoPtr->BytesRawRx!> !@SQ\n\
!33<NetIoPtr->BytesRawTx!> !@SQ\n\
!33<ConnectIpAddress!> !&I\n\
!33<RequestHostIpAddress!> !&I\n\
!33<RequestHostPort!> !&Z\n\
!33<RequestSchemeName!> !&Z\n\
!33<ProxyTunnel!> !UL\n\
!33<ProxyLookupRetryCount!> !UL\n\
!33<ProxyConnectIOsb!> !&S !UL\n\
!33<VerifyRecordPtr!> !&Z\n\
!33<RebuiltRequestLength!> !UL\n\
!33<RebuiltRequestPtr!> !&Z\n\
!33<ResponseBodyLength!> !UL\n\
!33<ResponseBufferNetCount!> !UL\n\
!33<ResponseBufferNetPtr!> !&X\n\
!33<ResponseCacheControlMaxAge!> !UL\n\
!33<ResponseCacheControlMaxAgeZero!> !&B\n\
!33<ResponseCacheControlMustReval!> !&B\n\
!33<ResponseCacheControlNoCache!> !&B\n\
!33<ResponseCacheControlNoStore!> !&B\n\
!33<ResponseCacheControlNoTransform!> !&B\n\
!33<ResponseCacheControlPrivate!> !&B\n\
!33<ResponseCacheControlProxyReval!> !&B\n\
!33<ResponseCacheControlPublic!> !&B\n\
!33<ResponseCacheControlSMaxAge!> !UL\n\
!33<ResponseChunkedCount!> !UL\n\
!33<ResponseChunkedEnd!> !&B\n\
!33<ResponseChunkedEol!> !&B\n\
!33<ResponseChunkedEot!> !&B\n\
!33<ResponseChunkedInit!> !&B\n\
!33<ResponseChunkedSize!> !UL\n\
!33<ResponseChunkedString!> !&Z\n\
!33<ResponseChunkedNewlineCount!> !UL\n\
!33<ResponseConsecutiveNewLineCount!> !UL\n\
!33<ResponseContentEncodingGzip!> !&B\n\
!33<ResponseContentEncodingUnknown!> !&B\n\
!33<ResponseContentLength!> !SL\n\
!33<ResponseExpires!> !&Z (!%D)\n\
!33<ResponseHeaderLength!> !UL\n\
!33<ResponseHeaderPtr!> |!#AZ|\n\
!33<ResponseHeaderSent!> !&B\n\
!33<ResponseLastModified!> !&Z (!%D)\n\
!33<ResponseTransferEncodingChunked!> !&B\n\
!33<ResponseUpgradeHttp2onTLS!> !&B\n\
!33<ResponseUpgradeHttp2toTLS!> !&B\n\
!33<ResponseUpgradeWebSocket!> !&B\n\
!33<RebuiltResponseLength!> !UL\n\
!33<RebuiltResponsePtr!> !&Z\n\
!33<CannotCache!> !&B\n\
!33<ProxyCacheFileName!> !&Z\n\
!33<ProxyCacheSuitable!> !&B\n\
!33<ProxyCacheFileSizeInBytes!> !UL\n\
!33<ProxyCacheLastModifiedHours!> !UL\n\
!33<ProxyCacheReadBytes!> !UL\n\
!33<ProxyCacheFileCdt!> !%D\n";

   static char  PutFao [] =
"!33<PutTaskPtr!> !&X\n\
!33<SsiTaskPtr!> !&X\n\
!33<UpdTaskPtr!> !&X\n\
|\n";

   int  status;
   ushort  Length;
   ulong  Remainder,
          Seconds,
          SubSeconds;
   ulong  BinaryTime [2],
          FaoVector [128],
          ResponseDuration [2],
          ResultTime [2];
   ulong  *vecptr;
   char  *cptr;
   char  Buffer [8192],
         ProxyDevName [64],
         ServerDevName [64];
   MAP_RULE_META  *mrptr;

   /*********/
   /* begin */
   /*********/

   WatchNone (true);

   NetGetBgDevice (rqeptr->ServicePtr->ServerChannel,
                   ServerDevName, sizeof(ServerDevName));

   sys$gettim (&BinaryTime);
   status = lib$sub_times (&BinaryTime, &rqeptr->rqTime.BeginTime64,
                           &ResponseDuration);
   if (VMSnok (status)) PUT_ZERO_QUAD (ResponseDuration);

   vecptr = FaoVector;

   *vecptr++ = HttpdTickSecond;
   *vecptr++ = rqeptr->ConnectNumber;
   *vecptr++ = rqeptr->VmHeapZoneId;

   status = FaolToBuffer (Buffer, sizeof(Buffer), &Length,
                          VmZoneFao, &FaoVector);
   if (VMSnok (status) || status == SS$_BUFFEROVF)
      ErrorNoticed (rqptr, status, NULL, FI_LI);

   WatchWrite (Buffer, Length);

   WatchVmZone (rqptr, rqeptr->VmHeapZoneId);

   vecptr = FaoVector;

   *vecptr++ = rqeptr->ServicePtr;
   *vecptr++ = rqeptr->ServicePtr->ServerChannel;
   *vecptr++ = ServerDevName+1;
   *vecptr++ = rqeptr->ServicePtr->ServerHostPort;
   *vecptr++ = rqeptr->ServicePtr->ServerIpAddressString;
   *vecptr++ = rqeptr->ServicePtr->RequestSchemeNamePtr;
   *vecptr++ = rqeptr->ServicePtr->ProxyTunnel;
   *vecptr++ = rqeptr->ServicePtr->RawSocket;
   *vecptr++ = rqeptr->ServicePtr->SSLserverPtr;
   *vecptr++ = rqeptr->ServicePtr->SSLclientPtr;

   *vecptr++ = rqeptr->RequestState;
   *vecptr++ = RequestState (rqeptr->RequestState);
   *vecptr++ = rqeptr->NotePadPtr;
   *vecptr++ = rqeptr->ProxyReverseLocationPtr;

   *vecptr++ = rqeptr->Http2Stream.Depend;
   *vecptr++ = rqeptr->Http2Stream.Http2Ptr;
   *vecptr++ = rqeptr->Http2Stream.RequestPtr;
   *vecptr++ = rqeptr->Http2Stream.ContinPtr;
   *vecptr++ = rqeptr->Http2Stream.ContinSize;
   *vecptr++ = rqeptr->Http2Stream.FlowControl;
   *vecptr++ = rqeptr->Http2Stream.HeaderSent;
   *vecptr++ = rqeptr->Http2Stream.Ident;
   *vecptr++ = rqeptr->Http2Stream.Priority;
   *vecptr++ = rqeptr->Http2Stream.DataReadPtr;
   *vecptr++ = rqeptr->Http2Stream.DataReadSize;
   *vecptr++ = rqeptr->Http2Stream.DataReadLength;
   *vecptr++ = rqeptr->Http2Stream.ReadWindowSize;
   *vecptr++ = rqeptr->Http2Stream.RequestEnd;
   *vecptr++ = rqeptr->Http2Stream.State;
   *vecptr++ = rqeptr->Http2Stream.Weight;
   *vecptr++ = rqeptr->Http2Stream.WriteWindowSize;
   *vecptr++ = rqeptr->Http2Stream.QueuedWriteCount;

   *vecptr++ = rqeptr->rqNet.ReadErrorCount;
   *vecptr++ = rqeptr->rqNet.ReadErrorStatus;
   *vecptr++ = rqeptr->rqNet.WriteErrorCount;
   *vecptr++ = rqeptr->rqNet.WriteErrorStatus;
   *vecptr++ = rqeptr->rqNet.GzipDataLength;
   *vecptr++ = rqeptr->rqNet.GzipAstFunction;
   *vecptr++ = rqeptr->rqNet.PipelineBufferPtr;
   *vecptr++ = rqeptr->rqNet.PipelineBufferCount;
   *vecptr++ = rqeptr->rqNet.PipelineBufferSize;
   *vecptr++ = rqeptr->rqNet.PipelineRequestCount;
   *vecptr++ = rqeptr->rqNet.PersistentCount;

   FaoCheck (sizeof(FaoVector), &FaoVector, vecptr, FI_LI);
   status = FaolToBuffer (Buffer, sizeof(Buffer), &Length,
                          ServiceFao, &FaoVector);
   if (VMSnok (status) || status == SS$_BUFFEROVF)
      ErrorNoticed (rqptr, status, NULL, FI_LI);

   WatchWrite (Buffer, Length);

   WatchPeekNetIo (rqptr, rqeptr->NetIoPtr,  "rqNet.NetIoPtr->");

   if (rqeptr->Http2Stream.Http2Ptr)
      WatchPeekHttp2 (rqptr, rqeptr->Http2Stream.Http2Ptr,
                      "|\nHttp2Stream.Http2Ptr->"); 

   vecptr = FaoVector;

   *vecptr++ = &rqeptr->BytesRx;
   *vecptr++ = &rqeptr->BytesTx;
   *vecptr++ = &rqeptr->NetIoPtr->BytesRawRx;
   *vecptr++ = &rqeptr->NetIoPtr->BytesRawTx;
   *vecptr++ = rqeptr->PersistentRequest;
   *vecptr++ = rqeptr->PersistentResponse;
   *vecptr++ = rqeptr->rqTmr.InputSecond;
   *vecptr++ = rqeptr->rqTmr.PersistentSecond;
   *vecptr++ = rqeptr->rqTmr.ListIndex;
   if (rqeptr->rqTmr.ListIndex)
   {
      *vecptr++ = " (!UL seconds)";
      *vecptr++ = SupervisorListArray[rqeptr->rqTmr.ListIndex].ChunkSeconds;
   }
   else
      *vecptr++ = "";
   *vecptr++ = rqeptr->rqTmr.NoProgressBytesTx;
   *vecptr++ = rqeptr->rqTmr.NoProgressSecond;
   *vecptr++ = rqeptr->rqTmr.NoProgressPeriod;
   *vecptr++ = rqeptr->rqTmr.OutputSecond;
   *vecptr++ = rqeptr->rqTmr.TimeoutCount;
   *vecptr++ = HttpdTimeoutType(rqeptr->rqTmr.TimeoutType);
   *vecptr++ = rqeptr->rqTmr.ThrottleSecond;

   *vecptr++ = rqeptr->rqPathSet.ThrottleSet;
   *vecptr++ = rqeptr->rqPathSet.ThrottleFrom;
   *vecptr++ = rqeptr->rqPathSet.ThrottlePerUser;
   if (rqeptr->rqPathSet.ThrottleFrom)
   {
      if (!rqeptr->ThrottleListEntry.DataPtr)
         *vecptr++ = " (QUEUED)";
      else
         *vecptr++ = " (PROCESSING)";
   }
   else
      *vecptr++ = "";
   *vecptr++ = rqeptr->rqPathSet.ThrottleTo;
   *vecptr++ = rqeptr->rqPathSet.ThrottleResume;
   *vecptr++ = rqeptr->rqPathSet.ThrottleBusy;
   *vecptr++ = rqeptr->rqPathSet.ThrottleIndex;
   /* if throttled get the path rule using the index number */
   if (rqeptr->rqPathSet.ThrottleIndex)
      mrptr = MapUrl_ThrottleRule (rqeptr->rqPathSet.ThrottleIndex);
   else
      mrptr = NULL;
   if (mrptr)
   {
      *vecptr++ = " (!AZ throttle=!UL,!UL,!UL,!UL,!AZ,!AZ)";
      *vecptr++ = mrptr->TemplatePtr;
      *vecptr++ = mrptr->mpPathSet.ThrottleFrom;
      *vecptr++ = mrptr->mpPathSet.ThrottleTo;
      *vecptr++ = mrptr->mpPathSet.ThrottleResume;
      *vecptr++ = mrptr->mpPathSet.ThrottleBusy;
      *vecptr++ = MetaConShowSeconds (rqptr, mrptr->mpPathSet.ThrottleTimeoutQueue);
      *vecptr++ = MetaConShowSeconds (rqptr, mrptr->mpPathSet.ThrottleTimeoutBusy);
   }
   else
      *vecptr++ = "";
   *vecptr++ = rqeptr->ThrottlePerUser;

   *vecptr++ = rqeptr->rqTime.BeginTime64;
   *vecptr++ = DurationString (rqptr, &ResponseDuration);
   *vecptr++ = rqeptr->rqTime.GmDateTime;

   FaoCheck (sizeof(FaoVector), &FaoVector, vecptr, FI_LI);
   status = FaolToBuffer (Buffer, sizeof(Buffer), &Length,
                          TimerFao, &FaoVector);
   if (VMSnok (status) || status == SS$_BUFFEROVF)
      ErrorNoticed (rqptr, status, NULL, FI_LI);

   WatchWrite (Buffer, Length);

   vecptr = FaoVector;

   if (rqeptr->rqHeader.RequestHeaderPtrInvalid)
   {
      *vecptr++ = sizeof("(invalid)")-1;
      *vecptr++ = "(invalid)";
   }
   else
   {
      *vecptr++ = rqeptr->rqHeader.RequestHeaderLength;
      *vecptr++ = WATCH_NULL(rqeptr->rqHeader.RequestHeaderPtr);
   }
   *vecptr++ = rqeptr->rqHeader.RequestBodyCount;
   *vecptr++ = WATCH_NULL(rqeptr->rqHeader.RequestBodyPtr);
   *vecptr++ = rqeptr->rqHeader.MethodName;
   if (rqeptr->rqHeader.RequestUriPtr)
      *vecptr++ = strlen(rqeptr->rqHeader.RequestUriPtr);
   else
      *vecptr++ = 0;
   *vecptr++ = rqeptr->rqHeader.RequestUriPtr;
   *vecptr++ = rqeptr->rqHeader.HttpVersion / 10;
   *vecptr++ = rqeptr->rqHeader.HttpVersion % 10;
   *vecptr++ = rqeptr->rqHeader.AcceptPtr;
   *vecptr++ = rqeptr->rqHeader.AcceptCharsetPtr;
   *vecptr++ = rqeptr->rqHeader.AcceptEncodingPtr;
   *vecptr++ = rqeptr->rqHeader.AcceptLangPtr;
   *vecptr++ = rqeptr->rqHeader.AuthorizationPtr;
   *vecptr++ = rqeptr->rqHeader.CacheControlNoCache;
   *vecptr++ = rqeptr->rqHeader.CacheControlNoStore;
   *vecptr++ = rqeptr->rqHeader.CacheControlMaxAgeZero;
   *vecptr++ = rqeptr->rqHeader.ContentLength;
   *vecptr++ = rqeptr->rqHeader.ContentTypePtr;
   *vecptr++ = rqeptr->rqHeader.CookiePtr;
   *vecptr++ = rqeptr->rqHeader.ForwardedPtr;
   *vecptr++ = rqeptr->rqHeader.HostPtr;
   *vecptr++ = rqeptr->rqHeader.IfMatchPtr;
   *vecptr++ = rqeptr->rqHeader.IfNoneMatchPtr;
   *vecptr++ = rqeptr->rqHeader.OriginPtr;
   *vecptr++ = rqeptr->rqHeader.ProxyAuthorizationPtr;
   *vecptr++ = rqeptr->rqHeader.RefererPtr;
   *vecptr++ = rqeptr->rqHeader.UserAgentPtr;
   *vecptr++ = rqeptr->rqHeader.XForwardedForPtr;

   FaoCheck (sizeof(FaoVector), &FaoVector, vecptr, FI_LI);
   status = FaolToBuffer (Buffer, sizeof(Buffer), &Length,
                          HeaderFao, &FaoVector);
   if (VMSnok (status) || status == SS$_BUFFEROVF)
      ErrorNoticed (rqptr, status, NULL, FI_LI);

   WatchWrite (Buffer, Length);

   vecptr = FaoVector;

   *vecptr++ = rqeptr->rqBody.UnEncodeStream;
   *vecptr++ = rqeptr->rqBody.ChunkState;
   *vecptr++ = rqeptr->rqBody.ChunkCount;
   *vecptr++ = rqeptr->rqBody.ChunkSize;
   *vecptr++ = rqeptr->rqBody.ChunkSizeString;
   *vecptr++ = rqeptr->rqBody.ChunkedTrailerBufferCount;
   *vecptr++ = rqeptr->rqBody.ChunkedTrailerBufferSize;
   *vecptr++ = rqeptr->rqBody.ChunkedTrailerBufferPtr;
   *vecptr++ = rqeptr->rqBody.ChunkedTrailerNewLineCount;
   *vecptr++ = rqeptr->rqBody.ContentLength;
   *vecptr++ = rqeptr->rqBody.ContentCount;
   *vecptr++ = rqeptr->rqBody.DataVBN;
   *vecptr++ = rqeptr->rqBody.DataPtr;
   *vecptr++ = rqeptr->rqBody.DataCount;
   *vecptr++ = rqeptr->rqBody.DataSize;
   *vecptr++ = rqeptr->rqBody.DataStatus;
   *vecptr++ = rqeptr->rqBody.DiscardReadCount;
   *vecptr++ = rqeptr->rqBody.AstFunction;
   *vecptr++ = rqeptr->rqBody.ProcessFunction;
   *vecptr++ = rqeptr->rqBody.ProcessPtr;

   FaoCheck (sizeof(FaoVector), &FaoVector, vecptr, FI_LI);
   status = FaolToBuffer (Buffer, sizeof(Buffer), &Length,
                          BodyFao, &FaoVector);
   if (VMSnok (status) || status == SS$_BUFFEROVF)
      ErrorNoticed (rqptr, status, NULL, FI_LI);

   WatchWrite (Buffer, Length);

   vecptr = FaoVector;

   *vecptr++ = rqeptr->rqHeader.PathInfoPtr;
   *vecptr++ = rqeptr->rqHeader.QueryStringPtr;
   *vecptr++ = &rqeptr->Md5HashPath;
   *vecptr++ = rqeptr->MappedPathPtr;
   *vecptr++ = rqeptr->RequestMappedFile;
   *vecptr++ = rqeptr->ParseOds.ExpFileName;
   *vecptr++ = rqeptr->ScriptName;
   *vecptr++ = rqeptr->RequestMappedScript;
   *vecptr++ = rqeptr->RequestMappedRunTime;
   *vecptr++ = rqeptr->IsCgiPlusScript;
   *vecptr++ = rqeptr->rqPathSet.PathOds;
   switch (rqeptr->rqPathSet.PathOds)
   {
      case MAPURL_PATH_ODS_2 : *vecptr++ = "ODS-2"; break;
      case MAPURL_PATH_ODS_5 : *vecptr++ = "ODS-5"; break;
      case MAPURL_PATH_ODS_ADS : *vecptr++ = "ADS"; break;
      case MAPURL_PATH_ODS_PWK : *vecptr++ = "PWK"; break;
      case MAPURL_PATH_ODS_SMB : *vecptr++ = "SMB"; break;
      case MAPURL_PATH_ODS_SRI : *vecptr++ = "SRI"; break;
      default : *vecptr++ = "ods-2";
   }
   *vecptr++ = rqeptr->PathOds;
   switch (rqeptr->PathOds)
   {
      case MAPURL_PATH_ODS_2 : *vecptr++ = "ODS-2"; break;
      case MAPURL_PATH_ODS_5 : *vecptr++ = "ODS-5"; break;
      case MAPURL_PATH_ODS_ADS : *vecptr++ = "ADS"; break;
      case MAPURL_PATH_ODS_PWK : *vecptr++ = "PWK"; break;
      case MAPURL_PATH_ODS_SMB : *vecptr++ = "SMB"; break;
      case MAPURL_PATH_ODS_SRI : *vecptr++ = "SRI"; break;
      default : *vecptr++ = "ods-2";
   }
   *vecptr++ = rqeptr->PathOdsExtended;

   *vecptr++ = rqeptr->rqResponse.HeaderGenerated;
   *vecptr++ = rqeptr->rqResponse.HeaderSent;
   *vecptr++ = rqeptr->rqResponse.ErrorReportPtr;
   *vecptr++ = rqeptr->rqResponse.LocationPtr;
   *vecptr++ = rqeptr->rqResponse.ContentEncodeAsGzip;
   *vecptr++ = rqeptr->rqResponse.ContentIsEncodedGzip;
   *vecptr++ = rqeptr->rqResponse.ChunkedBufferPtr;
   *vecptr++ = rqeptr->rqResponse.ChunkedBufferSize;
   *vecptr++ = rqeptr->rqResponse.TransferEncodingChunked;

   *vecptr++ = rqeptr->rqWebSocket.ScriptProcessPid;
   *vecptr++ = rqeptr->rqWebSocket.InputSize;
   *vecptr++ = rqeptr->rqWebSocket.InputChannel;
   *vecptr++ = rqeptr->rqWebSocket.InputDevName;
   *vecptr++ = rqeptr->rqWebSocket.InputIOsb.Status;
   *vecptr++ = rqeptr->rqWebSocket.InputIOsb.Count;
   *vecptr++ = rqeptr->rqWebSocket.QueuedInput;
   *vecptr++ = rqeptr->rqWebSocket.QueuedNetRead;
   *vecptr++ = rqeptr->rqWebSocket.OutputSize;
   *vecptr++ = rqeptr->rqWebSocket.OutputChannel;
   *vecptr++ = rqeptr->rqWebSocket.OutputDevName;
   *vecptr++ = rqeptr->rqWebSocket.OutputIOsb.Status;
   *vecptr++ = rqeptr->rqWebSocket.OutputIOsb.Count;
   *vecptr++ = rqeptr->rqWebSocket.QueuedOutput;
   *vecptr++ = rqeptr->rqWebSocket.QueuedNetWrite;

   *vecptr++ = rqeptr->RemoteUser;
   *vecptr++ = strlen(rqeptr->RemoteUserPassword);
   *vecptr++ = rqeptr->rqAuth.ResolvedRemoteUser;
   *vecptr++ = rqeptr->rqAuth.FinalStatus;
   *vecptr++ = rqeptr->rqAuth.RequestCan;
   *vecptr++ = AuthCanString (rqeptr->rqAuth.RequestCan, AUTH_CAN_FORMAT_LONG);
   *vecptr++ = rqeptr->rqAuth.UserCan;
   *vecptr++ = AuthCanString (rqeptr->rqAuth.UserCan, AUTH_CAN_FORMAT_LONG);
   *vecptr++ = rqeptr->rqAuth.GroupCan;
   *vecptr++ = AuthCanString (rqeptr->rqAuth.GroupCan, AUTH_CAN_FORMAT_LONG);
   *vecptr++ = rqeptr->rqAuth.WorldCan;
   *vecptr++ = AuthCanString (rqeptr->rqAuth.WorldCan, AUTH_CAN_FORMAT_LONG);
   *vecptr++ = rqeptr->rqAuth.Type;
   *vecptr++ = rqeptr->rqAuth.UserDetailsPtr;
   *vecptr++ = rqeptr->rqAuth.HttpsOnly;
   *vecptr++ = rqeptr->rqAuth.SkelKeyAuthenticated;
   *vecptr++ = rqeptr->rqAuth.SysUafAuthenticated;
   *vecptr++ = rqeptr->rqAuth.VmsIdentifiersCount;
   *vecptr++ = rqeptr->rqAuth.VmsIdentifiersPtr;
   *vecptr++ = rqeptr->rqAuth.VmsUserProfile;
   *vecptr++ = rqeptr->rqAuth.VmsUserProfileLength;
   *vecptr++ = rqeptr->rqAuth.VmsUserProfilePtr;
   *vecptr++ = rqeptr->rqAuth.VmsUserScriptAs;
   *vecptr++ = rqeptr->rqAuth.DirectoryPtr;
   *vecptr++ = rqeptr->rqAuth.RealmPtr;
   *vecptr++ = AuthSourceString (rqeptr->rqAuth.RealmPtr,
                                 rqeptr->rqAuth.SourceRealm);
   *vecptr++ = rqeptr->rqAuth.RealmDescrPtr;
   *vecptr++ = rqeptr->rqAuth.PathParameterPtr;
   *vecptr++ = rqeptr->rqAuth.GroupWritePtr;
   *vecptr++ = AuthSourceString (rqeptr->rqAuth.GroupWritePtr,
                                 rqeptr->rqAuth.SourceGroupWrite);
   *vecptr++ = rqeptr->rqAuth.GroupReadPtr;
   *vecptr++ = AuthSourceString (rqeptr->rqAuth.GroupReadPtr,
                                 rqeptr->rqAuth.SourceGroupRead);
   *vecptr++ = rqeptr->rqAuth.GroupRestrictListPtr;
   *vecptr++ = rqeptr->rqAuth.WorldRestrictListPtr;
   *vecptr++ = rqeptr->rqAuth.ProxyStringPtr;
   *vecptr++ = rqeptr->rqAuth.RemoteUser;

   *vecptr++ = rqeptr->rqCgi.BufferLength;
   *vecptr++ = rqeptr->rqCgi.BufferRemaining;
   *vecptr++ = rqeptr->rqCgi.BufferPtr;
   *vecptr++ = rqeptr->rqCgi.BufferCurrentPtr;
   *vecptr++ = rqeptr->rqCgi.CalloutInProgress;
   *vecptr++ = rqeptr->rqCgi.CalloutOutputCount;
   *vecptr++ = rqeptr->rqCgi.CalloutOutputPtr;
   *vecptr++ = rqeptr->rqCgi.CalloutOutputPtr;
   *vecptr++ = rqeptr->rqCgi.ContentEncodingGzip;
   *vecptr++ = rqeptr->rqCgi.ContentTypeText;
   *vecptr++ = rqeptr->rqCgi.EofStr;
   *vecptr++ = rqeptr->rqCgi.EotStr;
   *vecptr++ = rqeptr->rqCgi.EscStr;
   *vecptr++ = rqeptr->rqCgi.Header100Continue;
   *vecptr++ = rqeptr->rqCgi.Header100ContinueDone;
   *vecptr++ = rqeptr->rqCgi.HeaderLineCount;
   *vecptr++ = rqeptr->rqCgi.IsCliDcl;
   *vecptr++ = rqeptr->rqCgi.OutputMode;
   switch (rqeptr->rqCgi.OutputMode)
   {
      case CGI_OUTPUT_MODE_STREAM : *vecptr++ = "STREAM"; break;
      case CGI_OUTPUT_MODE_RECORD : *vecptr++ = "RECORD"; break;
      case CGI_OUTPUT_MODE_CRLF : *vecptr++ = "CRLF"; break;
      default : *vecptr++ = "?";
   }
   *vecptr++ = rqeptr->rqCgi.ProcessingBody;
   *vecptr++ = rqeptr->rqCgi.RecordCount;
   *vecptr++ = rqeptr->rqCgi.ScriptRetryCount;
   *vecptr++ = rqeptr->rqCgi.TransferEncoding;
   *vecptr++ = rqeptr->rqCgi.TransferEncodingChunked;
   *vecptr++ = rqeptr->rqCgi.XVMSRecordMode;

   FaoCheck (sizeof(FaoVector), &FaoVector, vecptr, FI_LI);
   status = FaolToBuffer (Buffer, sizeof(Buffer), &Length,
                          PathInfoFao, &FaoVector);
   if (VMSnok (status) || status == SS$_BUFFEROVF)
      ErrorNoticed (rqptr, status, NULL, FI_LI);

   WatchWrite (Buffer, Length);

   if ((cptr = rqeptr->rqCgi.BufferPtr))
   {
      /*****************/
      /* CGI variables */
      /*****************/

      for (;;)
      {
         if (!(Length = *(USHORTPTR)cptr)) break;
         status = FaoToBuffer (Buffer, sizeof(Buffer), &Length, "!&Z\n",
                               cptr + sizeof(short));
         if (VMSnok (status) || status == SS$_BUFFEROVF)
            ErrorNoticed (rqptr, status, NULL, FI_LI);

         WatchWrite (Buffer, Length);

         cptr += *(USHORTPTR)cptr + sizeof(short);
      }
   }

   vecptr = FaoVector;
   *vecptr++ = rqeptr->rqCache.EntryPtr;
   *vecptr++ = rqeptr->DclTaskPtr;

   FaoCheck (sizeof(FaoVector), &FaoVector, vecptr, FI_LI);
   status = FaolToBuffer (Buffer, sizeof(Buffer), &Length,
                          CacheFao, &FaoVector);
   if (VMSnok (status) || status == SS$_BUFFEROVF)
      ErrorNoticed (rqptr, status, NULL, FI_LI);

   WatchWrite (Buffer, Length);

   if (rqeptr->DclTaskPtr) WatchPeekDcl (rqptr, rqeptr->DclTaskPtr);

   vecptr = FaoVector;
   *vecptr++ = rqeptr->DECnetTaskPtr;

   FaoCheck (sizeof(FaoVector), &FaoVector, vecptr, FI_LI);
   status = FaolToBuffer (Buffer, sizeof(Buffer), &Length,
                          DECnetFao, &FaoVector);
   if (VMSnok (status) || status == SS$_BUFFEROVF)
      ErrorNoticed (rqptr, status, NULL, FI_LI);

   WatchWrite (Buffer, Length);

   if (rqeptr->DECnetTaskPtr)
   {
      /***************/
      /* DECnet task */
      /***************/

      vecptr = FaoVector;
      *vecptr++ = rqeptr->DECnetTaskPtr->DECnetChannel;
      *vecptr++ = rqeptr->DECnetTaskPtr->DECnetConnectIOsb.Status;
      *vecptr++ = rqeptr->DECnetTaskPtr->DECnetConnectIOsb.Count;
      *vecptr++ = rqeptr->DECnetTaskPtr->DECnetReadIOsb.Status;
      *vecptr++ = rqeptr->DECnetTaskPtr->DECnetReadIOsb.Count;
      *vecptr++ = rqeptr->DECnetTaskPtr->DECnetWriteIOsb.Status;
      *vecptr++ = rqeptr->DECnetTaskPtr->DECnetWriteIOsb.Count;
      *vecptr++ = rqeptr->DECnetTaskPtr->QueuedDECnetIO;
      *vecptr++ = rqeptr->DECnetTaskPtr->ScriptResponded;
      *vecptr++ = rqeptr->DECnetTaskPtr->BuildRecords;
      *vecptr++ = rqeptr->DECnetTaskPtr->BuildCount;
      *vecptr++ = rqeptr->DECnetTaskPtr->CgiDialogState;
      *vecptr++ = rqeptr->DECnetTaskPtr->OsuDialogState;
      *vecptr++ = rqeptr->DECnetTaskPtr->OsuDnetCgi;

      FaoCheck (sizeof(FaoVector), &FaoVector, vecptr, FI_LI);
      status = FaolToBuffer (Buffer, sizeof(Buffer), &Length,
                             DECnetTaskFao, &FaoVector);
      if (VMSnok (status) || status == SS$_BUFFEROVF)
         ErrorNoticed (rqptr, status, NULL, FI_LI);

      WatchWrite (Buffer, Length);
   }

   vecptr = FaoVector;
   *vecptr++ = rqeptr->DescrTaskPtr;
   *vecptr++ = rqeptr->DirTaskPtr;
   *vecptr++ = rqeptr->FileTaskPtr;
   *vecptr++ = rqeptr->HTAdminTaskPtr;
   *vecptr++ = rqeptr->ProxyTaskPtr;

   FaoCheck (sizeof(FaoVector), &FaoVector, vecptr, FI_LI);
   status = FaolToBuffer (Buffer, sizeof(Buffer), &Length,
                          DescrFao, &FaoVector);
   if (VMSnok (status) || status == SS$_BUFFEROVF)
      ErrorNoticed (rqptr, status, NULL, FI_LI);

   WatchWrite (Buffer, Length);

   if (rqeptr->ProxyTaskPtr)
   {
      /**************/
      /* proxy task */
      /**************/

      NetGetBgDevice (rqeptr->ProxyTaskPtr->NetIoPtr->Channel,
                      ProxyDevName, sizeof(ProxyDevName));

      vecptr = FaoVector;
      *vecptr++ = rqeptr->ProxyTaskPtr->NetIoPtr->Channel;
      *vecptr++ = ProxyDevName+1;
      *vecptr++ = rqeptr->ProxyTaskPtr->NetIoPtr->QioMaxSeg;
      *vecptr++ = rqeptr->ProxyTaskPtr->NetIoPtr->ReadIOsb.Status;
      *vecptr++ = rqeptr->ProxyTaskPtr->NetIoPtr->ReadIOsb.Count;
      *vecptr++ = rqeptr->ProxyTaskPtr->NetIoPtr->ReadStatus;
      *vecptr++ = rqeptr->ProxyTaskPtr->NetIoPtr->ReadCount;
      *vecptr++ = rqeptr->ProxyTaskPtr->NetIoPtr->ReadAstFunction;
      *vecptr++ = rqeptr->ProxyTaskPtr->NetIoPtr->ReadPtr;
      *vecptr++ = rqeptr->ProxyTaskPtr->NetIoPtr->ReadSize;
      *vecptr++ = rqeptr->ProxyTaskPtr->NetIoPtr->WriteIOsb.Status;
      *vecptr++ = rqeptr->ProxyTaskPtr->NetIoPtr->WriteIOsb.Count;
      *vecptr++ = rqeptr->ProxyTaskPtr->NetIoPtr->WriteStatus;
      *vecptr++ = rqeptr->ProxyTaskPtr->NetIoPtr->WriteCount;
      *vecptr++ = rqeptr->ProxyTaskPtr->NetIoPtr->WriteAstFunction;
      *vecptr++ = rqeptr->ProxyTaskPtr->NetIoPtr->WritePtr;
      *vecptr++ = rqeptr->ProxyTaskPtr->NetIoPtr->WriteLength;
      *vecptr++ = rqeptr->ProxyTaskPtr->NetIoPtr->BytesRawRx;
      *vecptr++ = rqeptr->ProxyTaskPtr->NetIoPtr->BytesRawTx;
      *vecptr++ = &rqeptr->ProxyTaskPtr->ConnectIpAddress;
      *vecptr++ = &rqeptr->ProxyTaskPtr->RequestHostIpAddress;
      *vecptr++ = rqeptr->ProxyTaskPtr->RequestHostPort;
      *vecptr++ = rqeptr->ProxyTaskPtr->RequestSchemeName;
      *vecptr++ = rqeptr->ProxyTaskPtr->ProxyTunnel;
      *vecptr++ = rqeptr->ProxyTaskPtr->ProxyLookupRetryCount;
      *vecptr++ = rqeptr->ProxyTaskPtr->ProxyConnectIOsb.Status;
      *vecptr++ = rqeptr->ProxyTaskPtr->ProxyConnectIOsb.Count;
      *vecptr++ = rqeptr->ProxyTaskPtr->VerifyRecordPtr;
      *vecptr++ = rqeptr->ProxyTaskPtr->RebuiltRequestLength;
      *vecptr++ = rqeptr->ProxyTaskPtr->RebuiltRequestPtr;
      *vecptr++ = rqeptr->ProxyTaskPtr->ResponseBodyLength;
      *vecptr++ = rqeptr->ProxyTaskPtr->ResponseBufferNetCount;
      *vecptr++ = rqeptr->ProxyTaskPtr->ResponseBufferNetPtr;
      *vecptr++ = rqeptr->ProxyTaskPtr->ResponseCacheControlMaxAge;
      *vecptr++ = rqeptr->ProxyTaskPtr->ResponseCacheControlMaxAgeZero;
      *vecptr++ = rqeptr->ProxyTaskPtr->ResponseCacheControlMustReval;
      *vecptr++ = rqeptr->ProxyTaskPtr->ResponseCacheControlNoCache;
      *vecptr++ = rqeptr->ProxyTaskPtr->ResponseCacheControlNoStore;
      *vecptr++ = rqeptr->ProxyTaskPtr->ResponseCacheControlNoTransform;
      *vecptr++ = rqeptr->ProxyTaskPtr->ResponseCacheControlPrivate;
      *vecptr++ = rqeptr->ProxyTaskPtr->ResponseCacheControlProxyReval;
      *vecptr++ = rqeptr->ProxyTaskPtr->ResponseCacheControlPublic;
      *vecptr++ = rqeptr->ProxyTaskPtr->ResponseCacheControlSMaxAge;
      *vecptr++ = rqeptr->ProxyTaskPtr->ResponseChunkedCount;
      *vecptr++ = rqeptr->ProxyTaskPtr->ResponseChunkedEnd;
      *vecptr++ = rqeptr->ProxyTaskPtr->ResponseChunkedEol;
      *vecptr++ = rqeptr->ProxyTaskPtr->ResponseChunkedEot;
      *vecptr++ = rqeptr->ProxyTaskPtr->ResponseChunkedInit;
      *vecptr++ = rqeptr->ProxyTaskPtr->ResponseChunkedSize;
      *vecptr++ = rqeptr->ProxyTaskPtr->ResponseChunkedString;
      *vecptr++ = rqeptr->ProxyTaskPtr->ResponseChunkedNewlineCount;
      *vecptr++ = rqeptr->ProxyTaskPtr->ResponseConsecutiveNewLineCount;
      *vecptr++ = rqeptr->ProxyTaskPtr->ResponseContentEncodingGzip;
      *vecptr++ = rqeptr->ProxyTaskPtr->ResponseContentEncodingUnknown;
      *vecptr++ = rqeptr->ProxyTaskPtr->ResponseContentLength;
      *vecptr++ = rqeptr->ProxyTaskPtr->ResponseExpires;
      *vecptr++ = rqeptr->ProxyTaskPtr->ResponseExpiresTime64;
      *vecptr++ = rqeptr->ProxyTaskPtr->ResponseHeaderLength;
      if (!rqeptr->ProxyTaskPtr->ResponseHeaderPtr)
      {
         *vecptr++ = sizeof(WATCH_NULL_STRING)-1;
         *vecptr++ = WATCH_NULL_STRING;
      }
      else
      if (rqeptr->ProxyTaskPtr->ResponseConsecutiveNewLineCount < 2)
      {
         *vecptr++ = rqeptr->ProxyTaskPtr->ResponseHeaderLength;
         *vecptr++ = WATCH_NULL(rqeptr->ProxyTaskPtr->ResponseHeaderPtr);
      }
      else
      {
         *vecptr++ = sizeof(WATCH_NULL_STRING)-1;
         *vecptr++ = WATCH_NULL_STRING;
      }
      *vecptr++ = rqeptr->ProxyTaskPtr->ResponseHeaderSent;
      *vecptr++ = rqeptr->ProxyTaskPtr->ResponseLastModified;
      *vecptr++ = rqeptr->ProxyTaskPtr->ResponseLastModifiedTime64;
      *vecptr++ = rqeptr->ProxyTaskPtr->ResponseTransferEncodingChunked;
      *vecptr++ = rqeptr->ProxyTaskPtr->ResponseUpgradeWebSocket;
      *vecptr++ = rqeptr->ProxyTaskPtr->RebuiltResponseLength;
      *vecptr++ = rqeptr->ProxyTaskPtr->RebuiltResponsePtr;
      *vecptr++ = rqeptr->ProxyTaskPtr->CannotCache;
      *vecptr++ = rqeptr->ProxyTaskPtr->ProxyCacheFileName;
      *vecptr++ = rqeptr->ProxyTaskPtr->ProxyCacheSuitable;
      *vecptr++ = rqeptr->ProxyTaskPtr->ProxyCacheFileSizeInBytes;
      *vecptr++ = rqeptr->ProxyTaskPtr->ProxyCacheLastModifiedHours;
      *vecptr++ = rqeptr->ProxyTaskPtr->ProxyCacheReadBytes;
      *vecptr++ = &rqeptr->ProxyTaskPtr->ProxyCacheFileCdt;

      FaoCheck (sizeof(FaoVector), &FaoVector, vecptr, FI_LI);
      status = FaolToBuffer (Buffer, sizeof(Buffer), &Length,
                             ProxyTaskFao, &FaoVector);
      if (VMSnok (status) || status == SS$_BUFFEROVF)
         ErrorNoticed (rqptr, status, NULL, FI_LI);

      WatchWrite (Buffer, Length);
   }

   vecptr = FaoVector;
   *vecptr++ = rqeptr->PutTaskPtr;
   *vecptr++ = rqeptr->SsiTaskPtr;
   *vecptr++ = rqeptr->UpdTaskPtr;

   FaoCheck (sizeof(FaoVector), &FaoVector, vecptr, FI_LI);
   status = FaolToBuffer (Buffer, sizeof(Buffer), &Length, PutFao, &FaoVector);
   if (VMSnok (status) || status == SS$_BUFFEROVF)
      ErrorNoticed (rqptr, status, NULL, FI_LI);

   WatchWrite (Buffer, Length);

   WatchNone (false);
}

/*****************************************************************************/
/*
Peek at the supplied DCL structure.
*/

void WatchPeekDcl
(
REQUEST_STRUCT *rqptr,
DCL_TASK *tkptr
)
{
   static char  DclTaskFao [] =
"!33<RequestPtr!> !&X\n\
!33<TaskType!> !UL (!AZ)\n\
!33<LifeTimeSecond!> !&@\n\
!33<CrePrcTermMbxChannel!> !UL (!AZ)\n\
!33<CrePrcDetachProcess!> !UL\n\
!33<CrePrcDetachStarting!> !UL\n\
!33<CrePrcUserName!> !&Z\n\
!33<CgiPlusVarStruct!> !UL\n\
!33<CgiPlusInChannel!> !UL (!AZ)\n\
!33<CgiPlusInIOsb!> !&S !UL\n\
!33<QueuedCgiPlusIn!> !UL\n\
!33<HttpInputChannel!> !UL (!AZ)\n\
!33<HttpInputIOsb!> !&S !UL\n\
!33<QueuedHttpInput!> !UL\n\
!33<ClientReadBufferSize!> !UL\n\
!33<ClientReadStripCrLf!> !UL\n\
!33<QueuedClientRead!> !UL\n\
!33<SysCommandChannel!> !UL (!AZ)\n\
!33<SysCommandIOsb!> !&S !UL\n\
!33<QueuedSysCommand!> !UL\n\
!33<QueuedSysCommandAllowed!> !UL\n\
!33<SysOutputSize!> !UL\n\
!33<SysOutputChannel!> !UL (!AZ)\n\
!33<SysOutputIOsb!> !&S !UL\n\
!33<QueuedSysOutput!> !UL\n\
!33<QueuedClientOutput!> !UL\n\
!33<BuildRecords!> !&B\n\
!33<SysOutputBuildCount!> !UL\n\
!33<ClientWriteErrorCount!> !UL\n\
!33<ScriptProcessPid!> !8XL\n\
!33<CrePrcTermRecord.acc$l_finalsts!> !&S\n\
!33<ScriptProcessActivated!> !&B\n\
!33<ScriptProcessResponded!> !&B\n\
!33<TaskRunDown!> !UL\n\
!33<DeleteProcess!> !&B\n\
!33<ForceImageExit!> !&B\n\
!33<ForceImageExitGetJpi!> !&B\n\
!33<ForceImageExitIssued!> !&B\n\
!33<ForceImageExitSecond!> !UL\n\
!33<JpiImagNameIOsb.Status!> !&S\n\
!33<JpiImagName!> |!#AZ|\n\
!33<ScriptCpuMax!> !UL\n\
!33<ScriptCpuTimGetJpi!> !UL\n\
!33<JpiCpuTimIOsb.Status!> !&S\n\
!33<JpiCpuTim!> !UL\n\
!33<ScriptCpuTimMax!> !UL\n\
!33<CalloutFunction!> !&A\n\
!33<DclCommandPtr!> !&Z\n\
!33<DclCommandSize!> !UL\n\
!33<DclCommandLength!> !UL\n\
!33<ScriptName!> !&Z\n\
!33<ScriptFileName!> !&Z\n\
|\n";

   int  status;
   ushort  slen;
   ulong  FaoVector [96];
   ulong  *vecptr;
   char  Buffer [4096];

   if (!tkptr) return;

   vecptr = FaoVector;
   *vecptr++ = tkptr->RequestPtr;
   *vecptr++ = tkptr->TaskType;
   switch (tkptr->TaskType)
   {
      case DCL_TASK_TYPE_NONE : *vecptr++ = "none"; break;
      case DCL_TASK_TYPE_CLI : *vecptr++ = "CLI"; break;
      case DCL_TASK_TYPE_CGI_SCRIPT : *vecptr++ = "CGI"; break;
      case DCL_TASK_TYPE_CGIPLUS_SCRIPT : *vecptr++ = "CGIplus"; break;
      case DCL_TASK_TYPE_RTE_SCRIPT : *vecptr++ = "RTE"; break;
      default : *vecptr++ = "?";
   }
   if (tkptr->LifeTimeSecond == DCL_DO_NOT_DISTURB)
      *vecptr++ = "DO-NOT-DISTURB";
   else
   {
      *vecptr++ = "!UL";
      *vecptr++ = tkptr->LifeTimeSecond;
   }
   *vecptr++ = tkptr->CrePrcTermMbxChannel;
   *vecptr++ = tkptr->CrePrcTermMbxDevName+1;
   *vecptr++ = tkptr->CrePrcDetachProcess;
   *vecptr++ = tkptr->CrePrcDetachStarting;
   *vecptr++ = tkptr->CrePrcUserName;
   *vecptr++ = tkptr->CgiPlusVarStruct;
   *vecptr++ = tkptr->CgiPlusInChannel;
   *vecptr++ = tkptr->CgiPlusInDevName+1;
   *vecptr++ = tkptr->CgiPlusInIOsb.Status;
   *vecptr++ = tkptr->CgiPlusInIOsb.Count;
   *vecptr++ = tkptr->QueuedCgiPlusIn;
   *vecptr++ = tkptr->HttpInputChannel;
   *vecptr++ = tkptr->HttpInputDevName+1;
   *vecptr++ = tkptr->HttpInputIOsb.Status;
   *vecptr++ = tkptr->HttpInputIOsb.Count;
   *vecptr++ = tkptr->QueuedHttpInput;
   *vecptr++ = tkptr->ClientReadBufferSize;
   *vecptr++ = tkptr->ClientReadStripCrLf;
   *vecptr++ = tkptr->QueuedClientRead;
   *vecptr++ = tkptr->SysCommandChannel;
   *vecptr++ = tkptr->SysCommandDevName+1;
   *vecptr++ = tkptr->SysCommandIOsb.Status;
   *vecptr++ = tkptr->SysCommandIOsb.Count;
   *vecptr++ = tkptr->QueuedSysCommand;
   *vecptr++ = tkptr->QueuedSysCommandAllowed;
   *vecptr++ = tkptr->SysOutputSize;
   *vecptr++ = tkptr->SysOutputChannel;
   *vecptr++ = tkptr->SysOutputDevName+1;
   *vecptr++ = tkptr->SysOutputIOsb.Status;
   *vecptr++ = tkptr->SysOutputIOsb.Count;
   *vecptr++ = tkptr->QueuedSysOutput;
   *vecptr++ = tkptr->QueuedClientOutput;
   *vecptr++ = tkptr->BuildRecords;
   *vecptr++ = tkptr->SysOutputBuildCount;
   *vecptr++ = tkptr->ClientWriteErrorCount;
   *vecptr++ = tkptr->ScriptProcessPid;
   *vecptr++ = tkptr->CrePrcTermRecord.acc$l_finalsts;
   *vecptr++ = tkptr->ScriptProcessActivated;
   *vecptr++ = tkptr->ScriptProcessResponded;
   *vecptr++ = tkptr->TaskRunDown;
   *vecptr++ = tkptr->DeleteProcess;
   *vecptr++ = tkptr->ForceImageExit;
   *vecptr++ = tkptr->ForceImageExitGetJpi;
   *vecptr++ = tkptr->ForceImageExitIssued;
   *vecptr++ = tkptr->ForceImageExitSecond;
   *vecptr++ = tkptr->JpiImagNameIOsb.Status;
   *vecptr++ = tkptr->JpiImagNameLength;
   *vecptr++ = tkptr->JpiImagName;
   *vecptr++ = tkptr->ScriptCpuMax;
   *vecptr++ = tkptr->ScriptCpuTimGetJpi;
   *vecptr++ = tkptr->JpiCpuTimIOsb.Status;
   *vecptr++ = tkptr->JpiCpuTim;
   *vecptr++ = tkptr->ScriptCpuTimMax;
   *vecptr++ = tkptr->CalloutFunction;
   *vecptr++ = tkptr->DclCommandPtr;
   *vecptr++ = tkptr->DclCommandSize;
   *vecptr++ = tkptr->DclCommandLength;
   *vecptr++ = tkptr->ScriptName;
   *vecptr++ = tkptr->ScriptFileName;

   FaoCheck (sizeof(FaoVector), &FaoVector, vecptr, FI_LI);
   status = FaolToBuffer (Buffer, sizeof(Buffer), &slen,
                          DclTaskFao, &FaoVector);
   if (VMSnok (status) || status == SS$_BUFFEROVF)
      ErrorNoticed (rqptr, status, NULL, FI_LI);

   if (rqptr)
      NetWrite (rqptr, NULL, Buffer, slen);
   else
      WatchWrite (Buffer, slen);
}

/*****************************************************************************/
/*
Peek at the supplied HTTP/2 structure.
*/

void WatchPeekHttp2
(
REQUEST_STRUCT *rqptr,
HTTP2_STRUCT *h2ptr,
char *Title
)
{
   static char  NetIoFao [] =
"!AZ\n\
!33<BytesRawRx!> !@SQ\n\
!33<BytesRawTx!> !@SQ\n\
!33<ClientInitialWindowSize!> !UL\n\
!33<ClientMaxConcStreams!> !UL\n\
!33<ClientMaxFrameSize!> !UL\n\
!33<ClientMaxHeaderListSize!> !UL\n\
!33<ClientMaxHeaderTableSize!> !UL\n\
!33<ClientPushPromise!> !UL\n\
!33<ConnectNumber!> !UL\n\
!33<ConnectTime64!> !%D (!AZ ago)\n\
!33<FlowControlCount!> !UL\n\
!33<FlowControlCurrent!> !UL\n\
!33<FrameCountRx!> !UL\n\
!33<FrameCountTx!> !UL\n\
!33<FrameRequestCountRx!> !UL\n\
!33<FrameRequestCountTx!> !UL\n\
!33<GoAwayIdent!> !UL\n\
!33<GoAwayLastStreamIdent!> !UL\n\
!33<GoAwaySecond!> !UL\n\
!33<IdleSecond!> !UL (!SL seconds)\n\
!33<LastStreamIdent!> !UL\n\
!33<PingTime64!> !%D!&@\n\
!33<PingMicroSeconds!> !UL\n\
!33<PingBackTickSecond!> !UL (!SL seconds)\n\
!33<PingSendTickSecond!> !UL (!SL seconds)\n\
!33<QueuedWriteList[0].Count!> !UL\n\
!33<QueuedWriteList[1].Count!> !UL\n\
!33<QueuedWriteList[2].Count!> !UL\n\
!33<QueuedWriteList[3].Count!> !UL\n\
!33<QueuedWritePeak!> !UL\n\
!33<ReadBufferCount!> !UL\n\
!33<ReadBufferPtr!> !&X\n\
!33<ReadBufferSize!> !UL\n\
!33<ReadWindowSize!> !UL\n\
!33<RequestCount!> !UL\n\
!33<RequestCurrent!> !UL\n\
!33<RequestPeak!> !UL\n\
!33<ServerHeaderTableSize!> !UL\n\
!33<ServerInitialWindowSize!> !UL\n\
!33<ServerMaxConcStreams!> !UL\n\
!33<ServerMaxFrameSize!> !UL\n\
!33<ServerMaxHeaderTableSize!> !UL\n\
!33<ServerMaxHeaderListSize!> !UL\n\
!33<ServerPushPromise!> !UL\n\
!33<ServicePtr!> !&X\n\
!33<->ServerChannel!> !UL (!AZ)\n\
!33<->ServerHostPort!> !&Z\n\
!33<->ServerIpAddressString!> !&Z\n\
!33<StreamList.Count!> !UL\n\
!33<WriteWindowSize!> !UL\n\
!33<NETIO_IN_PROGRESS!> !&B\n";

   int  status;
   ushort  Length;
   ulong  BinaryTime [2],
          ConnectDuration [2],
          PingDuration [2];
   ulong  FaoVector [96];
   ulong  *vecptr;
   char  Buffer [4096],
         ServerDevName [64];

   /*********/
   /* begin */
   /*********/

   if (rqptr &&
       rqptr->Http2Stream.Http2Ptr &&
       rqptr->Http2Stream.Http2Ptr == h2ptr) return;

   WatchNone (true);

   NetGetBgDevice (h2ptr->ServicePtr->ServerChannel,
                   ServerDevName, sizeof(ServerDevName));

   sys$gettim (&BinaryTime);
   status = lib$sub_times (&BinaryTime, &h2ptr->ConnectTime64,
                           &ConnectDuration);
   if (VMSnok (status)) PUT_ZERO_QUAD (ConnectDuration);
   status = lib$sub_times (&BinaryTime, &h2ptr->PingTime64,
                           &PingDuration);
   if (VMSnok (status)) PUT_ZERO_QUAD (PingDuration);

   vecptr = FaoVector;

   *vecptr++ = Title ? Title : "";

   *vecptr++ = h2ptr->BytesRawRx;
   *vecptr++ = h2ptr->BytesRawTx;
   *vecptr++ = h2ptr->ClientInitialWindowSize;

   *vecptr++ = h2ptr->ClientMaxConcStreams;
   *vecptr++ = h2ptr->ClientMaxFrameSize;
   *vecptr++ = h2ptr->ClientMaxHeaderListSize;
   *vecptr++ = h2ptr->ClientMaxHeaderTableSize;
   *vecptr++ = h2ptr->ClientPushPromise;

   *vecptr++ = h2ptr->ConnectNumber;
   *vecptr++ = h2ptr->ConnectTime64;
   *vecptr++ = DurationString (rqptr, &ConnectDuration);

   *vecptr++ = h2ptr->FlowControlCount;
   *vecptr++ = h2ptr->FlowControlCurrent;

   *vecptr++ = h2ptr->FrameCountRx;
   *vecptr++ = h2ptr->FrameCountTx;
   *vecptr++ = h2ptr->FrameRequestCountRx;
   *vecptr++ = h2ptr->FrameRequestCountTx;

   *vecptr++ = h2ptr->GoAwayIdent;
   *vecptr++ = h2ptr->GoAwayLastStreamIdent;
   *vecptr++ = h2ptr->GoAwaySecond;
   *vecptr++ = h2ptr->IdleSecond;
   *vecptr++ = h2ptr->IdleSecond - HttpdTickSecond;
   *vecptr++ = h2ptr->LastStreamIdent;
   *vecptr++ = h2ptr->PingTime64;
   if (QUAD_ZERO (h2ptr->PingTime64))
      *vecptr++ = "";
   else
   {
      *vecptr++ = " (!AZ ago)";
      *vecptr++ = DurationString (rqptr, &PingDuration);
   }
   *vecptr++ = h2ptr->PingMicroSeconds;
   *vecptr++ = h2ptr->PingBackTickSecond;
   *vecptr++ = h2ptr->PingBackTickSecond ?
               h2ptr->PingBackTickSecond - HttpdTickSecond : 0;
   *vecptr++ = h2ptr->PingSendTickSecond;
   *vecptr++ = h2ptr->PingSendTickSecond ?
               h2ptr->PingSendTickSecond - HttpdTickSecond : 0;

   *vecptr++ = LIST_GET_COUNT(&h2ptr->QueuedWriteList[0]);
   *vecptr++ = LIST_GET_COUNT(&h2ptr->QueuedWriteList[1]);
   *vecptr++ = LIST_GET_COUNT(&h2ptr->QueuedWriteList[2]);
   *vecptr++ = LIST_GET_COUNT(&h2ptr->QueuedWriteList[3]);
   *vecptr++ = h2ptr->QueuedWritePeak;

   *vecptr++ = h2ptr->ReadBufferCount;
   *vecptr++ = h2ptr->ReadBufferPtr;
   *vecptr++ = h2ptr->ReadBufferSize;
   *vecptr++ = h2ptr->ReadWindowSize;

   *vecptr++ = h2ptr->RequestCount;
   *vecptr++ = h2ptr->RequestCurrent;
   *vecptr++ = h2ptr->RequestPeak;

   *vecptr++ = h2ptr->ServerHeaderTableSize;
   *vecptr++ = h2ptr->ServerInitialWindowSize;
   *vecptr++ = h2ptr->ServerMaxConcStreams;
   *vecptr++ = h2ptr->ServerMaxFrameSize;
   *vecptr++ = h2ptr->ServerMaxHeaderTableSize;
   *vecptr++ = h2ptr->ServerMaxHeaderListSize;
   *vecptr++ = h2ptr->ServerPushPromise;

   *vecptr++ = h2ptr->ServicePtr;
   *vecptr++ = h2ptr->ServicePtr->ServerChannel;
   *vecptr++ = ServerDevName+1;
   *vecptr++ = h2ptr->ServicePtr->ServerHostPort;
   *vecptr++ = h2ptr->ServicePtr->ServerIpAddressString;

   *vecptr++ = LIST_GET_COUNT(&h2ptr->StreamList);

   *vecptr++ = h2ptr->WriteWindowSize;
   *vecptr++ = NETIO_IN_PROGRESS (h2ptr->NetIoPtr);

   FaoCheck (sizeof(FaoVector), &FaoVector, vecptr, FI_LI);
   status = FaolToBuffer (Buffer, sizeof(Buffer), &Length,
                          NetIoFao, &FaoVector);
   if (VMSnok (status) || status == SS$_BUFFEROVF)
      ErrorNoticed (rqptr, status, NULL, FI_LI);

   WatchWrite (Buffer, Length);

   WatchPeekNetIo (rqptr, h2ptr->NetIoPtr, "Http2Ptr->NetIoPtr->");

   WatchNone (false);
}

/*****************************************************************************/
/*
Peek at the supplied NETIO structure.
*/

void WatchPeekNetIo
(
REQUEST_STRUCT *rqptr,
NETIO_STRUCT *ioptr,
char *Title
)
{
   static char  NetIoFao [] =
"|\n\
!33<!AZ!> !&X\n\
!33<Channel!> !UL (!AZ)\n\
!33<QioMaxSeg!> !UL\n\
!33<BlocksRawRx!> !@SQ\n\
!33<BytesRawRx!> !@SQ\n\
!33<BlocksRawTx!> !@SQ\n\
!33<BytesRawTx!> !@SQ\n\
!33<ReadAstFunction!> !&A\n\
!33<ReadAstParam!> !&X\n\
!33<ReadCount!> !UL\n\
!33<ReadErrorCount!> !UL\n\
!33<ReadErrorStatus!> !&S\n\
!33<ReadPtr!> !&X\n\
!33<ReadSize!> !UL\n\
!33<ReadIOsb!> !&S !UL\n\
!33<VmsStatus!> !&S\n\
!33<SSHversionDigit!> 0x!2XL\n\
!33<WriteAstFunction!> !&A\n\
!33<WriteAstParam!> !&X\n\
!33<WriteCount!> !UL\n\
!33<WriteErrorCount!> !UL\n\
!33<WriteErrorStatus!> !&S\n\
!33<WriteLength!> !UL\n\
!33<WritePtr!> !&X\n\
!33<WriteLength!> !UL\n\
!33<WriteIOsb!> !&S !UL\n\
!33<ClientPtr->Lookup.HostName!> !&Z\n\
!33<ClientPtr->IpAddress!> !&I\n\
!33<ClientPtr->IpPort!> !UL\n\
!33<ClientPtr->MultiHomeIpAddress!> !&I\n";

   static char  SesolaPtrNull [] =
"|\nSesolaPtr->                       0x00000000\n";

   int  status;
   ushort  Length;
   ulong  FaoVector [48];
   ulong  *vecptr;
   char  Buffer [2048],
         DevName [64];

   /*********/
   /* begin */
   /*********/

   WatchNone (true);

   NetGetBgDevice (ioptr->Channel, DevName, sizeof(DevName));

   vecptr = FaoVector;

   *vecptr++ = Title ? Title : "ioptr->";
   *vecptr++ = ioptr;
   *vecptr++ = ioptr->Channel;
   *vecptr++ = DevName+1;
   *vecptr++ = ioptr->QioMaxSeg;
   *vecptr++ = &ioptr->BlocksRawRx;
   *vecptr++ = &ioptr->BytesRawRx;
   *vecptr++ = &ioptr->BlocksRawTx;
   *vecptr++ = &ioptr->BytesRawTx;

   *vecptr++ = ioptr->ReadAstFunction;
   *vecptr++ = ioptr->ReadAstParam;
   *vecptr++ = ioptr->ReadCount;
   *vecptr++ = ioptr->ReadErrorCount;
   *vecptr++ = ioptr->ReadErrorStatus;
   *vecptr++ = ioptr->ReadPtr;
   *vecptr++ = ioptr->ReadSize;
   *vecptr++ = ioptr->ReadIOsb.Status;
   *vecptr++ = ioptr->ReadIOsb.Count;
   *vecptr++ = ioptr->VmsStatus;
   *vecptr++ = ioptr->SSHversionDigit;

   *vecptr++ = ioptr->WriteAstFunction;
   *vecptr++ = ioptr->WriteAstParam;
   *vecptr++ = ioptr->WriteCount;
   *vecptr++ = ioptr->WriteErrorCount;
   *vecptr++ = ioptr->WriteErrorStatus;
   *vecptr++ = ioptr->WriteLength;
   *vecptr++ = ioptr->WritePtr;
   *vecptr++ = ioptr->WriteLength;
   *vecptr++ = ioptr->WriteIOsb.Status;
   *vecptr++ = ioptr->WriteIOsb.Count;

   *vecptr++ = ioptr->ClientPtr->Lookup.HostName;
   *vecptr++ = &ioptr->ClientPtr->IpAddress;
   *vecptr++ = ioptr->ClientPtr->IpPort;
   *vecptr++ = &ioptr->ClientPtr->MultiHomeIpAddress;

   FaoCheck (sizeof(FaoVector), &FaoVector, vecptr, FI_LI);
   status = FaolToBuffer (Buffer, sizeof(Buffer), &Length,
                          NetIoFao, &FaoVector);
   if (VMSnok (status) || status == SS$_BUFFEROVF)
      ErrorNoticed (rqptr, status, NULL, FI_LI);

   WatchWrite (Buffer, Length);

   if (ioptr->SesolaPtr == NULL)
      WatchWrite (SesolaPtrNull, sizeof(SesolaPtrNull)-1);
   else
      SesolaWatchPeek (rqptr, ioptr->SesolaPtr);

   WatchNone (false);
}

/*****************************************************************************/
/*
Return a report on processes' virtual memory usage.  This function blocks while
executing.
*/ 

void WatchVmZone
(
REQUEST_STRUCT *rqptr,
ulong ZoneId
)
{
   static ulong  ShowVmZoneDetail = 3;

   int  status;
   ushort  slen;
   char  buf [256];

   /*********/
   /* begin */
   /*********/

   status = lib$show_vm_zone (&ZoneId, &ShowVmZoneDetail, &WatchVmWrite, rqptr);
   if (VMSnok (status))
   {
      FaoToBuffer (buf, sizeof(buf), &slen, "LIB$SHOW_VM_ZONE !&S\n", status);
      WatchWrite (buf, slen);
   }
}

/*****************************************************************************/
/*
Action routine for lib$show_vm*() routines.
Munge the peek link from the zone name.
*/ 

int WatchVmWrite
(
struct dsc$descriptor *DscPtr,
REQUEST_STRUCT *rqptr
)
{
   int  status;
   char  *cptr, *czptr, *sptr, *zptr;
   char  buf [256];

   /*********/
   /* begin */
   /*********/

   zptr = (sptr = buf) + sizeof(buf)-2;
   czptr = (cptr = DscPtr->dsc$a_pointer) + DscPtr->dsc$w_length;
   while (cptr < czptr && sptr < zptr) *sptr++ = *cptr++;
   *sptr = '\0';
   if (sptr = strstr (buf, "WASD Request Heap "))
   {
      sptr += 18;
      if (cptr = strstr (sptr, "at="))
      {
         for (cptr += 3; isdigit(*cptr); *sptr++ = *cptr++);
         *sptr++ = '\"';
         *sptr = '\0';  
      }
   }
   for (sptr = buf; *sptr; sptr++);
   *sptr++ = '\n';
   *sptr = '\0';  
   WatchWrite (buf, sptr - buf);

   return (SS$_NORMAL);
}

/*****************************************************************************/
/*
Display the size of selected data structures.
*/ 

void WatchReportStruct (REQUEST_STRUCT *rqptr)

{
#if WATCH_MOD

   static char  ResponseFao [] =
"!25<AccountingStruct!> !6UL  (bytes)\n\
!25<ActivityGblSecStruct!> !6UL\n\
!25<AuthCacheRecordStruct!> !6UL\n\
!25<AuthConfigStruct!> !6UL\n\
!25<AuthGblSecStruct!> !6UL\n\
!25<AuthHtaRecordStruct!> !6UL\n\
!25<AuthPathRecordStruct!> !6UL\n\
!25<AuthRealmRecordStruct!> !6UL\n\
!25<BodyProcessStruct!> !6UL\n\
!25<CacheStruct!> !6UL\n\
!25<DclTaskStruct!> !6UL\n\
!25<DclScriptNameCacheStruct!> !6UL\n\
!25<DirTaskStruct!> !6UL\n\
!25<DECnetConnectStruct!> !6UL\n\
!25<DECnetTaskStruct!> !6UL\n\
!25<Http2Struct!> !6UL\n\
!25<Http2StreamStruct!> !6UL\n\
!25<Http2WriteStruct!> !6UL\n\
!25<HttpdGblSecStruct!> !6UL\n\
!25<MonRequestStruct!> !6UL\n\
!25<NetIoStruct!> !6UL\n\
!25<OdsStruct!> !6UL\n\
!25<ProxyTaskStruct!> !6UL\n\
!25<ProxyAccountingStruct!> !6UL\n\
!25<ProxyVerifyGblSecStruct!> !6UL\n\
!25<PutTaskStruct!> !6UL\n\
!25<RequestStruct!> !6UL\n\
!25<ServiceStruct!> !6UL\n\
!25<SesolaGblSecStruct!> !6UL\n\
!25<SsiStruct!> !6UL\n\
!25<StrDscStruct!> !6UL\n\
!25<UpdTaskStruct!> !6UL\n\
!25<VmStruct!> !6UL\n\
!25<WebDavTaskStruct!> !6UL\n";

   int  status;
   ulong  FaoVector [64];
   ulong  *vecptr;

   /*********/
   /* begin */
   /*********/

   if (!rqptr->RemoteUser[0])
   {
      rqptr->rqResponse.HttpStatus = 403;
      ErrorGeneral (rqptr, ErrorWatchAuthNeeded, FI_LI);
      AdminEnd (rqptr);
      return;
   }

   vecptr = FaoVector;
   *vecptr++ = sizeof(struct AccountingStruct);
   *vecptr++ = sizeof(struct ActivityGblSecStruct);
   *vecptr++ = sizeof(struct AuthCacheRecordStruct);
   *vecptr++ = sizeof(struct AuthConfigStruct);
   *vecptr++ = sizeof(struct AuthGblSecStruct);
   *vecptr++ = sizeof(struct AuthHtaRecordStruct);
   *vecptr++ = sizeof(struct AuthPathRecordStruct);
   *vecptr++ = sizeof(struct AuthRealmRecordStruct);
   *vecptr++ = sizeof(struct BodyProcessStruct);
   *vecptr++ = sizeof(struct CacheStruct);
   *vecptr++ = sizeof(struct DclTaskStruct);
   *vecptr++ = sizeof(struct DclScriptNameCacheStruct);
   *vecptr++ = sizeof(struct DirTaskStruct);
   *vecptr++ = sizeof(struct DECnetConnectStruct);
   *vecptr++ = sizeof(struct DECnetTaskStruct);
   *vecptr++ = sizeof(struct Http2Struct);
   *vecptr++ = sizeof(struct Http2StreamStruct);
   *vecptr++ = sizeof(struct Http2WriteStruct);
   *vecptr++ = sizeof(HTTPD_GBLSEC);
   *vecptr++ = sizeof(struct MonRequestStruct);
   *vecptr++ = sizeof(struct NetIoStruct);
   *vecptr++ = sizeof(struct OdsStruct);
   *vecptr++ = sizeof(struct ProxyTaskStruct);
   *vecptr++ = sizeof(PROXY_ACCOUNTING_STRUCT);
   *vecptr++ = sizeof(struct ProxyVerifyGblSecStruct);
   *vecptr++ = sizeof(struct PutTaskStruct);
   *vecptr++ = sizeof(struct RequestStruct);
   *vecptr++ = sizeof(struct ServiceStruct);
   *vecptr++ = SesolaGblSecStructSize;
   *vecptr++ = sizeof(struct SsiTaskStruct);
   *vecptr++ = sizeof(struct StrDscStruct);
   *vecptr++ = sizeof(struct UpdTaskStruct);
   *vecptr++ = sizeof(struct VmStruct);
   *vecptr++ = sizeof(struct WebDavTaskStruct);

   FaoCheck (sizeof(FaoVector), &FaoVector, vecptr, FI_LI);
   status = FaolToNet (rqptr, ResponseFao, &FaoVector);
   if (VMSnok (status)) ErrorNoticed (rqptr, status, NULL, FI_LI);

   ResponseHeader200 (rqptr, "text/plain", &rqptr->NetWriteBufferDsc);

   AdminEnd (rqptr);

#else /* WATCH_MOD */

   rqptr->rqResponse.HttpStatus = 403;
   ErrorGeneral (rqptr, ErrorWatchNoModule, FI_LI);
   AdminEnd (rqptr);

#endif /* WATCH_MOD */
}

/****************************************************************************/

