#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 1 (of 1)."
# Contents:  MANIFEST Makefile.smp mm mm/bang.mm mm/disac.mm mm/exi.mm
#   mm/sama.mm mm/samc.mm mm/sample.mm pdt pdt/bang_pdt
#   pdt/bang_pdt_out pdt/disac_pdt pdt/disac_pdt_out pdt/exi_pdt
#   pdt/exi_pdt_out pdt/sama_pdt pdt/sama_pdt_out pdt/samc_pdt
#   pdt/samc_pdt_out pdt/sample_pdt pdt/sample_pdt_out src src/evap.c
#   src/evap.h src/evap.pl src/evap.tcl src/sama.c src/sama.pl
#   src/sama.tcl src/sample.c src/sample.pl src/sample.tcl
#   src/sample1.c src/sample1.pl src/sample2.c
# Wrapped by lusol@Turkey.CC.Lehigh.EDU on Thu Jun  2 11:37:27 1994
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'MANIFEST' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'MANIFEST'\"
else
echo shar: Extracting \"'MANIFEST'\" \(1230 characters\)
sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
X   File Name		Archive #	Description
X-----------------------------------------------------------
X MANIFEST                   1	This shipping list
X Makefile.smp               1	
X mm                         1	
X mm/bang.mm                 1	
X mm/disac.mm                1	
X mm/exi.mm                  1	
X mm/sama.mm                 1	
X mm/samc.mm                 1	
X mm/sample.mm               1	
X pdt                        1	
X pdt/bang_pdt               1	
X pdt/bang_pdt_out           1	
X pdt/disac_pdt              1	
X pdt/disac_pdt_out          1	
X pdt/exi_pdt                1	
X pdt/exi_pdt_out            1	
X pdt/sama_pdt               1	
X pdt/sama_pdt_out           1	
X pdt/samc_pdt               1	
X pdt/samc_pdt_out           1	
X pdt/sample_pdt             1	
X pdt/sample_pdt_out         1	
X src                        1	
X src/evap.c                 1	
X src/evap.h                 1	
X src/evap.pl                1	
X src/evap.tcl               1	
X src/sama.c                 1	
X src/sama.pl                1	
X src/sama.tcl               1	
X src/sample.c               1	
X src/sample.pl              1	
X src/sample.tcl             1	
X src/sample1.c              1	
X src/sample1.pl             1	
X src/sample2.c              1	
END_OF_FILE
if test 1230 -ne `wc -c <'MANIFEST'`; then
    echo shar: \"'MANIFEST'\" unpacked with wrong size!
fi
# end of 'MANIFEST'
fi
if test -f 'Makefile.smp' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Makefile.smp'\"
else
echo shar: Extracting \"'Makefile.smp'\" \(420 characters\)
sed "s/^X//" >'Makefile.smp' <<'END_OF_FILE'
XCC=gcc
X
Xall:
X	ar rcv ./libevapmm.a mm/*.mm pdt/bang_pdt pdt/disac_pdt
X	${CC} -c -DP_EVAP_MM_PATH=\"./libevapmm.a\" src/evap.c
X	${CC} -o sample_c evap.o src/sample.c
X	${CC} -o sample1_c evap.o src/sample1.c
X	${CC} -o sample2_c evap.o src/sample2.c
X	cp src/sample.pl sample_pl
X	cp src/sample1.pl sample1_pl
X	cp src/sample.tcl sample_tcl
X	${CC} -o sama_c evap.o src/sama.c
X	cp src/sama.pl sama_pl
X	cp src/sama.tcl sama_tcl
END_OF_FILE
if test 420 -ne `wc -c <'Makefile.smp'`; then
    echo shar: \"'Makefile.smp'\" unpacked with wrong size!
fi
# end of 'Makefile.smp'
fi
if test ! -d 'mm' ; then
    echo shar: Creating directory \"'mm'\"
    mkdir 'mm'
fi
if test -f 'mm/bang.mm' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'mm/bang.mm'\"
else
echo shar: Extracting \"'mm/bang.mm'\" \(215 characters\)
sed "s/^X//" >'mm/bang.mm' <<'END_OF_FILE'
X!
X
X        Issue one or more commands to the shell.  If the SHELL environment
X        variable is not defined or is empty, then /bin/sh is used.
X
X
X          Examples:
X
X            !date
X            !del *.o; ls -al
END_OF_FILE
if test 215 -ne `wc -c <'mm/bang.mm'`; then
    echo shar: \"'mm/bang.mm'\" unpacked with wrong size!
fi
# end of 'mm/bang.mm'
fi
if test -f 'mm/disac.mm' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'mm/disac.mm'\"
else
echo shar: Extracting \"'mm/disac.mm'\" \(363 characters\)
sed "s/^X//" >'mm/disac.mm' <<'END_OF_FILE'
Xdisplay_application_commands, disac
X
X        Displays a list of legal commands for this application.
X
X          Examples:
X
X            disac              # the `brief' display
X            disac -do f        # the `full' display
X.display_option
X        Specifies the level of output desired.
X.output
X        Specifies the name of the file to write information to.
END_OF_FILE
if test 363 -ne `wc -c <'mm/disac.mm'`; then
    echo shar: \"'mm/disac.mm'\" unpacked with wrong size!
fi
# end of 'mm/disac.mm'
fi
if test -f 'mm/exi.mm' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'mm/exi.mm'\"
else
echo shar: Extracting \"'mm/exi.mm'\" \(47 characters\)
sed "s/^X//" >'mm/exi.mm' <<'END_OF_FILE'
Xexit, exi
X
X	Ends a sample_application session.
END_OF_FILE
if test 47 -ne `wc -c <'mm/exi.mm'`; then
    echo shar: \"'mm/exi.mm'\" unpacked with wrong size!
fi
chmod +x 'mm/exi.mm'
# end of 'mm/exi.mm'
fi
if test -f 'mm/sama.mm' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'mm/sama.mm'\"
else
echo shar: Extracting \"'mm/sama.mm'\" \(547 characters\)
sed "s/^X//" >'mm/sama.mm' <<'END_OF_FILE'
Xsample_application, sama
X
X	`sample_application' shows how to embed evaluate_parameters
X	into your application.  Therefore, all the benefits of using
X        evaluate_parameter on the command line apply to your
X	application's command processing as well.
X
X	Once inside the application, use `display_application_commands'
X	to see a list of valid commands for this application.
X
X	For each command, you can specify `-?', `-brief_help' or
X	`-full_help' to see command and parameter help information.
X.input
X        Specifies the name of the input file.
END_OF_FILE
if test 547 -ne `wc -c <'mm/sama.mm'`; then
    echo shar: \"'mm/sama.mm'\" unpacked with wrong size!
fi
chmod +x 'mm/sama.mm'
# end of 'mm/sama.mm'
fi
if test -f 'mm/samc.mm' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'mm/samc.mm'\"
else
echo shar: Extracting \"'mm/samc.mm'\" \(266 characters\)
sed "s/^X//" >'mm/samc.mm' <<'END_OF_FILE'
Xsample_command, sc
X
X	This is a simple command that demonstrates how evaluate_parameters
X	can be embedded into your application.  
X
X	  Examples:
X 
X	    sample_command -full_help
X	    samc -id "any 'ol string" red blue green
X.id
X	The `id' parameter is just a string.	
END_OF_FILE
if test 266 -ne `wc -c <'mm/samc.mm'`; then
    echo shar: \"'mm/samc.mm'\" unpacked with wrong size!
fi
chmod +x 'mm/samc.mm'
# end of 'mm/samc.mm'
fi
if test -f 'mm/sample.mm' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'mm/sample.mm'\"
else
echo shar: Extracting \"'mm/sample.mm'\" \(2390 characters\)
sed "s/^X//" >'mm/sample.mm' <<'END_OF_FILE'
Xsample
X
X	A sample program demonstrating typical evaluate_parameters
X	usage.
X
X	Examples:
X
X	  sample
X	  sample -usage_help
X	  sample -?
X	  sample -full_help
X	  sample -mui 1234
X.verbose
X	A 'switch' type parameter emulates a typical standalone
X	switch. If the switch is specified evaluate_parameters
X	returns a '1'.
X.command
X	A 'string' type parameter is just a list of characters,
X	which must be quoted if it contains whitespace. 
X	NOTE:  for this parameter you can also create and
X	initialize the environment variable D_SAMPLE_COMMAND to
X	override the standard default value for this command
X	line parameter.  All types except 'switch' may have a
X	default environment variable for easy user customization.
X.scale_factor
X	A 'real' type parameter must be a real number that may
X	contain a leading sign, a decimal point and an exponent.
X.millisecond_update_interval
X	An 'integer' type parameter must consist of all digits
X	with an optional leading sign.  NOTE: this parameter's
X	default value is '$required', meaning that
X	evaluate_parameters ensures that this parameter is
X	specified and given a valid value.  All types except
X	'switch' may have a default value of '$required'.
X.ignore_output_file_column_one
X	A 'boolean' type parameter may be TRUE/YES/ON/1 or
X	FALSE/NO/OFF/0, either upper or lower case.  If TRUE,
X	evaluate_parameters returns a value of '1', else '0'.
X.output
X	A 'file' type parameter expects a filename.  For Unix
X	$HOME and ~ are expanded.  For evap/Perl 'stdin' and
X	'stdout' are converted to '-' and '>-' so they can be
X	used in a Perl 'open' function.
X.queue
X	A 'key' type parameter enumerates valid values.  Only the
X	specified keywords can be entered on the command line.
X.destination
X	An 'application' type parameter is not type-checked in
X	any way - the treatment of this type of parameter is
X	application specific.  NOTE:  this parameter's default
X	value is enclosed in grave accents (or "backticks").
X	evaluate_parameters executes the command and uses it's
X	standard output as the default value for the parameter.
X.tty
X	A 'name' type parameter is similar to a string except
X	that embedded white-space is not allowed.  NOTE: this
X	parameter is also a LIST, meaning that it can be
X	specified multiple times and that each value is pushed
X	onto a LIST of variable values.  In general you should
X	quote all list elements.  All types except 'switch' may
X	be 'list of'.
END_OF_FILE
if test 2390 -ne `wc -c <'mm/sample.mm'`; then
    echo shar: \"'mm/sample.mm'\" unpacked with wrong size!
fi
# end of 'mm/sample.mm'
fi
if test ! -d 'pdt' ; then
    echo shar: Creating directory \"'pdt'\"
    mkdir 'pdt'
fi
if test -f 'pdt/bang_pdt' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'pdt/bang_pdt'\"
else
echo shar: Extracting \"'pdt/bang_pdt'\" \(114 characters\)
sed "s/^X//" >'pdt/bang_pdt' <<'END_OF_FILE'
X# $Id: bang_pdt,v 2.1.0.0 1994/05/13 13:18:48 lusol Exp $
XPDT (./libevapmm.a/bang.mm) !
XPDTEND optional_file_list
END_OF_FILE
if test 114 -ne `wc -c <'pdt/bang_pdt'`; then
    echo shar: \"'pdt/bang_pdt'\" unpacked with wrong size!
fi
# end of 'pdt/bang_pdt'
fi
if test -f 'pdt/bang_pdt_out' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'pdt/bang_pdt_out'\"
else
echo shar: Extracting \"'pdt/bang_pdt_out'\" \(710 characters\)
sed "s/^X//" >'pdt/bang_pdt_out' <<'END_OF_FILE'
X/*
XPDT (./libevapmm.a/bang.mm) !
XPDTEND optional_file_list
X*/
X
X/*
XDefine P_EVAP_EXTERN in separately compiled modules!
XThis will declare pvt as an external so you can reference
Xparameter values.  No storage is allocated in this case.
X*/
X#ifndef P_EVAP_EXTERN
X
Xstruct pdt_header bang_pkg_pdt = {
X  "PDT Version 2.0 for U*X",
X  "./libevapmm.a/bang.mm",
X  "optional_file_list"
X};
X
Xevap_Parameter_Value bang_pkg_pvt[] = {
X
X  {"help", "?",
X   FALSE, TRUE, P_TYPE_SWITCH,
X   NULL,
X   "FALSE",
X   ", usage_help, full_help: Display Command Information",
X   0,
X   NULL,
X   NULL},
X
X  {NULL}  /* end of parameters */
X
X};
X#else
Xextern evap_Parameter_Value bang_pkg_pvt[];
X#endif
X
X#define bang_pkg_P_NUMBER_OF_PARAMETERS 1
END_OF_FILE
if test 710 -ne `wc -c <'pdt/bang_pdt_out'`; then
    echo shar: \"'pdt/bang_pdt_out'\" unpacked with wrong size!
fi
# end of 'pdt/bang_pdt_out'
fi
if test -f 'pdt/disac_pdt' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'pdt/disac_pdt'\"
else
echo shar: Extracting \"'pdt/disac_pdt'\" \(195 characters\)
sed "s/^X//" >'pdt/disac_pdt' <<'END_OF_FILE'
X# $Id: disac_pdt,v 2.1.0.0 1994/05/13 13:27:06 lusol Exp $
XPDT (./libevapmm.a/disac.mm) disac
X  display_option, do: key brief, full, keyend = brief
X  output, o: file = stdout
XPDTEND no_file_list
END_OF_FILE
if test 195 -ne `wc -c <'pdt/disac_pdt'`; then
    echo shar: \"'pdt/disac_pdt'\" unpacked with wrong size!
fi
# end of 'pdt/disac_pdt'
fi
if test -f 'pdt/disac_pdt_out' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'pdt/disac_pdt_out'\"
else
echo shar: Extracting \"'pdt/disac_pdt_out'\" \(1137 characters\)
sed "s/^X//" >'pdt/disac_pdt_out' <<'END_OF_FILE'
X/*
XPDT (./libevapmm.a/disac.mm) disac
X  display_option, do: key brief, full, keyend = brief
X  output, o: file = stdout
XPDTEND no_file_list
X*/
X
X/*
XDefine P_EVAP_EXTERN in separately compiled modules!
XThis will declare pvt as an external so you can reference
Xparameter values.  No storage is allocated in this case.
X*/
X#ifndef P_EVAP_EXTERN
X
Xstruct pdt_header disac_pkg_pdt = {
X  "PDT Version 2.0 for U*X",
X  "./libevapmm.a/disac.mm",
X  "no_file_list"
X};
X
Xevap_Parameter_Value disac_pkg_pvt[] = {
X
X  {"help", "?",
X   FALSE, TRUE, P_TYPE_SWITCH,
X   NULL,
X   "FALSE",
X   ", usage_help, full_help: Display Command Information",
X   0,
X   NULL,
X   NULL},
X
X  {"display_option", "do",
X   FALSE, TRUE, P_TYPE_KEY,
X   NULL,
X   "brief",
X   ": key brief, full, keyend = brief",
X   0,
X   NULL,
X   "brief",
X   "full",
X   NULL},
X
X  {"output", "o",
X   FALSE, TRUE, P_TYPE_FILE,
X   NULL,
X   "stdout",
X   ": file = stdout",
X   0,
X   NULL,
X   NULL},
X
X  {NULL}  /* end of parameters */
X
X};
X#else
Xextern evap_Parameter_Value disac_pkg_pvt[];
X#endif
X
X#define disac_pkg_P_display_option 1
X#define disac_pkg_P_output 2
X#define disac_pkg_P_NUMBER_OF_PARAMETERS 3
END_OF_FILE
if test 1137 -ne `wc -c <'pdt/disac_pdt_out'`; then
    echo shar: \"'pdt/disac_pdt_out'\" unpacked with wrong size!
fi
# end of 'pdt/disac_pdt_out'
fi
if test -f 'pdt/exi_pdt' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'pdt/exi_pdt'\"
else
echo shar: Extracting \"'pdt/exi_pdt'\" \(109 characters\)
sed "s/^X//" >'pdt/exi_pdt' <<'END_OF_FILE'
X# $Id: exi_pdt,v 2.1.0.0 1994/05/13 13:27:20 lusol Exp $
XPDT (./libevapmm.a/exi.mm) exit
XPDTEND no_file_list
END_OF_FILE
if test 109 -ne `wc -c <'pdt/exi_pdt'`; then
    echo shar: \"'pdt/exi_pdt'\" unpacked with wrong size!
fi
# end of 'pdt/exi_pdt'
fi
if test -f 'pdt/exi_pdt_out' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'pdt/exi_pdt_out'\"
else
echo shar: Extracting \"'pdt/exi_pdt_out'\" \(695 characters\)
sed "s/^X//" >'pdt/exi_pdt_out' <<'END_OF_FILE'
X/*
XPDT (./libevapmm.a/exi.mm) exit
XPDTEND no_file_list
X*/
X
X/*
XDefine P_EVAP_EXTERN in separately compiled modules!
XThis will declare pvt as an external so you can reference
Xparameter values.  No storage is allocated in this case.
X*/
X#ifndef P_EVAP_EXTERN
X
Xstruct pdt_header exi_pkg_pdt = {
X  "PDT Version 2.0 for U*X",
X  "./libevapmm.a/exi.mm",
X  "no_file_list"
X};
X
Xevap_Parameter_Value exi_pkg_pvt[] = {
X
X  {"help", "?",
X   FALSE, TRUE, P_TYPE_SWITCH,
X   NULL,
X   "FALSE",
X   ", usage_help, full_help: Display Command Information",
X   0,
X   NULL,
X   NULL},
X
X  {NULL}  /* end of parameters */
X
X};
X#else
Xextern evap_Parameter_Value exi_pkg_pvt[];
X#endif
X
X#define exi_pkg_P_NUMBER_OF_PARAMETERS 1
END_OF_FILE
if test 695 -ne `wc -c <'pdt/exi_pdt_out'`; then
    echo shar: \"'pdt/exi_pdt_out'\" unpacked with wrong size!
fi
# end of 'pdt/exi_pdt_out'
fi
if test -f 'pdt/sama_pdt' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'pdt/sama_pdt'\"
else
echo shar: Extracting \"'pdt/sama_pdt'\" \(156 characters\)
sed "s/^X//" >'pdt/sama_pdt' <<'END_OF_FILE'
X# $Id: sama_pdt,v 2.1.0.0 1994/05/13 13:27:27 lusol Exp $
XPDT (./libevapmm.a/sama.mm) sample_application, sama
X  input, i: file = stdin
XPDTEND no_file_list
END_OF_FILE
if test 156 -ne `wc -c <'pdt/sama_pdt'`; then
    echo shar: \"'pdt/sama_pdt'\" unpacked with wrong size!
fi
# end of 'pdt/sama_pdt'
fi
if test -f 'pdt/sama_pdt_out' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'pdt/sama_pdt_out'\"
else
echo shar: Extracting \"'pdt/sama_pdt_out'\" \(842 characters\)
sed "s/^X//" >'pdt/sama_pdt_out' <<'END_OF_FILE'
X/*
XPDT (./libevapmm.a/sama.mm) sample_application, sama
X  input, i: file = stdin
XPDTEND no_file_list
X*/
X
X/*
XDefine P_EVAP_EXTERN in separately compiled modules!
XThis will declare pvt as an external so you can reference
Xparameter values.  No storage is allocated in this case.
X*/
X#ifndef P_EVAP_EXTERN
X
Xstruct pdt_header pdt = {
X  "PDT Version 2.0 for U*X",
X  "./libevapmm.a/sama.mm",
X  "no_file_list"
X};
X
Xevap_Parameter_Value pvt[] = {
X
X  {"help", "?",
X   FALSE, TRUE, P_TYPE_SWITCH,
X   NULL,
X   "FALSE",
X   ", usage_help, full_help: Display Command Information",
X   0,
X   NULL,
X   NULL},
X
X  {"input", "i",
X   FALSE, TRUE, P_TYPE_FILE,
X   NULL,
X   "stdin",
X   ": file = stdin",
X   0,
X   NULL,
X   NULL},
X
X  {NULL}  /* end of parameters */
X
X};
X#else
Xextern evap_Parameter_Value pvt[];
X#endif
X
X#define P_input 1
X#define P_NUMBER_OF_PARAMETERS 2
END_OF_FILE
if test 842 -ne `wc -c <'pdt/sama_pdt_out'`; then
    echo shar: \"'pdt/sama_pdt_out'\" unpacked with wrong size!
fi
# end of 'pdt/sama_pdt_out'
fi
if test -f 'pdt/samc_pdt' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'pdt/samc_pdt'\"
else
echo shar: Extracting \"'pdt/samc_pdt'\" \(162 characters\)
sed "s/^X//" >'pdt/samc_pdt' <<'END_OF_FILE'
X# $Id: samc_pdt,v 2.1.0.0 1994/05/13 13:27:37 lusol Exp $
XPDT (./libevapmm.a/samc.mm) sample_command
X  id, i: string = "sample_command"
XPDTEND optional_file_list
END_OF_FILE
if test 162 -ne `wc -c <'pdt/samc_pdt'`; then
    echo shar: \"'pdt/samc_pdt'\" unpacked with wrong size!
fi
# end of 'pdt/samc_pdt'
fi
if test -f 'pdt/samc_pdt_out' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'pdt/samc_pdt_out'\"
else
echo shar: Extracting \"'pdt/samc_pdt_out'\" \(919 characters\)
sed "s/^X//" >'pdt/samc_pdt_out' <<'END_OF_FILE'
X/*
XPDT (./libevapmm.a/samc.mm) sample_command
X  id, i: string = "sample_command"
XPDTEND optional_file_list
X*/
X
X/*
XDefine P_EVAP_EXTERN in separately compiled modules!
XThis will declare pvt as an external so you can reference
Xparameter values.  No storage is allocated in this case.
X*/
X#ifndef P_EVAP_EXTERN
X
Xstruct pdt_header samc_pkg_pdt = {
X  "PDT Version 2.0 for U*X",
X  "./libevapmm.a/samc.mm",
X  "optional_file_list"
X};
X
Xevap_Parameter_Value samc_pkg_pvt[] = {
X
X  {"help", "?",
X   FALSE, TRUE, P_TYPE_SWITCH,
X   NULL,
X   "FALSE",
X   ", usage_help, full_help: Display Command Information",
X   0,
X   NULL,
X   NULL},
X
X  {"id", "i",
X   FALSE, TRUE, P_TYPE_STRING,
X   NULL,
X   "sample_command",
X   ": string = \"sample_command\"",
X   0,
X   NULL,
X   NULL},
X
X  {NULL}  /* end of parameters */
X
X};
X#else
Xextern evap_Parameter_Value samc_pkg_pvt[];
X#endif
X
X#define samc_pkg_P_id 1
X#define samc_pkg_P_NUMBER_OF_PARAMETERS 2
END_OF_FILE
if test 919 -ne `wc -c <'pdt/samc_pdt_out'`; then
    echo shar: \"'pdt/samc_pdt_out'\" unpacked with wrong size!
fi
# end of 'pdt/samc_pdt_out'
fi
if test -f 'pdt/sample_pdt' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'pdt/sample_pdt'\"
else
echo shar: Extracting \"'pdt/sample_pdt'\" \(552 characters\)
sed "s/^X//" >'pdt/sample_pdt' <<'END_OF_FILE'
X# $Id: sample_pdt,v 2.1.0.2 1994/05/13 19:03:14 lusol Exp $
XPDT (./libevapmm.a/sample.mm) sample
X  verbose, v: switch
X  command, c: string = D_SAMPLE_COMMAND, "ps -el"
X  scale_factor, sf: real = 1.2340896e-1
X  millisecond_update_interval, mui: integer = $required
X  ignore_output_file_column_one, iofco: boolean = TRUE
X  output, o: file = stdout
X  queue, q: key plotter, postscript, text, printer, keyend = printer
X  destination, d: application = `hostname`
X  tty, t: list of name = ("/dev/console", "/dev/tty0", "/dev/tty1")
XPDTEND optional_file_list
END_OF_FILE
if test 552 -ne `wc -c <'pdt/sample_pdt'`; then
    echo shar: \"'pdt/sample_pdt'\" unpacked with wrong size!
fi
chmod +x 'pdt/sample_pdt'
# end of 'pdt/sample_pdt'
fi
if test -f 'pdt/sample_pdt_out' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'pdt/sample_pdt_out'\"
else
echo shar: Extracting \"'pdt/sample_pdt_out'\" \(2780 characters\)
sed "s/^X//" >'pdt/sample_pdt_out' <<'END_OF_FILE'
X/*
XPDT (./libevapmm.a/sample.mm) sample
X  verbose, v: switch
X  command, c: string = D_SAMPLE_COMMAND, "ps -el"
X  scale_factor, sf: real = 1.2340896e-1
X  millisecond_update_interval, mui: integer = $required
X  ignore_output_file_column_one, iofco: boolean = TRUE
X  output, o: file = stdout
X  queue, q: key plotter, postscript, text, printer, keyend = printer
X  destination, d: application = `hostname`
X  tty, t: list of name = ("/dev/console", "/dev/tty0", "/dev/tty1")
XPDTEND optional_file_list
X*/
X
X/*
XDefine P_EVAP_EXTERN in separately compiled modules!
XThis will declare pvt as an external so you can reference
Xparameter values.  No storage is allocated in this case.
X*/
X#ifndef P_EVAP_EXTERN
X
Xstruct pdt_header pdt = {
X  "PDT Version 2.0 for U*X",
X  "./libevapmm.a/sample.mm",
X  "optional_file_list"
X};
X
Xevap_List_Value P_LIST_tty[] = {
X  {"/dev/console"},
X  {"/dev/tty0"},
X  {"/dev/tty1"},
X  NULL,
X};
X
Xevap_Parameter_Value pvt[] = {
X
X  {"help", "?",
X   FALSE, TRUE, P_TYPE_SWITCH,
X   NULL,
X   "FALSE",
X   ", usage_help, full_help: Display Command Information",
X   0,
X   NULL,
X   NULL},
X
X  {"verbose", "v",
X   FALSE, TRUE, P_TYPE_SWITCH,
X   NULL,
X   "FALSE",
X   ": switch",
X   0,
X   NULL,
X   NULL},
X
X  {"command", "c",
X   FALSE, TRUE, P_TYPE_STRING,
X   "D_SAMPLE_COMMAND",
X   "ps -el",
X   ": string = D_SAMPLE_COMMAND, \"ps -el\"",
X   0,
X   NULL,
X   NULL},
X
X  {"scale_factor", "sf",
X   FALSE, TRUE, P_TYPE_REAL,
X   NULL,
X   "1.2340896e-1",
X   ": real = 1.2340896e-1",
X   0,
X   NULL,
X   NULL},
X
X  {"millisecond_update_interval", "mui",
X   FALSE, TRUE, P_TYPE_INTEGER,
X   NULL,
X   "$required",
X   ": integer = $required",
X   0,
X   NULL,
X   NULL},
X
X  {"ignore_output_file_column_one", "iofco",
X   FALSE, TRUE, P_TYPE_BOOLEAN,
X   NULL,
X   "TRUE",
X   ": boolean = TRUE",
X   0,
X   NULL,
X   NULL},
X
X  {"output", "o",
X   FALSE, TRUE, P_TYPE_FILE,
X   NULL,
X   "stdout",
X   ": file = stdout",
X   0,
X   NULL,
X   NULL},
X
X  {"queue", "q",
X   FALSE, TRUE, P_TYPE_KEY,
X   NULL,
X   "printer",
X   ": key plotter, postscript, text, printer, keyend = printer",
X   0,
X   NULL,
X   "plotter",
X   "postscript",
X   "text",
X   "printer",
X   NULL},
X
X  {"destination", "d",
X   FALSE, TRUE, P_TYPE_APPLICATION,
X   NULL,
X   "`hostname`",
X   ": application = `hostname`",
X   0,
X   NULL,
X   NULL},
X
X  {"tty", "t",
X   FALSE, TRUE, P_TYPE_NAME,
X   NULL,
X   "",
X   ": list of name = (\"/dev/console\", \"/dev/tty0\", \"/dev/tty1\")",
X   1,
X   P_LIST_tty,
X   NULL},
X
X  {NULL}  /* end of parameters */
X
X};
X#else
Xextern evap_Parameter_Value pvt[];
X#endif
X
X#define P_verbose 1
X#define P_command 2
X#define P_scale_factor 3
X#define P_millisecond_update_interval 4
X#define P_ignore_output_file_column_one 5
X#define P_output 6
X#define P_queue 7
X#define P_destination 8
X#define P_tty 9
X#define P_NUMBER_OF_PARAMETERS 10
END_OF_FILE
if test 2780 -ne `wc -c <'pdt/sample_pdt_out'`; then
    echo shar: \"'pdt/sample_pdt_out'\" unpacked with wrong size!
fi
# end of 'pdt/sample_pdt_out'
fi
if test ! -d 'src' ; then
    echo shar: Creating directory \"'src'\"
    mkdir 'src'
fi
if test -f 'src/evap.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/evap.c'\"
else
echo shar: Extracting \"'src/evap.c'\" \(41573 characters\)
sed "s/^X//" >'src/evap.c' <<'END_OF_FILE'
X
X#ifdef _AIX
X#define _POSIX_SOURCE
X#define _ALL_SOURCE
X#endif
X
X#ifdef __hpux
X#define _POSIX_SOURCE
X#define _INCLUDE_XOPEN_SOURCE
X#endif
X
X#include <stdio.h>
X#include <ctype.h>
X#include <malloc.h>
X#include <sys/types.h>
X#include <pwd.h>
X#include <string.h>
X#include <stdlib.h>
X#include <unistd.h>
X#include "evap.h"
X#include "../pdt/bang_pdt_out"
X#include "../pdt/disac_pdt_out"
X
Xstatic char *rcsid = {"@@(#)$Id: evap.c,v 2.1.0.5 1994/05/31 14:55:57 lusol Exp $"};
X
Xchar   *evap_Type_Strings[P_MAXIMUM_TYPES] = {
X  "switch",
X  "string",
X  "real",
X  "integer",
X  "boolean",
X  "file",
X  "key",
X  "application",
X  "name",
X};				/* indexed by type ordinal */
X
X/* Help Hooks that provide some customization of evap's help output. */
X
Xchar   *evap_X11 = NULL;	/* see evap.c(2), section `Interface to X11 XtAppInitialize' */
Xchar   *evap_Help_Hooks[P_MAXIMUM_HELP_HOOKS] = {
X  " file(s)\n",
X  " [file(s)]\n",
X  "\n",
X  "\nfile(s) required by this command\n\n",
X  "\n[file(s)] optionally required by this command\n\n",
X  "\n",
X  "Trailing file name(s) required.\n",
X  "Trailing file name(s) not permitted.\n",
X};				/* indexed by Help Hook ordinal */
Xint    evap_embed = 0;		/* 1 IFF embedding evaluate_parameters */
Xchar   evap_shell[514];		/* user's preferred shell */
Xevap_Application_Command *evap_commands; /* evap_pac's combined command list */
X
X
Xint    evap_display_message_module(char *message_module_name,
X				   char *parameter_help[],
X				   int *parameter_help_count,
X				   FILE *PAGER);
Xvoid   evap_display_usage(char *command,
X			  struct pdt_header pdt,
X			  evap_Parameter_Value pvt[],
X			  FILE *PAGER);
Xvoid   evap_display_which(char *command,
X			  FILE *PAGER);
Xvoid   evap_type_conversion(evap_Parameter_Value *pvte);
Xint    evap_type_verification(evap_Parameter_Value *pvte,
X			      int *error);
X
X
Xint    evap(int *argc,
X	    char **argv[],
X	    struct pdt_header pdt,
X	    void *check_parameters_function,
X	    evap_Parameter_Value *pvt)
X
X/*
X
X  Step through the parameters, checking if they are valid, and if they
X  require a value that one is specified and that it is valid. Note that
X  it changes argv and argc to point to file names that appear AFTER all
X  the parameters.  pvt is modified with the new parameter values.
X  Because argv[0], the program name, is no longer available after calling
X  evaluate_parameters, stuff it into pvt[P_HELP].unconverted_value.
X 
X  If a help message module is specified in the PDT header, then search the
X  message module archive file libevapmm.a for the help text and display it
X  if the -help switch is specified on the command line.  If the message
X  module cannot be located then generate a short Usage: report.
X 
X  The check_parameters_function is currently unused and should be NULL.
X
X 
X  For related information see the evap/C header file evap.h.  Complete
X  help can be found in the man pages evap(2), evap.c(2), evap.pl(2),
X  evap.tcl(2) and evap_pac(2).
X    
X 
X  Copyright (C) 1990 - 1994 by Stephen O. Lidie and Lehigh University.
X			 All rights reserved.
X
X  lusol@Lehigh.EDU
X
X
X			   Revision History
X
X  Stephen.O.Lidie@CDC1.CC.Lehigh.EDU, LUCC, 90/12/28. (PDT version 1.0)
X    . Original release - evaluate_parameters and generate_pdt.
X
X  Stephen.O.Lidie@CDC1.CC.Lehigh.EDU, LUCC, 91/07/01. (PDT version 1.1)
X    . Minor bug fixes in generate_pdt.
X    . Add support for the name type.
X    . Add the new command display_command_information (disci).
X    . Add support for help message modules.
X    . Add the new command add_message_modules (addmm).
X    . Minor bug fix in evaluate_parameters handling of key type.
X    . Improve evaluate_parameters error messages.
X    . Provide an install script for VX/VE, EP/IX, SunOS, Stardent and AIX.
X    . Add support for PDTEND file_list option.
X    . Add -qualifier parameter to generate_pdt so that the PDT/PVT names
X      can be qualified for 'multiple entry point' programs.  Similar to
X      COMPASS QUAL blocks.
X
X  Stephen.O.Lidie@CDC1.CC.Lehigh.EDU, LUCC, 91/08/01. (PDT version 1.1)
X    . Allow -- to end command line parameters.
X    . Don't print the colon after the type for disci; generate_pdt supplies
X      it for us.  This allows the description to be better customized.
X    . When type-checking keywords, first search for an exact match (as is
X      currently done) and if that fails, search for a substring match.
X    . In a similar manner, when the exact match for a command line parameter
X      fails, try a substring match (but not for the alias).
X    . If the evaluate_parameters message module is missing, generate a short
X      Usage: display.
X    . If no parameter alias, use the full spelling for Usage: and -help.
X
X  Stephen.O.Lidie@CDC1.CC.Lehigh.EDU, LUCC, 91/12/02. (PDT version 1.2)
X    . Do the 'which' function internally rather than using slow system.
X    . exec the ar command to display the message module rather than
X      using slow system.
X    . If an environment variable is specified as a default value for a
X      parameter, the variable is defined and the parameter is not 
X      specified, use the value of the environment variable for the
X      parameter's value.
X 
X  lusol@Lehigh.EDU 93/01/02. (PDT version 1.2)  Version 1.4
X    . Evaluate parameter values within grave accents, or
X      backticks.  Add -usage_help to display_command_information.
X      Add support for parameter descriptions in the message module
X      file for -full_help.
X 
X  lusol@Lehigh.EDU 93/02/19. (PDT version 1.2)  Version 1.5
X    . Document the interface to X11 Release 4 XGetDefault.
X    . For parameters of type File expand $HOME and ~.
X    . Make evap.c more ANSI-like - define function prototypes and use returns
X      consistently.
X    . Make evap.h more ANSI-like - replace the #if .. #endif surrounding the 
X      evaluate_parameters documentation with a C comment construct.  However,
X      all the C comments embedded in the sample code are now PASCAL comments
X      of the form {* ... *}.  Ugh, but that's the price I had to pay to make
X      the code portable!
X 
X  lusol@Lehigh.EDU 93/05/18. (PDT version 1.2)  Version 1.6
X    . Expose the -full_help command line parameter in evaluate_parameters.
X    . For type boolean parameters allow TRUE/YES/1 and FALSE/NO/0, either
X      upper or lower case.
X    . These changes make evaluate_parameters for C conform, as much as
X      possible, to the initial release of evaluate_parameters for Perl.
X 
X  lusol@Lehigh.EDU 93/08/20. (PDT version 2.0)  Version 2.0
X    . Convert evap/C and friends to ANSI C.
X    . Expose the -usage_help command line parameter in evaluate_parameters.
X    . Full support for 'list of' command line parameters in evap/C and
X      generate_pdt.  The PDT list syntax is identical to Perl's list syntax,
X      and, of course, to evap/Perl.
X    . PDT lines beginning with # are comments.
X 
X  lusol@Lehigh.EDU 94/03/29. (PDT version 2.0)  Version 2.1
X    . Replace help alias `disci' with `?'.
X    . Add ON/OFF as valid boolean values.
X    . Don't type-check unspecified and empty default PDT values.
X    . Move documentation from evap.h to the man page evap.c(2).
X    . Obey MANPAGER (or PAGER) environment variable and page help output.
X      Default pager is `more'.  Since this changes the behavior of
X      evaluate_parameters, the boolean environment variable D_EVAP_DO_PAGE
X      can be set to FALSE/NO/OFF/0, any case, to disable this automatic
X      paging.
X    . Implement Help Hooks to customize evap's help output.
X    . Use only a command's basename for -usage_help.
X    . To use evaluate_parameters as an embedded command line processor call
X      the internal routine `evap_pac'.
X
X*/
X{
X  char   *arg;
X  char   *command;
X  char   *default_variable;
X  int    error;
X  short  full_help;
X  short  usage_help;
X  char   *getenv();
X  int    i, j, entry;
X  char   *parameter_help[P_MAX_PARAMETER_HELP];
X  int    parameter_help_count;
X  char   *parameter_help_name;
X  evap_List_Value *lve;
X  FILE   *PAGER = NULL;
X  char   *pager;
X  extern int evap_embed;
X  static int opvt_count = 0;
X  int    registered;
X  
X  static struct {
X    char *MM;			/* register by Message Module name */
X    evap_Parameter_Value *pvt;	/* pointer to original pristine PVT  */
X  } opvt[P_MAX_EMBEDDED_COMMANDS]; /* maximum count of embedded PVTs to keep */
X
X  error = 0;			/* no errors */
X  full_help = FALSE;		/* assume standard -help (brief) help */
X  usage_help = FALSE;		/* assume standard -help (brief) help */
X
X  if (strncmp(pdt.version, "PDT Version 2.0 ", 16) < 0) {
X    fprintf( stderr, "Error - evaluate_parameters has detected an illegal PDT.\n" );
X    exit( 1 );
X  }
X
X  if (check_parameters_function != NULL) {
X    fprintf( stderr, "Informative - check_parameters_function is not supported.\n" );
X  }
X
X  if ( evap_embed ) {
X    /*
X       Initialize for a new call in case evaluate_parameters is embedded in an application.
X       Register new PVT's if required so subsequent embedded calls can restore the incoming
X       PVT to it's pristine state.
X    */
X    registered = 0;
X    for ( i=0; i<opvt_count; i++ ) {
X      if ( strcmp( pdt.help_module_name, opvt[i].MM ) == 0 ) {
X	registered = 1;		/* `i' = registered oridinal */
X	break;
X      }
X    } /* forend */
X    if ( registered == 0 ) {
X      if ( opvt_count >= P_MAX_EMBEDDED_COMMANDS ) {
X	fprintf( stderr, "Too many embedded commands (max=%d), evap results will be unpredictable.\n", P_MAX_EMBEDDED_COMMANDS );
X	goto UH_OH;
X      }
X      for (j=0; (pvt[j].parameter) != NULL; j++); /* count number of PVT entries */
X      opvt[opvt_count].MM = pdt.help_module_name;
X      opvt[opvt_count].pvt = (evap_Parameter_Value *)malloc( j * sizeof( evap_Parameter_Value ) );
X      for (j=0; (pvt[j].parameter) != NULL; j++) {
X	opvt[opvt_count].pvt[j] = pvt[j];
X      }
X      opvt_count++;
X    } else {
X      for (j=0; (pvt[j].parameter) != NULL; j++) {
X	pvt[j] = opvt[i].pvt[j];
X      }
X    }
X  } /* ifend embed */
X
X UH_OH:
X  command = *argv[0];
X  pvt[P_HELP].unconverted_value = command;
X
X  while (*argc > 1 && (*argv)[1][0] == '-') {
X    (*argc)--;
X    arg = *++(*argv);		/* get this parameter */
X    arg++;			/* skip over the - */
X    if (*arg == '-') goto EVAP_FIN; /* -- ends command line parameters */
X    entry = -1;
X
X    if ( (strcmp( arg, "full_help" ) == 0) || (strcmp( arg, "???" ) == 0) ) {
X      full_help = TRUE;		/* flag special full help from disci */
X      pvt[P_HELP].specified = TRUE;
X      continue;			/* while argc */
X    }  
X    if ( (strcmp( arg, "usage_help" ) == 0) || (strcmp( arg, "??" ) == 0) ) {
X      usage_help = TRUE;	/* flag special usage help from disci */
X      pvt[P_HELP].specified = TRUE;
X      continue;			/* while argc */
X    }  
X
X    for (i=0; (pvt[i].parameter) != NULL && entry == -1; i++) 
X      if ( (strcmp(arg, pvt[i].parameter) == 0) && pvt[i].changeable)
X        entry = i;		/* exact match on full form */
X
X    for (i=0; (pvt[i].parameter) != NULL && entry == -1; i++)
X      if ( (strcmp(arg, pvt[i].alias) == 0) && pvt[i].changeable)
X        entry = i;		/* exact match on alias */
X
X    if (entry == -1) {		/* no match so far, try a substring match */
X      for (i=0; (pvt[i].parameter) != NULL; i++) 
X        if ( (strncmp(arg, pvt[i].parameter, strlen(arg)) == 0) &&
X             pvt[i].changeable) {
X          if (entry != -1) {
X            fprintf( stderr, "Ambiguous parameter: -%s.\n", arg );
X	    error = 1;
X	    break; /* for */
X          }
X          entry = i;		/* substring match on full form */
X        }
X    }
X
X    if ( error == 1 )
X      continue; /* while arc */
X
X    if (entry ==  -1) {
X      fprintf( stderr, "Invalid parameter: -%s.\n", arg );
X      error = 1;
X      continue; /* while argc */
X    }
X
X    pvt[entry].specified = TRUE; /* mark it as specified by the user */
X    if (pvt[entry].type != P_TYPE_SWITCH) { /* value for non-switch types */
X      if (*argc > 1) {
X        (*argc)--;
X        pvt[entry].unconverted_value = *++(*argv);
X      } else {
X        fprintf( stderr, "Value required for parameter -%s.\n", pvt[entry].parameter );
X	error = 1;
X      }
X    } else {
X      pvt[entry].unconverted_value = "TRUE";
X    } /* ifend */
X
X    evap_type_verification( &pvt[entry], &error );
X
X  } /* while argc */
X
X  if (pvt[P_HELP].specified) {	/* display command information */
X
X    /* 
X       Establish the proper pager and open the pipeline.  Do no paging
X       if the boolean environment variable D_EVAP_DO_PAGE is FALSE.
X    */
X
X    if ( (pager = getenv( "MANPAGER" )) == NULL || (strcmp( pager, "" ) == 0) ) {
X      if ( (pager = getenv( "PAGER" )) == NULL || (strcmp( pager, "" ) == 0) ) {
X	pager = "more";
X      }
X    }
X    if ( (default_variable = getenv( "D_EVAP_DO_PAGE" )) != NULL ) {
X      if ( strcmp( default_variable, "" ) != 0 ) {
X	for ( i = 0; default_variable[i]; i++ ) {
X	  if ( islower( default_variable[i]) )
X	    default_variable[i] = toupper( default_variable[i] );
X	}
X	if( (strcmp(default_variable, "FALSE") == 0) || (strcmp(default_variable, "NO") == 0) ||
X	    (strcmp(default_variable, "OFF") == 0)   || (strcmp(default_variable, "0") == 0) ) {
X	  PAGER = stdout;
X	}
X      } /* ifend non-NULL D_EVAP_DO_PAGE */
X    } /* ifend environment variable D_EVAP_DO_PAGE exists */
X    if ( PAGER != stdout ) {
X      if ( (PAGER = popen( pager, "w" )) == NULL ) {
X	PAGER = stdout;
X      }
X    }
X
X    if (full_help) {
X      fprintf ( PAGER, "Command Source:  " );
X      evap_display_which(command, PAGER);
X      fprintf ( PAGER, "\nMessage Module Name:  %s\n\n", pdt.help_module_name );
X    }
X
X    if ( usage_help || (evap_display_message_module(pdt.help_module_name,
X          parameter_help, &parameter_help_count, PAGER) != 0) )
X      evap_display_usage(command, pdt, pvt, PAGER);
X
X    fprintf( PAGER, "\nParameters:\n" );
X    if ( ! full_help )
X      fprintf( PAGER, "\n" );
X    for (i=0; (pvt[i].parameter != NULL); i++) {
X      /* changeable = -1 means valid but HIDDEN from -disci */
X      if (pvt[i].changeable == 1) { /*valid and advertisable*/
X	if ( full_help )
X	  fprintf( PAGER, "\n" );
X	if (strcmp(pvt[i].alias, "") != 0)
X          fprintf( PAGER, "-%s, %s%s\n",pvt[i].parameter, pvt[i].alias, pvt[i].description );
X        else
X          fprintf( PAGER, "-%s%s\n",pvt[i].parameter, pvt[i].description );
X
X	if ( full_help && (parameter_help_count >= 0) ) {
X	  fprintf( PAGER, "\n" );
X          if ( i == P_HELP ) {
X            fprintf( PAGER, "\tDisplay information about this command, which includes\n" );
X            fprintf( PAGER, "\ta command description with examples, plus a synopsis of\n" );
X	    fprintf( PAGER, "\tthe command line parameters.  If you specify -full_help\n" );
X	    fprintf( PAGER, "\trather than -help complete parameter help is displayed\n" );
X	    fprintf( PAGER, "\tif it's available.\n" );
X          }
X	  /*
X             Search parameter_help for this parameter's description.
X	     Each entry is a list of new-line-separated lines - the
X	     first line is the name of the parameter.
X          */
X	  for ( j=0; j <= parameter_help_count; j++ ) {
X	    parameter_help_name = strtok( parameter_help[j], "\n" );
X	    if ( strcmp( pvt[i].parameter, parameter_help_name ) == 0 ) {
X	      fprintf( PAGER, "%s", parameter_help[j]+strlen(parameter_help_name)+1 );
X	    } /* ifend */
X	  } /* forend */
X	} /* ifend full_help and parameter_help_count >= 0 */
X      } /* ifend valid and advertisable */ 
X    } /* forend all parameters */
X
X    if ( evap_X11 != NULL )
X      fprintf( PAGER, "%s", evap_X11 );
X
X    if (strcmp(pdt.file_list, "no_file_list") == 0) {
X      fprintf( PAGER, "%s", evap_Help_Hooks[P_HHBNFL] );
X    } else if (strcmp(pdt.file_list, "required_file_list") == 0) {
X      fprintf( PAGER, "%s", evap_Help_Hooks[P_HHBRFL] );
X    } else {
X      fprintf( PAGER, "%s", evap_Help_Hooks[P_HHBOFL] );
X    }
X
X    if ( PAGER != stdout ) {
X      pclose( PAGER );
X    }
X
X    if ( evap_embed ) {
X      return( -1 );
X    } else {
X      exit( 0 );
X    }
X
X  } /* ifend help specified */
X
XEVAP_FIN:
X  /*
X    Now loop through the PDT looking for unspecified parameters.
X
X    If there is a default environment variable specified and it is
X    defined then update the structure member unconverted_value.
X
X    Complain if there are any $required parameters.
X
X    Then perform type verification followed by type conversion.
X  */
X
X  for (i = 0; pvt[i].parameter != NULL; i++) {
X
X    if ( i == P_HELP ) continue; /* for */
X
X    if (! pvt[i].specified) {
X
X      if (strcmp("$required", pvt[i].unconverted_value) == 0) {
X	fprintf( stderr, "Parameter %s is required but was omitted.\n", pvt[i].parameter );
X	error = 1;
X	continue;
X      }
X
X      if (pvt[i].default_variable != NULL) {
X	if ((default_variable = getenv(pvt[i].default_variable)) != NULL) {
X	  pvt[i].unconverted_value = default_variable;
X	} /* ifend */
X      } /* ifend default variable */ 
X
X      if ( pvt[i].list == NULL && (strcmp( pvt[i].unconverted_value, "" ) != 0) ) {
X	evap_type_verification( &pvt[i], &error );
X      } else if ( pvt[i].list != NULL ) {
X	lve = pvt[i].list;
X	while ( lve->unconverted_value != NULL ) {
X	  pvt[i].unconverted_value = lve->unconverted_value;
X	  if ( evap_type_verification( &pvt[i], &error ) )
X	    lve->unconverted_value = pvt[i].unconverted_value;
X	  pvt[i].list_state++;	/* update state for evap_type_conversion */
X	  lve++;
X	} /* whilend */
X      } /* ifend 'list of' parameter */
X
X    } /* ifend parameter not specified */
X
X    if ( error == 0 )
X      evap_type_conversion( &pvt[i] );
X
X  } /* forend */
X
X  if ((strcmp(pdt.file_list, "no_file_list") == 0) && (*argc > 1)) {
X    fprintf( stderr, "%s", evap_Help_Hooks[P_HHENFL] );
X    error = 1;
X  } 
X  if ((strcmp(pdt.file_list, "required_file_list") == 0) && (*argc == 1)) {
X    fprintf( stderr, "%s", evap_Help_Hooks[P_HHERFL] );
X    error = 1;
X  }
X
X  if ( error != 0 ) {
X    fprintf( stderr, "Type %s -? for command line parameter information.\n", pvt[P_HELP].unconverted_value );
X  }
X
X  if ( error != 0 && ! evap_embed ) { exit( 1 ); } /* command line parsing failed, error */
X  if ( ! error ) {
X    return( 0 );		/* return False for success.... sigh */
X  } else {
X    return( 1 );		/* return True for failure... stupid C/Unix */
X  }
X
X} /* end evaluate_parameters */
X
X
X
X
Xint    evap_type_verification(evap_Parameter_Value *pvte, int *error)
X
X/*
X  Type-check/initialize the unconverted_value member (a C string).
X  Evaluate backticked items.
X
X  Lists are a little weird as they may already have default values from the
X  PDT declaration. The first time a list parameter is specified on the
X  command line we must first empty the list of its default values.  The
X  list_state flag thus can be in one of two states: 1 = the list has
X  possible default values from the PDT - malloc space for 10 list values and
X  store the first at the head of the list, and 2++ = from now just keep pushing
X  new command line values on the list, reallocing as needed.
X
X  Return 1 IFF we have changed the original unconverted value, since we might
X  need to update a list.  Also be VERY careful to malloc new space so we don't
X  end up trying to write in a read only segment!
X*/
X{
X
X#define BACKMAX 1024
X
X  char   *backcomd;
X  int    backcnt;
X  int    backincr;
X  char   *backline;
X  char   *backptr;
X  FILE   *backtick;
X  int    i;
X  int    valid;
X  char   *value;
X  char   home[6];
X  struct passwd *pwent;
X  char   *home_ptr;
X  int    rc;
X
X  rc = 0;			/* assume value is not updated */
X
X  if ( pvte->unconverted_value[0] == '`' &&
X      pvte->unconverted_value[strlen( pvte->unconverted_value ) - 1] == '`' ) {
X    backcomd = (char *)malloc( 10 + strlen( pvte->unconverted_value ) );
X    sprintf( backcomd, "echo %s", pvte->unconverted_value );
X    if ( (backtick = popen( backcomd, "r" )) != NULL ) {
X      backcnt = 1;
X      backline = (char *)malloc( BACKMAX * backcnt );
X      backptr = fgets( backline, BACKMAX, backtick );
X      pvte->unconverted_value = backline;
X      while ( backptr != NULL ) {
X	backline = (char *) realloc( backline, BACKMAX * ++backcnt );
X	pvte->unconverted_value = backline;
X	backincr = (BACKMAX * (backcnt - 1)) - (backcnt - 1);
X	backptr = fgets( backline+backincr, BACKMAX, backtick );
X      }
X      pvte->unconverted_value[strlen( pvte->unconverted_value ) - 1] = '\0';
X      pclose( backtick );
X      free( backcomd );
X      rc = 1;
X    } /* ifend backtick evaluation */
X  } /* backticks */
X
X  value = pvte->unconverted_value; /* get value from pvt entry */
X
X  switch (pvte->type) {
X
X  case P_TYPE_SWITCH:
X    break; /* only TRUE or FALSE, guaranteed */
X
X  case P_TYPE_STRING:
X    break; /* anything OK */
X
X  case P_TYPE_REAL:
X    if (FALSE) {		/* no type enforcment (no U*X consistency either) */
X      fprintf( stderr, "Expecting real reference, found \"%s\" for parameter -%s.\n", pvte->unconverted_value, pvte->parameter );
X      *error = 1;
X      break; /* case */
X    }
X    break;
X
X  case P_TYPE_INTEGER:
X    if((isdigit(*value)) || (value[0] == '+') || (value[0] == '-'))
X      value++;
X    else {
X      fprintf( stderr, "Expecting integer reference, found \"%s\" for parameter -%s.\n",
X	      pvte->unconverted_value, pvte->parameter );
X      *error = 1;
X      break; /* case */
X    }
X    for(; *value != '\0'; value++) {
X      if(! isdigit(*value)) {
X        fprintf( stderr, "Expecting integer reference, found \"%s\" for parameter -%s.\n",
X		pvte->unconverted_value, pvte->parameter );
X	*error = 1;
X	break; /* case */
X      }
X    }
X    break;
X
X  case P_TYPE_BOOLEAN:
X    pvte->unconverted_value = (char *)malloc( strlen( value ) + 1 );
X    strcpy( pvte->unconverted_value, value );
X    for ( i = 0; pvte->unconverted_value[i]; i++ ) {
X      if ( islower( pvte->unconverted_value[i]) )
X        pvte->unconverted_value[i] = toupper( pvte->unconverted_value[i] );
X    }
X    value = pvte->unconverted_value;
X    rc = 1;
X    if((strcmp(value, "TRUE") != 0) && (strcmp(value, "FALSE") != 0) &&
X       (strcmp(value, "YES") != 0) && (strcmp(value, "NO") != 0) &&
X       (strcmp(value, "ON") != 0) && (strcmp(value, "OFF") != 0) &&
X       (strcmp(value, "1") != 0) && (strcmp(value, "0") != 0)) {
X      fprintf( stderr, "Expecting boolean reference, found \"%s\" for parameter -%s.\n",
X	      pvte->unconverted_value, pvte->parameter );
X      *error = 1;
X      break; /* case */
X    }
X    break;
X
X  case P_TYPE_FILE:
X    home_ptr = NULL;
X    strncpy( home, value, 5);	/* look for $HOME or ~ */
X    home[5] = '\0';
X    if ( strcmp( home, "$HOME" ) == 0) 
X      home_ptr = value+5;
X    if ( *value == '~')
X      home_ptr = value+1;
X    if ( home_ptr != NULL ) {	/* expand the shorthand */
X      if ( (pwent = getpwuid( getuid() )) != NULL ) {
X        pvte->unconverted_value = (char *)malloc( strlen( value ) + strlen( pwent->pw_dir ) );
X	strcpy( pvte->unconverted_value, pwent->pw_dir );
X	strcat( pvte->unconverted_value, home_ptr );
X	value = pvte->unconverted_value;
X      } /* ifend pwent */
X    } /* ifend expand $HOME */
X    rc = 1;
X    if (strlen(value) > 255) {
X      fprintf( stderr, "Expecting file reference, found \"%s\" for parameter -%s.\n", pvte->unconverted_value, pvte->parameter );
X      *error = 1;
X      break; /* case */
X    }
X    break;
X
X  case P_TYPE_KEY:
X    if (pvte->valid_values[0]) {
X
X      for(valid=FALSE, i=0; pvte->valid_values[i] && ! valid; i++)
X        if (strcmp(value, pvte->valid_values[i]) == 0)
X          valid = TRUE;		/* ok, got one */
X
X      if (! valid)		/* no exact match, try a substring match */
X        for(valid=FALSE, i=0; pvte->valid_values[i]; i++)
X          if (strncmp(value, pvte->valid_values[i], strlen(value)) == 0) {
X            if (valid) {
X              fprintf( stderr, "Ambiguous keyword for parameter -%s: %s.\n", pvte->parameter, value );
X	      *error = 1;
X	      break; /* case */
X            }
X            valid = TRUE;	/* ok, got one */
X            pvte->unconverted_value = pvte->valid_values[i];
X	    rc = 1;
X          } /* ifend update value in pvt */
X
X      if (! valid) {		/* no matches */
X        fprintf( stderr, "\"%s\" is not a valid value for the parameter -%s.\n", pvte->unconverted_value, pvte->parameter );
X	*error = 1;
X	break; /* case */
X      }
X    }
X    break;
X
X  case P_TYPE_APPLICATION:
X    break;			/* anything is valid in this case */
X
X  case P_TYPE_NAME:
X    for ( ; *value != '\0'; value++ ) {
X      if ( *value == ' ' || *value == '\n' || *value == '\t' ) {
X	fprintf( stderr, "Expecting name reference, found \"%s\" for parameter -%s.\n",
X		pvte->unconverted_value, pvte->parameter );
X	*error = 1;
X	break; /* case */
X      }
X    }
X    break;
X
X  default:
X    fprintf( stderr, "Error in evap_type_verification (default), please get help!\n" );
X    exit( 1 );
X    break;
X  }
X
X  if ( (pvte->list != NULL) && pvte->specified ) {
X
X    /*
X       If list_state = 1 malloc room for the first 10 command line values.
X       list_state values >= 2 determine when to realloc - it's the count of
X       list elements - 1.
X    */
X
X    switch ( pvte->list_state ) {
X
X    case 1:			/* store first list value */
X      pvte->list = (evap_List_Value *)malloc( 1 * 10 * sizeof( evap_List_Value) );
X      pvte->list->unconverted_value = pvte->unconverted_value;
X      pvte->list[pvte->list_state++].unconverted_value = NULL;
X      break;
X
X    default:			/* push value on the list, realloc as needed */
X      if ( ( pvte->list_state + 1 ) % 10 == 0 ) {
X	pvte->list =
X	  (evap_List_Value *)realloc(pvte->list, ( ( ( pvte->list_state + 1 ) / 10) + 1 ) * 10 * sizeof( evap_List_Value) );
X      } /* ifend time to realloc */
X      pvte->list[pvte->list_state-1].unconverted_value = pvte->unconverted_value;
X      pvte->list[pvte->list_state++].unconverted_value = NULL;
X      break;
X
X    } /* casend list_state */
X
X  } /* ifend 'list of' parameter */
X
X  return rc;
X
X} /* end evap_type_verification */
X
X
X
X
Xvoid   evap_type_conversion(evap_Parameter_Value *pvte)
X
X/*
X  Convert all the unconverted values, which are C strings, in a type-dependent
X  manner, and store the result in the value variant record (union).
X*/
X{
X
X  char   *value;
X
X  do {				/* for all values */
X
X      if ( pvte->list == NULL ) { /* get scalar value */
X	value = pvte->unconverted_value;
X      } else {			/* get list value */
X	pvte->list_state--;
X	value = pvte->list[pvte->list_state - 1].unconverted_value;
X      }
X
X    switch (pvte->type) {
X
X    case P_TYPE_SWITCH:
X      if (strcmp(value, "TRUE") == 0)
X	pvte->value.switch_value = TRUE;
X      else
X	pvte->value.switch_value = FALSE;
X      if ( pvte->list != NULL )
X	pvte->list[pvte->list_state - 1].value.switch_value = pvte->value.switch_value;
X      break;
X
X    case P_TYPE_STRING:
X      pvte->value.string_value = value;
X      if ( pvte->list != NULL )
X	pvte->list[pvte->list_state - 1].value.string_value = pvte->value.string_value;
X      break;
X
X    case P_TYPE_REAL:
X      sscanf(value, "%lg", &pvte->value.real_value);
X      if ( pvte->list != NULL )
X	pvte->list[pvte->list_state - 1].value.real_value = pvte->value.real_value;
X      break;
X
X    case P_TYPE_INTEGER:
X      sscanf(value, "%d", &pvte->value.integer_value);
X      if ( pvte->list != NULL )
X	pvte->list[pvte->list_state - 1].value.integer_value = pvte->value.integer_value;
X      break;
X
X    case P_TYPE_BOOLEAN:
X      if ( (strcmp(value, "TRUE") == 0) || (strcmp(value, "YES") == 0) ||
X	  (strcmp(value, "ON") == 0)    || (strcmp(value, "1") == 0) )
X	pvte->value.boolean_value = TRUE;
X      else
X	pvte->value.boolean_value = FALSE;
X      if ( pvte->list != NULL )
X	pvte->list[pvte->list_state - 1].value.boolean_value = pvte->value.boolean_value;
X      break;
X
X    case P_TYPE_FILE:
X      pvte->value.file_value = value;
X      if ( pvte->list != NULL )
X	pvte->list[pvte->list_state - 1].value.file_value = pvte->value.file_value;
X      break;
X
X    case P_TYPE_KEY:
X      pvte->value.key_value = value;
X      if ( pvte->list != NULL )
X	pvte->list[pvte->list_state - 1].value.key_value = pvte->value.key_value;
X      break;
X
X    case P_TYPE_APPLICATION:
X      pvte->value.application_value = value;
X      if ( pvte->list != NULL )
X	pvte->list[pvte->list_state - 1].value.application_value = pvte->value.application_value;
X      break;
X
X    case P_TYPE_NAME:
X      pvte->value.name_value = value;
X      if ( pvte->list != NULL )
X	pvte->list[pvte->list_state - 1].value.name_value = pvte->value.name_value;
X      break;
X
X    default:
X      fprintf( stderr, "Error in evap_type_conversion (default), please get help!\n" );
X      exit( 1 );
X      break;
X    }
X
X  } while ( pvte->list_state > 1 );
X
X  return;
X
X} /* end evap_type_conversion */
X
X
X
Xint    evap_display_message_module(char *message_module_name,
X				   char *parameter_help[],
X				   int *parameter_help_count,
X				   FILE *PAGER)
X
X/*
X  Search an evaluate_parameters message module file for the specified help
X  module and, if found, display it.
X 
X  The message_module_name parameter is either a simple message module name or
X  a message module name prefixed with the path name of a local message module
X  archive file.  For example:
X 
X    disci.mm               names a message module disci.mm in file libevapmm.a
X    my_mm/my_program.mm    names a message module my_progam.mm in file my_mm
X*/
X{
X
X  FILE*  a;			/* stream to read ar output from */
X  char   afn[256];		/* evap ar message module path name */
X  char   ar_str[600];		/* ar p libevapmm.a mm */
X  char*  cp;			/* character pointer */
X  short  parameter_help_in_progress;
X  char   mmn[256];
X
X
X  if (message_module_name == NULL)
X    return( 1 );		/* if no message module specified */
X
X  strncpy( mmn, message_module_name, 255 ); /* make local copy */
X  cp = strrchr(mmn, '/');	/* check for local archive path */
X  if (cp == NULL) {		/* simple message module name */
X    strcpy(afn, P_EVAP_MM_PATH); /* use default ar file name */
X  } else {			/* private message module ar file */
X    *cp = '\0'; /* separate file path name and message module name */
X    strcpy(afn, mmn);
X    strcpy(mmn, cp+1);
X  } /* ifend simple message module */
X
X  sprintf(ar_str, "ar p %s %s 2> /dev/null", afn, mmn);
X
X  *parameter_help_count = -1;	/* no parameters have help so far */
X  parameter_help_in_progress = FALSE; /* not collecting parameter help */
X
X  if ( (a = popen( ar_str, "r" )) == NULL )
X    return( 1 );		/* do usage */
X
X  if ( fgets( ar_str, 512, a ) == NULL )
X    return( 1 );		/* do usage */
X
X  do {				/* copy message module until EOF */
X    if ( ar_str[0] == '.' ) {	/* or until start of parameter help */
X      parameter_help_in_progress = TRUE;
X      /*
X	Create an array of parameter help: the first line is the parameter
X	name and successive lines are the associated help text.
X      */
X      (*parameter_help_count)++;
X      parameter_help[*parameter_help_count] = (char *)malloc( P_MAX_PARAMETER_HELP_LENGTH );
X      strcpy( parameter_help[*parameter_help_count], ar_str+1 );
X      continue; /* do */
X    } /* ifend start of parameter help */
X    if ( parameter_help_in_progress ) {
X      if ( strlen( parameter_help[*parameter_help_count] ) + strlen( ar_str ) < P_MAX_PARAMETER_HELP_LENGTH ) {
X	strcat( parameter_help[*parameter_help_count], ar_str );
X      } else {
X	sprintf( ar_str, "\n*** Parameter Help Text Exceeds %d Characters ***\n", P_MAX_PARAMETER_HELP_LENGTH );
X	strcpy( parameter_help[*parameter_help_count] + P_MAX_PARAMETER_HELP_LENGTH - strlen( ar_str ) - 1, ar_str );
X      }
X    } else {
X      fprintf( PAGER, "%s", ar_str );
X    }
X  } while (fgets( ar_str, 512, a) != NULL); /* doend */
X  pclose( a );
X
X  return( 0 );			/* success */
X
X} /* end evap_display_message_module */
X
X
X
X
X
Xvoid  evap_display_usage(char *command,
X			 struct pdt_header pdt,
X			 evap_Parameter_Value pvt[],
X			 FILE *PAGER)
X
X/*
X  Generate a 'standard' usage display in lieu of a help message module.
X*/
X{
X
X  int    i;
X  int    optional_param_count;
X  char   *basename;
X
X  optional_param_count = 0;
X
X  if ( (basename = strrchr( command, '/' )) == NULL ) { /* only basename for usage help */
X    basename = command;
X  } else {
X    basename++;
X  }
X  fprintf( PAGER, "\nUsage: %s", basename );
X
X  for(i=0; pvt[i].parameter != NULL; i++) {
X    if (pvt[i].changeable == 1) { /* valid and advertisable */
X      optional_param_count++;
X      if (strcmp(pvt[i].unconverted_value, "$required") == 0) {
X        optional_param_count--;
X        if (strcmp(pvt[i].alias, "") != 0)
X          fprintf( PAGER, " -%s", pvt[i].alias );
X        else
X          fprintf( PAGER, " -%s", pvt[i].parameter );
X      } /* ifend */
X    } /* ifend */
X  } /* forend */
X
X  if (optional_param_count > 0) {
X    fprintf( PAGER, " [" );
X    for(i=0; pvt[i].parameter != NULL; i++) {
X      if (pvt[i].changeable == 1) { /* if advertisable */
X        if (strcmp(pvt[i].unconverted_value, "$required") != 0) {
X          if (strcmp(pvt[i].alias, "") != 0)
X            fprintf( PAGER, " -%s", pvt[i].alias );
X          else
X            fprintf( PAGER, " -%s", pvt[i].parameter );
X        } /* ifend */
X      } /* ifend */
X    } /* forend */
X    fprintf( PAGER, "]" );
X  } /* ifend */
X
X  if (strcmp(pdt.file_list, "required_file_list") == 0) {
X    fprintf( PAGER, "%s", evap_Help_Hooks[P_HHURFL] );
X  } else if (strcmp(pdt.file_list, "optional_file_list") == 0) {
X    fprintf( PAGER, "%s", evap_Help_Hooks[P_HHUOFL] );
X  } else {
X    fprintf( PAGER, "%s", evap_Help_Hooks[P_HHUNFL] );
X  }
X
X  return;
X
X} /* end evap_display_usage */
X
X
X
X
Xvoid  evap_display_which(char *command,
X			 FILE *PAGER)
X
X/*
X  Perform a fast 'which' function to show the source of this command.
X  (Copied from which.c on UUNET.UU.NET, but with a few bug fixes.)
X*/
X{
X
X  char   *getenv(), *path = getenv("PATH");
X  char   test[1000], *pc, save;
X  int    len, found;
X
X  char   name[256];		/* name exclusive of path */
X  char   *cp;			/* character pointer */  
X
X  cp = strrchr(command, '/');	/* look for path separator */
X  if (cp == NULL)
X    strcpy(name, command);	/* if a simple file name */
X  else {
X    fprintf( PAGER, "%s\n", command );	/* must be an explicit path */
X    return;
X  }
X
X  pc = path;
X  found = 0;
X
X  while (*pc != '\0' && found == 0) {
X    len = 0;
X
X    while (*pc != ':' && *pc != '\0') {
X      len++;
X      pc++;
X    } /* whilend */
X
X    save = *pc;
X    *pc = '\0';
X    sprintf(test, "%s/%s", pc-len, name);
X    *pc = save;
X    if (*pc)
X      pc++;
X
X    found = (0 == access(test, 01)); /* executable */
X    if (found) {
X      fputs( test, PAGER );
X      fputs( "\n", PAGER );
X    }
X
X  } /* whilend */
X
X  return;
X
X} /* end evap_display_which */
X
X
X
X
X
Xvoid evap_pac(char *prompt,
X	      FILE *I,
X	      evap_Application_Command user_commands[])
X
X/*
X   Process Application Commands
X
X   An application command can be envoked by entering either its full spelling or the alias.
X*/
X{
X
X  int argc;			/* argument count */
X  char *argv[P_MAX_EMBEDDED_ARGUMENTS];	/* argument vector */
X  evap_Application_Command *cmd_e; /* command entry */
X  evap_Application_Command *cmd_p; /* command pointer */
X  char *char_p;			/* character pointer */
X  int evap_bang_proc(int argc,	/* bang processor */
X		     char *argv[]);
X  int evap_disac_proc(int argc,	/* display_application_commands processor */
X		      char *argv[]);
X  char *evap_get_token(char *char_p, int bang ); /* get next token from input line */
X  extern evap_Application_Command *evap_commands; /* combined user/evap command list */
X  evap_Application_Command evap_commands0[] = {	/* evap_pac special commands */
X    {"display_application_commands", "disac", evap_disac_proc},
X    {"!", "", evap_bang_proc},
X  };				/* user commands MUST be NULL terminated */
X  extern int  evap_embed;	/* 1 IFF evap is embedded */
X  extern char evap_shell[];	/* user's preferred shell */
X  int evap_sorac_proc();	/* sort application commands processor */
X  char *getenv();		/* get value of environment variable */
X  int i;			/* index */
X  char line[514];		/* user's input line */
X  char new_line[514];		/* copy of user's input line for bang processor */
X
X  evap_embed = 1;		/* flag to evaluate_parameters */
X  if ( (char_p = getenv( "SHELL" )) == NULL || (strcmp( char_p, "" ) == 0) ) {
X    char_p = "/bin/sh";
X  }
X  strcpy( evap_shell, char_p );	/* save user's preferred shell */
X
X  /* First, combine the special evap_pac commands and the user commands into a new, sorted, command list. */
X
X  i = sizeof(evap_commands0) / sizeof(evap_Application_Command) + 1;
X  cmd_p = user_commands;
X  while ( cmd_p->command != NULL ) {
X    i++;			/* count user commands too */
X    cmd_p++;
X  }
X  if ( (evap_commands = (evap_Application_Command *)malloc( i * sizeof(evap_Application_Command) )) == NULL ) {
X    fprintf( stderr, "malloc error requesting space for evap_pac's command list.\n" );
X    return;
X  }
X  for ( i=0; i < sizeof(evap_commands0) / sizeof(evap_Application_Command); i++ ) {
X    evap_commands[i] = evap_commands0[i]; /* copy special evaluate_parameters/process_application_commands commands */
X  }
X  for ( cmd_p=user_commands; cmd_p->command != NULL; cmd_p++, i++ ) {
X    evap_commands[i] = *cmd_p;	/* append user commands */
X  }
X  qsort( evap_commands, i, sizeof( evap_Application_Command ), evap_sorac_proc );
X  evap_commands[i].command = NULL;	/* mark end of PAC command list */
X
X  fprintf( stdout, "%s", prompt );
X
X  while ( fgets( line, 512, I ) != NULL ) {
X
X    argc = 0 ;
X    if ( line[0] == '\n' ) { goto GET_USER_INPUT; } /* ignore empty input lines */
X
X    /*
X       Span leading whitespace and inspect first character.  If no token get another input
X       line.  If a ! ensure a space follows the bang character.  Then get the first token.
X    */
X    line[strlen( line )-1] = '\0';		/* zap newline */
X    for ( char_p=line; *char_p != '\0' && (*char_p == ' ' || *char_p == '\n' || *char_p == '\t'); char_p++ );
X    if ( *char_p == '\0' ) goto GET_USER_INPUT;
X    if ( *char_p == '!' ) {
X      strcpy( new_line, "! " );
X      strcat( new_line, ++char_p );	/* ensure a space after the bang */
X      char_p = new_line;
X    }
X    argv[argc++] = evap_get_token( char_p, FALSE ); /* get application command */
X
X    cmd_e = NULL;
X    for ( cmd_p=evap_commands; (cmd_p->command != NULL && cmd_e == NULL); cmd_p++ ) {
X      if ( strcmp( cmd_p->command, argv[0] ) == 0 ) { cmd_e = cmd_p; }
X    }
X    for ( cmd_p=evap_commands; (cmd_p->command != NULL && cmd_e == NULL); cmd_p++ ) {
X      if ( strcmp( cmd_p->alias, argv[0] ) == 0 ) { cmd_e = cmd_p; }
X    }
X
X    if ( cmd_e == NULL ) {
X      fprintf( stderr, "Error - unknown command `%s'.  Type \"disac -do f\" for a\n", argv[0] );
X      fprintf( stderr, "list of valid application commands.  You can then ...\n\n" );
X      fprintf( stderr, "Type \"xyzzy -?\" for help on application command `xyzzy'.\n" );
X      goto GET_USER_INPUT;
X    }
X
X    if ( strcmp( argv[0], "!" ) == 0 ) { /* rest of line is token */
X      argv[argc++] = evap_get_token( NULL, TRUE );
X      argv[argc] = NULL;
X    } else {
X      do {			/* get shell-like tokens */
X	if ( argc >= P_MAX_EMBEDDED_ARGUMENTS ) {
X	  fprintf( stderr, "Too many command arguments (max=%d); please re-enter command.\n", P_MAX_EMBEDDED_ARGUMENTS );
X	  goto GET_USER_INPUT;
X	}
X      } while ( (argv[argc++] = evap_get_token( NULL, FALSE )) != NULL );
X      argc--;
X    }
X
X    cmd_e->proc( argc, argv );	/* call the evap/usr procedure */
X
X  GET_USER_INPUT:
X    fprintf( stdout, "%s", prompt );
X
X  } /* whilend */
X
X  free( evap_commands );
X  fprintf( stdout, "\n" );
X
X} /* end evap_pac */
X
X
X
X
Xint evap_bang_proc(int argc,
X		   char *argv[])
X{
X
X  char cmd[514];
X  extern char evap_shell[];
X  
X  evap_Help_Hooks[P_HHUOFL] = " Command(s)\n";
X  evap_Help_Hooks[P_HHBOFL] = "\nA list of shell Commands.\n\n";
X  if ( *argv[1] == '\n' ) { return( 0 ); }
X  if ( evap( &argc, &argv, bang_pkg_pdt, NULL, bang_pkg_pvt ) != 0 ) { return( 0 ); }
X
X  sprintf( cmd, "%s -c '%s'", evap_shell, argv[1] );
X  system( cmd );
X
X  return( 0 );
X
X} /* end evap_bang_proc */
X
X
X
X
Xint evap_disac_proc(int argc,
X		    char *argv[])
X{
X
X  evap_Application_Command *cmd_p;
X  extern evap_Application_Command *evap_commands;
X
X  if ( evap( &argc, &argv, disac_pkg_pdt, NULL, disac_pkg_pvt ) != 0 ) { return( 0 ); }
X
X  if ( strcmp( disac_pkg_pvt[disac_pkg_P_display_option].value.key_value, "full" ) == 0 ) {
X    fprintf( stdout, "\nCommands and aliases for this application:\n\n" );
X  }
X  for( cmd_p=evap_commands; cmd_p->command != NULL; cmd_p++ ) {
X    if ( strcmp( disac_pkg_pvt[disac_pkg_P_display_option].value.key_value, "full" ) == 0 ) {
X      fprintf( stdout, "  %s%s%s\n", cmd_p->command, (strcmp( cmd_p->alias, "" ) == 0) ? "" : ", ", cmd_p->alias );
X
X    } else {
X      fprintf( stdout, "%s\n", cmd_p->command );
X    }
X  }
X  
X
X  return( 0 );
X
X} /* end evap_disac_proc */
X
X
X
X
Xint evap_sorac_proc(const evap_Application_Command *keyval, /* sort application commands processor */
X		    const evap_Application_Command *base)
X{
X
X  return( strcmp( keyval->command, base->command ) );
X
X} /* end evap_sorac_proc */
X
X
X
X
Xchar *evap_get_token( char *char_p, int bang ) /* get next token from input line */
X{
X  
X  int str = FALSE;
X  static char *token_p;
X  char *tp;
X
X  if ( char_p != NULL ) {
X    token_p = char_p;		/* initialize token pointer */
X  }
X  tp = token_p;
X
X  if ( bang ) { return( tp ); }	/* entire line is bang's token */
X
X  if ( *token_p == '"' || *token_p == '\'' ) {
X    str = TRUE;
X    tp++;			/* do not return leading quote */
X  }
X
X  do {
X    for ( ; *token_p != '\0' && (*token_p != ' ' && *token_p != '\n' && *token_p != '\t'); token_p++ ); /* span token */
X    if ( *(token_p-1) == '"' || *(token_p-1) == '\'' ) {
X      str = FALSE;
X      *(token_p-1) = '\0';	/* do not return trailing quote */
X    }
X    if ( str ) { token_p++; }
X  } while ( str && *token_p != '\0' );
X  *token_p++ = '\0';		/* terminate token */
X  for ( ; *token_p != '\0' && (*token_p == ' ' || *token_p == '\n' || *token_p == '\t'); token_p++ ); /* span whitespace */
X
X  if ( *tp == '\0' ) { tp = NULL; }
X  return( tp );
X
X} /* end evap_get_token */
END_OF_FILE
if test 41573 -ne `wc -c <'src/evap.c'`; then
    echo shar: \"'src/evap.c'\" unpacked with wrong size!
fi
# end of 'src/evap.c'
fi
if test -f 'src/evap.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/evap.h'\"
else
echo shar: Extracting \"'src/evap.h'\" \(4523 characters\)
sed "s/^X//" >'src/evap.h' <<'END_OF_FILE'
X/*
X
X  evap.h - header file for evaluate_parameters (PDT Version 2.0)
X
X  Copyright (C) 1990 - 1994 by Stephen O. Lidie and Lehigh University.
X			 All rights reserved.
X
X  $Id: evap.h,v 2.1.0.3 1994/05/26 19:02:26 lusol Exp $
X
X*/
X
X#define P_PDT_VERSION "2.0"	/* Parameter Description Table version */
X
X#ifndef TRUE
X#define TRUE  1			/* TRUE */
X#endif
X#ifndef FALSE
X#define FALSE 0			/* FALSE */
X#endif
X
X#define P_TYPE_SWITCH      0	/* type ordinals */
X#define P_TYPE_STRING      1
X#define P_TYPE_REAL        2
X#define P_TYPE_INTEGER     3
X#define P_TYPE_BOOLEAN     4
X#define P_TYPE_FILE        5
X#define P_TYPE_KEY         6
X#define P_TYPE_APPLICATION 7
X#define P_TYPE_NAME        8
X#define P_MAXIMUM_TYPES    9	/* maximum types supported */
X
X#define P_MAX_KEYWORD_LENGTH 31	/* maximum parameter length */
X#define P_MAX_KEYWORD_VALUE_LENGTH 256 /* maximum parameter value length */
X#define P_MAX_PARAMETER_HELP 256 /* max parameters that can have full_help */
X#define P_MAX_PARAMETER_HELP_LENGTH 1024 /* maximum parameter help length */
X#define P_MAX_VALID_VALUES 32	/* maximum number of key values */
X#define P_MAX_EMBEDDED_COMMANDS 100 /* maximum count of original, pristine,  PVTs to keep */
X#define P_MAX_EMBEDDED_ARGUMENTS 256 /* maximum count of embedded command arguments */
X
X#define P_HELP 0		/* display command information */
X
X#define P_HHURFL 0		/* Help Hook text, Usage, required_file_list */
X#define P_HHUOFL 1		/* Help Hook text, Usage, optional_file_list */
X#define P_HHUNFL 2		/* Help Hook text, Usage, no_file_list */
X#define P_HHBRFL 3		/* Help Hook text, Brief, required_file_list */
X#define P_HHBOFL 4		/* Help Hook text, Brief, optional_file_list */
X#define P_HHBNFL 5		/* Help Hook text, Brief, no_file_list */
X#define P_HHERFL 6		/* Help Hook text, Error, required_file_list */
X#define P_HHENFL 7		/* Help Hook text, Error, no_file_list */
X#define P_MAXIMUM_HELP_HOOKS 8	/* maximum Help Hooks available */
X
Xstruct pdt_header {		/* PDT header */
X  char *version;		/* PDT version */
X  char *help_module_name;	/* help module */
X  char *file_list;		/* trailing file list flag */
X};
X
Xunion evap_value {		/* one evaluate_parameters value */
X  short int switch_value;
X  char *string_value;
X#ifdef nosve
X  long double real_value;
X#else
X  double real_value;
X#endif
X  int integer_value;
X  short int boolean_value;
X  char *file_value;
X  char *key_value;
X  char *application_value;
X  char *name_value;
X};
X
Xtypedef union evap_value evap_Value; /* an alias */
X
Xstruct evap_list_value {	/* a 'list of' value */
X  char  *unconverted_value;	/* value before type conversion */
X  evap_Value value;		/* type-converted value */
X};
X
Xtypedef struct evap_list_value evap_List_Value;
X
Xstruct evap_parameter_value {	/* parameter value */
X  char  *parameter;		/* official parameter spelling */
X  char  *alias;			/* this parameter also known as */
X  short int specified;		/* if this paramameter entered by user */
X  short int changeable;		/* if parameter is changeable by user */
X  short int type;		/* this parameter's type */
X  char  *default_variable;	/* default environment variable */
X  char  *unconverted_value;	/* value before type conversion */
X  char  *description;		/* for usage information */
X  int   list_state;		/* 0   = not 'list of',
X				   1   = list initialized by genpdt, malloc 10
X				         list values and store the first,
X				   2++ = push successive command line values
X				         and realloc as needed */
X  evap_List_Value  *list;	/* pointer to 'list of' values or NULL if not
X				   a list parameter */
X  char  *valid_values[P_MAX_VALID_VALUES]; /* valid values, last one NULL */
X  evap_Value value;		/* parameter value */
X};
X
Xtypedef struct evap_parameter_value evap_Parameter_Value; /* an alias */
X
Xstruct evap_application_command { /* application command */
X  char  *command;		/* official command spelling */
X  char  *alias;			/* this command also known as */
X  int   (*proc)(int argc,	/* pointer to comand processor */
X		char *argv[]);
X};
X
Xtypedef struct evap_application_command evap_Application_Command; /* an alias */
X
Xextern char *evap_Type_Strings[]; /* valid types, indexed by type ordinal */
X
Xextern char *evap_Help_Hooks[]; /* Help Hooks text, indexed by hook ordinal */
X
Xvoid evap_pac(char *prompt,	/* evaluate_parameters/process_application_commands prototype */
X	      FILE *I,
X	      evap_Application_Command commands[]);
X
Xint evap(int *argc,		/* evaluate_parameters prototype */
X	 char **argv[],
X	 struct pdt_header pdt,
X	 void *check_parameters_function,
X	 evap_Parameter_Value *pvt);
END_OF_FILE
if test 4523 -ne `wc -c <'src/evap.h'`; then
    echo shar: \"'src/evap.h'\" unpacked with wrong size!
fi
chmod +x 'src/evap.h'
# end of 'src/evap.h'
fi
if test -f 'src/evap.pl' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/evap.pl'\"
else
echo shar: Extracting \"'src/evap.pl'\" \(30832 characters\)
sed "s/^X//" >'src/evap.pl' <<'END_OF_FILE'
X#
X# evap.pl - evaluate_parameters 2.1 for Perl
X#
X# lusol@lehigh.EDU, 93/11/07
X#
X# Made to conform, as much as possible, to the C function evap. The C, Perl
X# and Tcl versions of evap are patterned after the Control Data procedure
X# CLP$EVALUATE_PARAMETERS for the NOS/VE operating system, although neither
X# approaches the richness of CDC's implementation.
X#
X# Availability is via anonymous FTP from ftp.Lehigh.EDU (128.180.63.4) in the
X# directory pub/evap/evap-2.x.
X#
X# Stephen O. Lidie, Lehigh University Computing Center.
X#
X# Copyright (C) 1993 - 1994 by Stephen O. Lidie.  All rights reserved.
X#
X# For related information see the evap/C header file evap.h.  Complete
X# help can be found in the man pages evap(2), evap.c(2), evap.pl(2),
X# evap.tcl(2) and evap_pac(2).
X#     
X# 
X#                           Revision History 
X#
X# lusol@Lehigh.EDU 93/05/03 (PDT version 1.2)  Version 1.6
X#   . Original release - similar to version 1.6 of the C function evap.
X#     Differences: support for `list of'; no support for types `application'
X#     and `name'; no suport for default environment variables.
X#   . For MS-DOS beasts set the internal variable $evap'DOS = 1.
X#
X# lusol@Lehigh.EDU 93/08/24 (PDT version 2.0)  Version 2.0
X#   . The syntax for initializing the default value(s) for a `list of' command
X#     line parameter has been defined and implemented:  ("val 1", "val 2"),
X#     strangely enough the same syntax that Perl uses (-:, since that and eval
X#     made my life much easier.  NOTE: in general you should quote components
X#     of your lists, even if they're not type string, so that Perl/eval can
X#     properly parse the list for evaluate_parameters.
X#   . Essentially unnoticeable bug fix concerning `optional_file_list'.
X#   . In a keyword type defintion 'key key1, key2, keyend' a space character
X#     after the comma is no longer required.
X#   . Various bug fixes when displaying -help information:  always surround
X#     strings with double quotes, separate list with commas, convert boolean
X#     values to TRUE or FALSE.
X#   . Empty a `list of' variable the first time it's specified on the command
X#     line.  Previously, list values specified on the command line were simply
X#     pushed onto the list of PDT default values.
X#   . Fix expansion of $HOME and ~ for file types that broke when I added the
X#     stdin/stdout mod at the last second (-:!  Sigh, my QA was done on DOS.
X#   . Handle default environment variables just like evap/C.  (DOS and Unix!)
X#   . Similarly to evap/C, return program name in $opt_help.
X#   . PDT lines beginning with # are considered comments and are ignored.
X#   . In addition to returning command line values in scalar/list variables of
X#     the form $opt_parameter and @opt_parameter, return them in the 
X#     associative arrays %options and %Options as:
X#
X#       Perl 4: a single string `joined' with the multi-dimensional array
X#               emulation character ($;)
X#       Perl 5: a reference to a list
X#
X#     and indexed by the name of the parameter's full-spelling.
X#   . Defer evaluation of file, boolean and backticked items if -help is
X#     requested so that the unevaluated PDT values are displayed.
X#
X# lusol@Lehigh.EDU 94/03/29 (PDT version 2.0)  Version 2.1
X#   . Replace help alias `disci' with `?'.
X#   . Add ON/OFF as valid boolean values.
X#   . Also return parameter values in %Options.
X#   . Move documentation from evap.pl to the man page evap.pl(2).
X#   . Obey MANPAGER (or PAGER) environment variable and page help output.
X#     Default pager is `more'.  Since this changes the behavior of
X#     evaluate_parameters, the boolean environment variable D_EVAP_DO_PAGE
X#     can be set to FALSE/NO/OFF/0, any case, to disable this automatic
X#     paging.
X#   . Implement Help Hooks to customize evap's help output.
X#   . Use only a command's basename for -usage_help.
X#   . To use evaluate_parameters as an embedded command line processor call
X#     the internal routine `$evap'evap_pac'.
X#
X# $Id: evap.pl,v 2.1.0.5 1994/06/01 01:03:08 lusol Exp $
X#
X
X
X
X
Xsub evap {
X    
X    package evap;
X    
X    local( *PDT, *MM ) = @_;	# Parameter Description Table, Message Module
X    
X    $DOS = 0 unless defined( $DOS  ); # 1 iff MS-DOS, else Unix
X    $message_modules = "./libevapmm.a";
X
X    eval 'BEGIN {}';
X    $Perl_version_major = $@ ? 4 : 5;
X
X    local( $pdt_reg_exp1 ) = '^(.)(.)(.?)$';
X    local( $pdt_reg_exp2 ) = '^TRUE$|^YES$|^ON$|^1$';
X    local( $pdt_reg_exp3 ) = '^FALSE$|^NO$|^OFF$|^0$';
X    local( $pdt_reg_exp4 ) = '^\s*no_file_list\s*$';
X    local( $pdt_reg_exp5 ) = '^\s*optional_file_list\s*$';
X    local( $pdt_reg_exp6 ) = '^\s*required_file_list\s*$';
X    local( $full_help ) = 0;
X    local( $usage_help ) = 0;
X    local( $file_list ) = 'optional_file_list';
X    local( $error ) = 0;
X    local( $pkg ) = (caller)[0];
X    local( $value, $rt, $type, $required, @P_PARAMETER, %P_INFO, %P_ALIAS, @P_REQUIRED, %P_VALID_VALUES, %P_ENV );
X    local( $option, $default_value, $list, $parameter, $alias, @keys0, @keys, $found, $length, %P_EVALUATE, %P_DEFAULT_VALUE );
X    
X    
X    $evap_embed = 0 unless defined( $evap_embed ); # 1 iff embed evap in the application
X    if ( $evap_embed ) {	# Initialize for a new call in case evaluate_parameters is embedded in an application.
X	$variable_name_old = "${pkg}\'opt_help";
X	$vnn = "${pkg}\'options";
X	$vnn2 = "${pkg}\'Options";
X	&evap_set_value(0,  'w', '', '', $variable_name_old, $vnn, $vnn2, 'help' ); # clear `help' indicator
X    }
X    
X    #
X    # Verify correctness of the PDT.  Check for duplicate parameter names
X    # and aliases.  Extract default values and possible keywords.  Decode
X    # the user syntax and convert into a simpler form (ala NGetOpt) for
X    # internal use.  Handle 'file list' too.
X    #
X
X    @local_pdt = @PDT;
X    unshift( @local_pdt, 'help, ?: switch' );	# supply -help automatically
X    @P_PARAMETER = ();		# no parameter names
X    %P_INFO = ();		# no encoded parameter information
X    %P_ALIAS = ();		# no aliases
X    @P_REQUIRED = ();		# no required parameters
X    %P_VALID_VALUES = ();	# no keywords
X    %P_ENV = ();		# no default environment variables
X    %P_EVALUATE = ();		# no PDT values evaluated yet
X    %P_DEFAULT_VALUE = ();	# no default values yet
X
X  OPTIONS:
X    foreach $option ( @local_pdt ) {
X
X	$option =~ s/\s*$//;	# trim trailing spaces
X	next OPTIONS if $option =~ /^#.*|PDT\s+|pdt\s+|PDT$|pdt$/;
X	$option =~ s/\s*PDTEND|\s*pdtend//;
X	next OPTIONS if $option =~ /^ ?$/;
X	
X	if ( $option =~ /$pdt_reg_exp4|$pdt_reg_exp5|$pdt_reg_exp6/ ) {
X	    $file_list = $option; # remember user specified file_list
X	    next OPTIONS;
X	}
X	
X        ($parameter, $alias, $_) = ($option =~ /^\s*(\S*)\s*,\s*(\S*)\s*:\s*(.*)$/);
X	&evap_PDT_error( "Error in an evaluate_parameters 'parameter, alias: type' option specification:  \"$option\".\n" )
X	    unless defined( $parameter ) && defined( $alias ) && defined( $_ );
X	&evap_PDT_error( "Duplicate parameter $parameter:  \"$option\".\n" ) if defined( $P_INFO{$parameter} );
X	push( @P_PARAMETER, $parameter ); # update the ordered list of parameter names
X
X        /(\bswitch\b|\binteger\b|\bstring\b|\breal\b|\bfile\b|\bboolean\b|\bkey\b|\bname\b|\bapplication\b)/; # type/list
X        ($list, $type, $_)=($`, $1, $');
X	&evap_PDT_error( "Parameter $parameter has an undefined type:  \"$option\".\n" ) unless defined( $type );
X	&evap_PDT_error( "Expecting 'list of', found:  \"$list\".\n") if $list ne '' && $list !~ /\s*list\s+of\s+/;
X        $list = '1' if $list;	# list state = 1, possible default PDT values
X        $type = 'w' if $type =~ /^switch$/;
X	$type = substr( $type, 0, 1 );
X
X        ($_, $default_value) = /\s*=\s*/ ? ($`, $') : ('', ''); # get possible default value
X	if ( $default_value =~ /^([^\(]{1})(\w*)\s*,\s*(.*)/ ) { # if environment variable AND not a list
X	    $default_value = $3;
X	    $P_ENV{$parameter} = $1 . $2;
X	}
X        $required = ($default_value eq '$required') ? 'R' : 'O';
X        $P_INFO{$parameter} = defined $type ? $required . $type . $list : "";
X	push( @P_REQUIRED, $parameter ) if $required =~ /^R$/; # update the list of $required parameters
X
X        if ( $type =~ /^k$/ ) {
X	    $_ =~ s/,/ /g;
X	    @keys = split( ' ' );
X	    pop( @keys );	# remove 'keyend'
X	    $P_VALID_VALUES{$parameter} = join( ' ', @keys );
X        } #ifend keyword type
X	
X	foreach $value (keys %P_ALIAS) {
X	    &evap_PDT_error( "Duplicate alias $alias:  \"$option\".\n" ) if $alias eq $P_ALIAS{$value};
X	}
X	$P_ALIAS{$parameter} = $alias; # remember alias
X
X	&evap_PDT_error( "Cannot have 'list of switch':  \"$option\".\n" ) if $P_INFO{$parameter} =~ /^.w1$/;
X
X        if ( $default_value ne '' && $default_value ne '$required' ) {
X	    $default_value = $ENV{$P_ENV{$parameter}} if $P_ENV{$parameter} && $ENV{$P_ENV{$parameter}};
X	    $P_DEFAULT_VALUE{$parameter} = $default_value;
X	    $variable_name_old = "${pkg}\'opt_${parameter}";
X	    $vnn = "${pkg}\'options";
X	    $vnn2 = "${pkg}\'Options";
X            &evap_set_value(0,  $type, $list, $default_value, $variable_name_old, $vnn, $vnn2, $parameter ); # initialize
X        }
X	
X    } # forend OPTIONS
X
X    if ( $error ) {
X        print STDERR "Inspect the file \"evap.pl\" for details on PDT syntax.\n";
X        exit( 1 );
X    }
X
X    # Process arguments from the command line, stopping at the first
X    # parameter without a leading dash, or a --.  Convert a parameter
X    # alias into its full form, type-check parameter values and store
X    # the value into global variables for use by the caller.  When
X    # complete call evap_fin to perform final processing.
X    
X  ARGUMENTS:
X    while ( $#ARGV >= $[) {
X	
X	$option = shift (@ARGV); # get next command line parameter
X	$value = undef;		# assume no value
X	
X	$full_help = 1 if $option =~ /^-(full_help|\?\?\?)$/;
X	$usage_help = 1 if $option =~ /^-(usage_help|\?\?)$/;
X	$option = '-help' if $full_help || $usage_help;
X	
X	if ( $option =~ /^(--|-)/ ) { # check for end of parameters
X	    if ( $option eq '--' ) {
X		return( &evap_fin );
X	    }
X	    $option = $';	# option name without dash
X	} else {		# not an option, push it back on the list
X	    unshift (@ARGV, $option);
X	    return( &evap_fin );
X	}
X	
X	foreach $alias (keys %P_ALIAS) { # replace any alias with the full parameter spelling
X	    $option = $alias if $option eq $P_ALIAS{$alias};
X	}
X	
X	if ( ! defined( $rt = $P_INFO{$option} ) ) {
X	    $found = 0;
X	    $length = length( $option );
X	    foreach $key (keys %P_INFO) { # try substring match
X		if ( $option eq substr( $key, $[, $length ) ) {
X		    if ( $found ) {
X			print STDERR "Ambiguous parameter: -$option.\n";
X			$error++;
X			last;
X		    }
X		    $found = $key; # remember full spelling
X		}
X	    } # forend
X	    $option = $found ? $found : $option;
X	    if ( ! defined( $rt = $P_INFO{$option} ) ) {
X		print STDERR "Invalid parameter: -$option.\n";
X		$error++;
X		next ARGUMENTS;
X	    }
X	} # ifend non-substring match
X	
X	($required, $type, $list) = ( $rt =~ /$pdt_reg_exp1/ ); # unpack encoded information
X	
X	if ( $type !~ /^w$/ ) {
X	    if ( $#ARGV < $[ ) { # if argument list is exhausted
X		print STDERR ("Value required for parameter -$option.\n");
X		$error++;
X		next ARGUMENTS;
X	    } else {
X		$value = shift (@ARGV);	# get argument value, then perform type-checking
X	    }
X	}
X	
X	if ( $type =~ /^w$/ ) { # switch
X	    $value = 1;
X	} elsif ( $type =~ /^i$/ ) { # integer
X	    if ( $value !~ /^[+-]?[0-9]+$/ ) {
X		print STDERR "Expecting integer reference, found \"$value\" for parameter -$option.\n";
X		$error++;
X		undef $value;
X	    }
X	} elsif ( $type =~ /^r$/ ) { # real number, int is also ok
X	    if ( $value !~ /^\s*[+-]?(\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?\s*$/ ) {
X		print STDERR "Expecting real reference, found \"$value\" for parameter -$option.\n";
X		$error++;
X		undef $value;
X	    }
X	} elsif ( $type =~ /^s$|^n$|^a$/ ) { # string (or name or application for evap/C compatibility)
X	} elsif ( $type =~ /^f$/ ) { # file
X	    if ( length( $value ) > 255 ) {
X		print STDERR "Expecting file reference, found \"$value\" for parameter -$option.\n";
X		$error++;
X		undef $value;
X	    }
X	} elsif ( $type =~ /^b$/ ) { # boolean
X	    $value =~ tr/a-z/A-Z/;
X	    if ( $value !~ /$pdt_reg_exp2|$pdt_reg_exp3/i ) {
X		print STDERR "Expecting boolean reference, found \"$value\" for parameter -$option.\n";
X		$error++;
X		undef $value;
X            }
X	} elsif ( $type =~ /^k$/ ) { # keyword
X	    #
X	    # First try exact match, then substring match.
X	    #
X	    undef( $found );
X	    @keys = split( ' ', $P_VALID_VALUES{$option} );
X	    for ( $i = 0; $i <= $#keys && ! defined( $found ); $i++ ) {
X		$found = 1 if $value eq $keys[$i];
X	    }
X	    if ( ! defined( $found ) ) { # try substring match
X		$length = length( $value );
X		for ( $i = 0; $i <= $#keys; $i++ ) {
X		    if ( $value eq substr( $keys[$i], $[, $length ) ) {
X			if ( defined( $found ) ) {
X			    print STDERR "Ambiguous keyword for parameter -$option: $value.\n";
X			    $error++;
X			    last; # for
X			}
X			$found = $keys[$i]; # remember full spelling
X		    }
X		} # forend
X		$value = defined( $found ) ? $found : $value;
X	    } # ifend
X	    if ( ! defined( $found ) ) {
X		print STDERR "\"$value\" is not a valid value for the parameter -$option.\n";
X		$error++;
X		undef $value;
X	    }
X	} # ifend type-check
X	
X	next ARGUMENTS if ! defined( $value );
X	    
X    	$list = '2' if $list =~ /^1$/; # list state = 2, empty list this time only
X        $variable_name_old = "${pkg}\'opt_${option}";
X        $vnn = "${pkg}\'options";
X        $vnn2 = "${pkg}\'Options";
X	&evap_set_value(1,  $type, $list, $value, $variable_name_old, $vnn, $vnn2, $option ) if defined( $value );
X	@P_REQUIRED = grep( $option ne $_, @P_REQUIRED ); # remove from $required list if specified
X	$P_INFO{$option} = $required . $type . '3' if $list; # list state = 3, don't empty list from now on
X
X    } # whilend ARGUMENTS
X    
X    return( &evap_fin );
X    
X} # end evap
X
X
X
X
Xsub evap'evap_fin {
X
X    #
X    # Finish up evaluate_parameters processing:
X    #
X    # If -usage_help, -help or -full_help was requested then do it and exit.  Else,
X    #   
X    #  . Store program name in `help' variables.
X    #  . Perform deferred evaluations.
X    #  . Ensure all $required parameters have been given a value.
X    #  . Ensure the validity of the trailing file list.
X    #  . Exit with a Unix return code of 1 if there were errors and $evap_embed = 0,
X    #    else return to the calling Perl program with a proper return code.
X    #
X    
X    package evap;
X    
X    local( $m, $p, $required, $type, $list, $def, $rt, $def, $element, $is_string, $pager, $do_page );
X
X    $variable_name = "\$${pkg}\'opt_help";
X
X    # Define Help Hooks text as required.
X
X    if ( ! defined( $evap_Help_Hooks{'P_HHURFL'} ) ) { $evap_Help_Hooks{'P_HHURFL'} = " file(s)\n"; }
X    if ( ! defined( $evap_Help_Hooks{'P_HHUOFL'} ) ) { $evap_Help_Hooks{'P_HHUOFL'} = " [file(s)]\n"; }
X    if ( ! defined( $evap_Help_Hooks{'P_HHUNFL'} ) ) { $evap_Help_Hooks{'P_HHUNFL'} = "\n"; }
X    if ( ! defined( $evap_Help_Hooks{'P_HHBRFL'} ) ) { $evap_Help_Hooks{'P_HHBRFL'} =
X							   "\nfile(s) required by this command\n\n"; }
X    if ( ! defined( $evap_Help_Hooks{'P_HHBOFL'} ) ) { $evap_Help_Hooks{'P_HHBOFL'} =
X							   "\n[file(s)] optionally required by this command\n\n"; }
X    if ( ! defined( $evap_Help_Hooks{'P_HHBNFL'} ) ) { $evap_Help_Hooks{'P_HHBNFL'} = "\n"; }
X    if ( ! defined( $evap_Help_Hooks{'P_HHERFL'} ) ) { $evap_Help_Hooks{'P_HHERFL'} =
X							   "Trailing file name(s) required.\n"; }
X    if ( ! defined( $evap_Help_Hooks{'P_HHENFL'} ) ) { $evap_Help_Hooks{'P_HHENFL'} =
X							   "Trailing file name(s) not permitted.\n"; }
X
X    if ( eval( $variable_name ) ) { # see if help was requested
X	
X	local( $optional );
X	local( %parameter_help ) = ();
X	local( $parameter_help_in_progress ) = 0;
X	local( %type_list ) = (
X			       'w', 'switch',
X			       'i', 'integer',
X			       's', 'string',
X			       'r', 'real',
X			       'f', 'file',
X			       'b', 'boolean',
X			       'k', 'key',
X			       'n', 'name',
X			       'a', 'application',
X			       );
X
X	# Establish the proper pager and open the pipeline.  Do no paging
X	# if the boolean environment variable D_EVAP_DO_PAGE is FALSE.
X
X	$pager = $ENV{'MANPAGER'} || $ENV{'PAGER'} || 'more';
X	$pager = '|' . $pager;
X	if ( defined( $ENV{'D_EVAP_DO_PAGE'} ) && (($do_page = $ENV{'D_EVAP_DO_PAGE'}) ne '') ) {
X	    $do_page =~ tr/a-z/A-Z/;
X	    if ( $do_page =~ /$pdt_reg_exp3/ ) {
X		$pager = '>-';
X	    }
X	}
X	open( PAGER, "$pager" );
X	
X	print PAGER "Command Source:  $0\n\n\n\n" if $full_help;
X
X	# Print the Message Module text and save any full help.  The key
X	# is the parameter name and the value is a list of strings with
X	# the newline as a separator.  If there is no Message Module or
X	# it's empty then display an abbreviated usage message.
X	
X        if ( $usage_help || ! defined( @MM ) || ($#MM < $[) ) {
X	    
X	    split( /\//, $0 );	# only basename for usage help
X	    print PAGER "\nUsage: ", $_[$#_];
X	    $optional = '';
X	    foreach $p (@P_PARAMETER) {
X		if ( $P_INFO{$p} =~ /^R..?$/ ) { # if $required
X		    print PAGER " -$P_ALIAS{$p}";
X		} else {
X		    $optional .= " -$P_ALIAS{$p}";
X		}
X	    } # forend
X	    print PAGER " [$optional]" if $optional;
X	    if ( $file_list =~ /$pdt_reg_exp5/ ) {
X		print PAGER "$evap_Help_Hooks{'P_HHUOFL'}";
X	    } elsif ( $file_list =~ /$pdt_reg_exp6/ ) {
X		print PAGER "$evap_Help_Hooks{'P_HHURFL'}";
X	    } else {
X		print PAGER "$evap_Help_Hooks{'P_HHUNFL'}";
X	    }
X	    
X        } else {
X	    
X	  MESSAGE_LINE:
X	    foreach $m (@MM) {
X		
X		if ( $m =~ /^\.(.*)$/ ) { # look for 'dot' leadin character
X		    $p = $1; # full spelling of parameter
X		    $parameter_help_in_progress = 1;
X		    $parameter_help{$p} = "\n";
X		    next MESSAGE_LINE;
X		} # ifend start of help text for a new parameter
X		if ( $parameter_help_in_progress ) { 
X		    $parameter_help{$p} .=  $m . "\n";
X		} else {
X		    print PAGER $m, "\n";
X		}
X		
X	    } # forend MESSAGE_LINE
X	    
X	} # ifend usage_help
X
X	# Pass through the PDT list printing a standard evap help summary.
X
X        print PAGER "\nParameters:\n";
X	if ( ! $full_help ) { print PAGER "\n"; }
X	
X      ALL_PARAMETERS:
X        foreach $p (@P_PARAMETER) {
X
X	    if ( $full_help ) { print PAGER "\n"; }
X	    
X	    if ( $p =~ /^help$/ ) {
X		print PAGER "-$p, $P_ALIAS{$p}, usage_help, full_help: Display Command Information\n";
X                if ( $full_help ) {
X         	    print PAGER "\n\tDisplay information about this command, which includes\n";
X		    print PAGER "\ta command description with examples, plus a synopsis of\n";
X		    print PAGER "\tthe command line parameters.  If you specify -full_help\n";
X		    print PAGER "\trather than -help complete parameter help is displayed\n";
X		    print PAGER "\tif it's available.\n";
X	        }
X		next ALL_PARAMETERS;
X	    }
X	    
X	    $rt = $P_INFO{$p};	# get encoded required/type information
X	    ($required, $type, $list) = ($rt =~ /$pdt_reg_exp1/); # unpack
X	    $type = $type_list{$type};
X	    $is_string = ( $type =~ /^string$/ );
X	    
X	    print PAGER "-$p, $P_ALIAS{$p}: ", $list ? 'list of ' : '', $type; 
X	    
X	    print PAGER " ", join( ', ', split( ' ', $P_VALID_VALUES{$p} ) ), ", keyend" if $type =~ /^key$/;
X	    
X            local( *glob ) = "$pkg".'\'opt_'.$p;
X	    if ( $list ) {
X                $def = defined( @glob ) ? 1 : 0;
X	    } else {
X                $def = defined( $glob ) ? 1 : 0;
X            }
X    
X	    if ( ($required =~ /^O$/) || ( $def == 1) ) { # if $optional or defined
X		
X                if ( $def == 0 ) { # undefined and $optional
X    		    print PAGER "\n";
X                } else {	# defined (either $optional or $required), display the default value(s)
X                    if ( $list ) {
X			print PAGER $P_ENV{$p} ? " = $P_ENV{$p}, " : " = ";
X			print PAGER $is_string ? "(\"" : "(", $is_string ? join( '", "', @glob ) : join( ', ', @glob),
X			      $is_string ? "\")\n" : ")\n";
X                    } else {	# not 'list of'
X			print PAGER $P_ENV{$p} ? " = $P_ENV{$p}, " : " = ";
X			print PAGER $is_string ? "\"" : "", $glob, $is_string ? "\"\n" : "\n";
X                    } # ifend 'list of'
X                } # ifend
X		
X	    } elsif ( $required =~ /R/ ) {
X		print PAGER $P_ENV{$p} ? " = $P_ENV{$p}, " : " = ";
X		print PAGER "\$required\n";
X	    } else {
X		print PAGER "\n";
X	    } # ifend $optional or defined parameter
X	    
X            if ( $full_help ) {
X		if ( defined( $parameter_help{$p} ) ) {
X		    print PAGER "$parameter_help{$p}";
X		} else {
X		    print PAGER "\n";
X		}
X	    }
X	    
X	} # forend ALL_PARAMETERS
X
X	if ( $file_list =~ /$pdt_reg_exp5/ ) {
X	    print PAGER "$evap_Help_Hooks{'P_HHBOFL'}";
X	} elsif ( $file_list =~ /$pdt_reg_exp6/ ) {
X	    print PAGER "$evap_Help_Hooks{'P_HHBRFL'}";
X	} else {
X	    print PAGER "$evap_Help_Hooks{'P_HHBNFL'}";
X	}
X
X	close( PAGER );
X	if ( $evap_embed ) {
X	    return( -1 );
X	} else {
X	    exit( 0 );
X	}
X	
X    } # ifend help requested
X
X    # Evaluate remaining unspecified command line parameters.  This has been deferred until now so that
X    # if -help was requested the user sees unevaluated boolean, file and backticked values.
X
X    foreach $parameter (@P_PARAMETER) {
X	if ( ! $P_EVALUATE{$parameter} && $P_DEFAULT_VALUE{$parameter} ) {
X	    ($required, $type, $list) = ($P_INFO{$parameter} =~ /$pdt_reg_exp1/);
X	    if ( $type ne 'w' ) {
X		$variable_name_old = "${pkg}\'opt_${parameter}";
X		$vnn = "${pkg}\'options";
X		$vnn2 = "${pkg}\'Options";
X		$list = 2 if $list; # force re-initialization of the list
X		&evap_set_value(1, $type, $list, $P_DEFAULT_VALUE{$parameter}, $variable_name_old, $vnn, $vnn2,	$parameter );
X	    } # ifend non-switch
X	} # ifend not specified
X    } # forend all PDT parameters
X
X    # Store program name for caller.
X
X    $variable_name_old = "${pkg}\'opt_help";
X    $vnn = "${pkg}\'options";
X    $vnn2 = "${pkg}\'Options";
X    &evap_set_value(0,  'w', '', $0, $variable_name_old, $vnn, $vnn2, 'help' ); # initialize program name
X    
X    # Ensure all $required parameters have been specified on the command line.
X
X    foreach $p (@P_REQUIRED) {
X	print STDERR "Parameter $p is required but was omitted.\n";
X	$error++;
X    } # forend
X    
X    # Ensure any required files follow, or none do if that is the case.
X
X    if ( $file_list =~ /$pdt_reg_exp4/ && $#ARGV > $[ - 1 ) {
X        print STDERR "$evap_Help_Hooks{'P_HHENFL'}";
X        $error++;
X    } elsif ( $file_list =~ /$pdt_reg_exp6/ && $#ARGV == $[ - 1 ) {
X        print STDERR "$evap_Help_Hooks{'P_HHERFL'}";
X        $error++;
X    }
X    
X    print STDERR "Type $0 -? for command line parameter information.\n" if $error;
X
X    exit( 1 ) if $error && ! $evap_embed;
X    if ( ! $error ) {
X	return( 1 );
X    } else {
X	return( 0 );
X    }
X    
X} # end evap_fin
X
X
X
X
Xsub evap'evap_PDT_error {
X
X    #
X    # Inform the application developer that they've screwed up!
X    #
X
X    package evap;
X
X    local( $msg ) = @_;
X
X    print STDERR "$msg";
X    $error++;
X    next OPTIONS;
X
X} # end evap_PDT_error
X   
X
X
X
Xsub evap'evap_set_value {
X    
X    #
X    # Store a parameter's value; some parameter types require special type
X    # conversion.  Store values the old way in scalar/list variables of the
X    # form $opt_parameter and @opt_parameter, as well as the new way in an
X    # associative arrays named %options and %Options.  In Perl 5 'list of'
X    # parameters are returned as a reference in %options/%Options; in Perl 4
X    # these parameters are returned as a string 'joined' with the multi-
X    # dimensional array emulation character ($;).
X    #
X    # Evaluate items in grave accents (backticks), boolean and files if
X    # `evaluate' is TRUE.
X    #
X    # Handle list syntax (item1, item2, ...) for 'list of' types.
X    #
X    # Lists are a little weird as they may already have default values from the
X    # PDT declaration. The first time a list parameter is specified on the
X    # command line we must first empty the list of its default values.  The
X    # P_INFO list flag thus can be in one of three states: 1 = the list has
X    # possible default values from the PDT, 2 = first time for this command
X    # line parameter so empty the list and THEN push the parameter's value, and
X    # 3 = from now just keep pushing new command line values on the list.
X    #
X    
X    package evap;    
X    
X    local( $evaluate, $type, $list, $v, *parameter_old, *parameter_new, *parameter_new2, $parameter_new_hash ) = @_;
X    local( $value, @values );
X
X    if ( $list =~ /^2$/ ) {	# empty list of default values
X	@parameter_old = ();
X	if ( $Perl_version_major == 5 ) {
X            eval "\$parameter_new{\$parameter_new_hash} = \\\@parameter_old";
X            eval "\$parameter_new2{\$parameter_new_hash} = \\\@parameter_old";
X        } else {
X            $parameter_new{$parameter_new_hash} = '';
X            $parameter_new2{$parameter_new_hash} = '';
X        }
X    }
X
X    if ( $list && $v =~ /^\(+.*\)+$/ ) { # check for list
X	@values = eval "$v"; # let Perl do the walking
X    } else {
X	$v =~ s/["|'](.*)["|']/$1/; # remove any bounding superfluous quotes
X	@values = $v;		# a simple scalar	
X    } # ifend initialize list of values
X
X    foreach $value (@values) {
X
X        if ( $evaluate ) {
X            $P_EVALUATE{$parameter_new_hash} = 'evaluated';
X            $value =~ /^(`*)([^`]*)(`*)$/; # check for backticks
X	    chop( $value = `$2` ) if $1 eq '`' && $3 eq '`';
X	    if ( ! $DOS && $type =~ /^f$/ ) {
X                local( @path ) = split( /\//, $value );
X	        if ( $value =~ /^stdin$/ ) {
X                    $value = '-';
X                } elsif ( $value =~ /^stdout$/ ) {
X                    $value = '>-';
X                } elsif ( $path[$[] =~ /(^~$|^\$HOME$)/ ) {
X		    $path[$[] = $ENV{'HOME'};
X                    $value = join( '/', @path );
X                }
X            } # ifend file type
X
X            if ( $type =~ /^b$/ ) {
X	        $value = '1' if $value =~ /$evap'pdt_reg_exp2/i;
X	        $value = '0' if $value =~ /$evap'pdt_reg_exp3/i;
X            } # ifend boolean type
X        } # ifend evaluate
X
X        if ( $list ) {		# extend list with new value
X	    push( @parameter_old, $value );
X	    if ( $Perl_version_major == 5 ) {
X                eval "\$parameter_new{\$parameter_new_hash} = \\\@parameter_old";
X                eval "\$parameter_new2{\$parameter_new_hash} = \\\@parameter_old";
X            } else {
X	        $parameter_new{$parameter_new_hash} = '' unless defined( $parameter_new{$parameter_new_hash} );
X                $parameter_new{$parameter_new_hash} .= ($parameter_new{$parameter_new_hash} ? $; : '') . $value;
X	        $parameter_new2{$parameter_new_hash} = '' unless defined( $parameter_new2{$parameter_new_hash} );
X                $parameter_new2{$parameter_new_hash} .= ($parameter_new2{$parameter_new_hash} ? $; : '') . $value;
X            }
X        } else {		# store scalar value
X	    $parameter_old = $value;
X            $parameter_new{$parameter_new_hash} = $value;
X            $parameter_new2{$parameter_new_hash} = $value;
X        }
X
X    } # forend
X	
X} # end evap_set_value
X
X
X
X
Xsub evap_pac {
X
X    #
X    # Process Application Commands
X    #
X    # An application command can be envoked by entering either its full spelling or the alias.
X    #
X
X    local( $prompt, $I, %cmds ) = @_;
X    local( $proc, $args, %long, %alias, $name, $long, $alias );
X
X    require "shellwords.pl";
X
X    $evap'evap_embed = 1;	# enable embedding
X    $evap'shell = ( defined( $ENV{'SHELL'} ) && $ENV{'SHELL'} ne '' ) ? $ENV{'SHELL'} : '/bin/sh';
X    $cmds{'display_application_commands|disac'} = "evap'evap_disac_proc( %cmds )";
X    $cmds{'!'} = "evap'evap_bang_proc";
X
X    # First, create new associative command name arrays with full/alias names.
X
X    foreach $name ( keys %cmds ) {
X        if ( $name =~ /\|/ ) {
X            ($long, $alias) = ($name =~ /(.*)\|(.*)/);
X	    $long{$long} = $cmds{$name};
X	    $alias{$alias} = $cmds{$name};
X        } else {
X	    $long{$name} = $cmds{$name};
X	}
X    }
X
X    print STDOUT "$prompt";
X
X  GET_USER_INPUT:
X    while ( <$I> ) {
X
X	next GET_USER_INPUT if /^\s*$/;	# ignore empty input lines
X
X	if ( /^\s*!(.+)/ ) {
X	    $_ = '! ' . $1;
X	}
X
X        ($0, $args) = /\s*(\S+)\s*(.*)/;
X	if ( defined( $long{$0} ) ) {
X	    $proc = $long{$0};
X	} elsif ( defined( $alias{$0} ) ) {
X	    $proc = $alias{$0};
X	} else  {
X            print STDERR "Error - unknown command `$0'.  Type \"disac -do f\" for a\n";
X	    print STDERR "list of valid application commands.  You can then ...\n\n";
X            print STDERR "Type \"xyzzy -?\" for help on application command `xyzzy'.\n";
X	    next GET_USER_INPUT;
X        }
X	
X	if ( $0 eq '!' ) {
X	    @ARGV = $args;
X	} else {
X	    @ARGV = &shellwords( $args );
X	}
X        eval "&$proc;";		# call the evap/user procedure
X	print STDERR $@ if $@;
X
X    } # whilend GET_USER_INPUT
X    continue { # while GET_USER_INPUT
X        print STDOUT "$prompt";
X    } # continuend
X    print STDOUT "\n";
X
X} # end evap_pac
X
X 
X
X
Xsub evap'evap_bang_proc {
X    
X    #
X    # Issue one or more commands to the user's shell.  If the SHELL environment
X    # variable is not defined or is empty, then /bin/sh is used.
X    #
X
X    package evap;
X
X    local( $cmd ) = $main'ARGV[$[];
X    return if $cmd eq '';
X
X    &evap_setup_for_evap( "evap", "bang" );
X    $evap_Help_Hooks{'P_HHUOFL'} = " Command(s)\n";
X    $evap_Help_Hooks{'P_HHBOFL'} = "\nA list of shell Commands.\n\n";
X    if ( &main'evap( *PDT, *MM ) != 1 ) { return; }
X
X    system( "$evap'shell -c '$cmd'" );
X
X} # end evap_bang_proc
X
X 
X
X
Xsub evap'evap_disac_proc {
X    
X    #
X    # Display the list of legal application commands.
X    #
X
X    package evap;
X
X    local( %commands ) = @_;
X    local( @brief, @full, $name, $long, $alias );
X
X    &evap_setup_for_evap( "evap", "disac" );
X    if ( &main'evap( *PDT, *MM ) != 1 ) { return; }
X
X    foreach $name ( keys %commands ) {
X        if ( $name =~ /\|/ ) {
X            ($long, $alias) = ($name =~ /(.*)\|(.*)/);
X        } else {
X	    $long = $name;
X            $alias = '';
X	}
X        push( @brief, $long );
X        push( @full, ($alias ne '') ? "$long, $alias" : "$long" );
X    }
X
X    open( H, ">$Options{'output'}" );
X    if ( $Options{'display_option'} eq 'full' ) {
X        print H "\nCommands and aliases for this application:\n\n";
X	print H "  ", join( "\n  ", sort( @full ) ), "\n";
X    } else {
X        print H join( "\n", sort( @brief ) ), "\n";
X    }
X    close( H );
X
X} # end evap_disac_proc
X
X 
X
X
Xsub evap'evap_setup_for_evap {
X    
X    #
X    # Initialize evap_pac's builtin commands' PDT/MM variables.
X    #
X
X    package evap;
X
X    local( $pkg, $command ) = @_;
X
X    open( IN, "ar p $message_modules ${command}_pdt|" );
X    eval "@${pkg}'PDT = <IN>;";                        # initialize Parameter Description Table
X    close( IN );
X    open( IN, "ar p $message_modules ${command}.mm|" );
X    eval "@${pkg}'MM = grep( \$@ = s/\n\$//, <IN> );"; # initialize Message Module
X    close( IN );
X
X} # end evap_setup_for_evap
X
X
X
X
X1;
END_OF_FILE
if test 30832 -ne `wc -c <'src/evap.pl'`; then
    echo shar: \"'src/evap.pl'\" unpacked with wrong size!
fi
# end of 'src/evap.pl'
fi
if test -f 'src/evap.tcl' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/evap.tcl'\"
else
echo shar: Extracting \"'src/evap.tcl'\" \(30094 characters\)
sed "s/^X//" >'src/evap.tcl' <<'END_OF_FILE'
X#
X# evap.tcl - evaluate_parameters 2.1 for Tcl
X#
X# lusol@lehigh.EDU, 94/05/14
X#
X# Made to conform, as much as possible, to the C function evap. The C, Perl
X# and Tcl versions of evap are patterned after the Control Data procedure
X# CLP$EVALUATE_PARAMETERS for the NOS/VE operating system, although neither
X# approaches the richness of CDC's implementation.
X#
X# Availability is via anonymous FTP from ftp.Lehigh.EDU (128.180.63.4) in the
X# directory pub/evap/evap-2.x.
X#
X# Stephen O. Lidie, Lehigh University Computing Center.
X#
X# Copyright (C) 1994 - 1994 by Stephen O. Lidie and Lehigh University.
X# All rights reserved.
X#
X# For related information see the evap/C header file evap.h.  Complete
X# help can be found in the man pages evap(2), evap.c(2), evap.pl(2),
X# evap.tcl(2) and evap_pac(2).
X#     
X# 
X#                           Revision History 
X#
X# lusol@Lehigh.EDU 94/03/14 (PDT version 2.0)  Version 2.1
X#   . Original release - similar to version 2.1 of the C and Perl functions
X#     evap.
X#
X# $Id: evap.tcl,v 2.1.0.9 1994/06/02 15:25:35 lusol Exp $
X#
X
X
Xproc evap { PDT MM {QUAL ""} } {
X
X    global evap_QUAL evap_message_modules
X    set evap_QUAL $QUAL
X    set evap_message_modules "./libevapmm.a"
X    global argc argv0 argv env ${evap_QUAL}options ${evap_QUAL}Options evap_embed
X    if { ! [info exists evap_embed] } { set evap_embed 0 }
X    global evap_PARAMETER evap_INFO evap_ALIAS evap_REQUIRED evap_VALID_VALUES evap_ENV evap_EVALUATE evap_DEFAULT_VALUE
X
X    if { $evap_embed } {
X	catch {unset ${evap_QUAL}opt_help}
X	catch {unset ${evap_QUAL}Options(help)}
X	catch {unset ${evap_QUAL}options(help)}
X	unset evap_PARAMETER
X	unset evap_INFO
X	unset evap_ALIAS
X	unset evap_REQUIRED
X	unset evap_VALID_VALUES
X	unset evap_ENV
X	unset evap_EVALUATE
X	unset evap_DEFAULT_VALUE
X    }
X
X    set evap_PARAMETER {};                                               # no parameter names
X    set evap_INFO() {};                                                  # no encoded parameter information
X    set evap_ALIAS() {};                                                 # no aliases
X    set evap_REQUIRED {};                                                # no required parameters
X    set evap_VALID_VALUES() {};                                          # no keywords
X    set evap_ENV() {};                                                   # no default environment variables
X    set evap_EVALUATE() {};                                              # no PDT values evaluated yet
X    set evap_DEFAULT_VALUE() {};                                         # no default values yet
X
X    global evap_DOS;             set evap_DOS 0;                         # 1 IFF MS-DOS beast
X    global evap_error;           set evap_error 0;                       # no PDT parsing or command line errors 
X    global evap_full_help;       set evap_full_help 0;                   # full_help flag
X    global evap_usage_help;      set evap_usage_help 0;                  # usage_help flag
X    global evap_file_list;       set evap_file_list {optional_file_list};# file_list flag
X
X    global evap_d;               set evap_d "\[0-9\]";                   # simulate Perl's \d, match digit
X    global evap_D;               set evap_D "\[^0-9\]";                  # simulate Perl's \D, match non-digit
X    global evap_s;               set evap_s "\[ \t\n\r\f\]";             # simulate Perl's \s, match whitespace
X    global evap_S;               set evap_S "\[^ \t\n\r\f\]";            # simulate Perl's \S, match non-whitespace
X    global evap_w;               set evap_w "\[0-9a-z_A-Z]";             # simulate Perl's \w, match word
X    global evap_W;               set evap_W "\[^0-9a-z_A-Z]";            # simulate Perl's \W, match non-word
X
X    global evap_pdt_reg_exp1;    set evap_pdt_reg_exp1 {^(.)(.)(.?)$}
X    global evap_pdt_reg_exp2;    set evap_pdt_reg_exp2 {^TRUE$|^YES$|^ON$|^1$}
X    global evap_pdt_reg_exp3;    set evap_pdt_reg_exp3 {^FALSE$|^NO$|^OFF$|^0$}
X    global evap_pdt_reg_exp4;    set evap_pdt_reg_exp4 "^$evap_s*no_file_list$evap_s*\$"
X    global evap_pdt_reg_exp5;    set evap_pdt_reg_exp5 "^$evap_s*optional_file_list$evap_s*\$"
X    global evap_pdt_reg_exp6;    set evap_pdt_reg_exp6 "^$evap_s*required_file_list$evap_s*\$"
X    global evap_pdt_reg_exp7;    set evap_pdt_reg_exp7 "^$evap_s*list$evap_s+of$evap_s+"
X
X    set local_pdt $PDT
X    set local_pdt [linsert $PDT 0 {help, ?: switch}];                # supply -help automatically
X
X    foreach option $local_pdt {
X
X	if { [regexp -nocase "^#.*|$evap_s*PDT$evap_s+|PDT\$" $option] } { continue }
X	regsub -nocase "^$evap_s*PDTEND" $option {} option
X	if { [regexp {^ ?$} $option] } { continue }
X
X	if { [regexp "$evap_pdt_reg_exp4|$evap_pdt_reg_exp5|$evap_pdt_reg_exp6" $option] } {
X	    set evap_file_list $option
X	    continue
X	}
X
X	catch {unset parameter alias rest}
X	regexp "^$evap_s*($evap_S*)$evap_s*,$evap_s*($evap_S*)$evap_s*:$evap_s*(.*)$" $option ignore parameter alias rest;
X	if { ! [info exists parameter] || ! [info exists alias] || ! [info exists rest] } {
X	    EvaP_PDT_error "Error in an evaluate_parameters 'parameter, alias: type' option specifiction:  \"$option\"."
X	    continue
X	}
X	if { [info exists evap_INFO($parameter)] } {
X	    EvaP_PDT_error "Duplicate parameter $parameter: \"$option\"."
X	    continue
X	}
X	lappend evap_PARAMETER $parameter
X
X	catch {unset type}
X	regexp "($evap_pdt_reg_exp7)*$evap_s*(switch|integer|string|real|file|boolean|key|name|application)$evap_s*(.*)" \
X	    $rest ignore list type rest
X	if { ! [info exists type] } {
X	    EvaP_PDT_error "Parameter $parameter has an undefined type:  \"$option\"."
X	    continue
X	}
X	if { $list != "" && ! [regexp "$evap_pdt_reg_exp7" $list] } {
X	    EvaP_PDT_error "Expecting 'list of', found:  \"$list\"."
X	    continue
X	}
X	set list [expr { ($list != "") ? 1 : 0 }]
X	if { $type == {switch} } { set type {w} }
X	set type [string range $type 0 0]
X
X	set default_value {}
X	regexp "$evap_s*=$evap_s*(.*)" $rest ignore default_value
X	if { [regexp "^\(\[^\(\]\)($evap_w*)$evap_s*,$evap_s*(.*)" $default_value ignore p1 p2 p3] } {
X	    set default_value $p3
X	    set evap_ENV($parameter) "$p1$p2"
X	}
X
X	set required [expr { ($default_value == {$required}) ? "R" : "O" }]
X	set evap_INFO($parameter) "$required$type$list"
X	if { $required == "R" } { lappend evap_REQUIRED $parameter }
X
X	if { $type == "k" } {
X	    regsub {keyend.*} $rest {} rest
X	    regsub -all {,} $rest {} rest
X	    set rest [string trim $rest]
X	    regsub -all { +} $rest { } evap_VALID_VALUES($parameter)
X	    
X	}
X
X	set alias_error 0
X	foreach value [array name evap_ALIAS] {
X	    if { $alias == $evap_ALIAS($value) } {
X		EvaP_PDT_error "Duplicate alias $alias:  \"$option\"."
X		set alias_error 1
X	    }
X	}
X	if { $alias_error } { continue }
X	set evap_ALIAS($parameter) $alias
X
X	if { [regexp {^.w1$} $evap_INFO($parameter)] } {
X	    EvaP_PDT_error "Cannot have 'list of' switch:  \"$option\"."
X	    continue
X	}
X
X	if { $default_value != ""  && $default_value != {$required} } {
X	    if { [info exists env(evap_ENV($parameter))] } {
X		if { $env($evap_ENV($parameter)) != "" } {
X		    set default_value $env($evap_ENV($parameter))
X		}
X	    }
X	    set evap_DEFAULT_VALUE($parameter) $default_value
X	    EvaP_set_value 0 $type $list $default_value $parameter
X	}
X
X    }; # forend options
X
X    if { $evap_error } {
X	puts stderr "Inspect the file \"evap.tcl\" for details on PDT syntax."
X	exit 1
X    }
X
X    while { $argc > 0 } {
X
X	incr argc -1
X	set option [lindex $argv 0]
X	set argv [lreplace $argv 0 0]
X	catch {unset value}
X
X	if { [regexp {^-(full_help|\?\?\?)$} $option] } { set evap_full_help 1 }
X	if { [regexp {^-(usage_help|\?\?)$}  $option] } { set evap_usage_help 1 }
X	if { $evap_full_help || $evap_usage_help } { set option {-help} }
X	
X	if { [regexp {^(--|-)(.*)} $option p1 p2 p3] } {
X	    if { $option == {--} } {
X		return [EvaP_fin $MM]
X	    }
X	    set option $p3
X	} else {
X	    set argv [linsert $argv 0 $option]
X	    incr argc 1
X	    return [EvaP_fin $MM]
X	}
X
X	foreach alias [array names evap_ALIAS] {
X	    if { $option == $evap_ALIAS($alias) } { set option $alias }
X	}
X
X	if { ! [info exists evap_INFO($option)] } {
X	    set found 0
X	    set length [string length $option]
X	    foreach key [array names evap_INFO] {
X		if { $option == [string range $evap_INFO($key) 0 [expr $length - 1]] } {
X		    if { $found } {
X			puts stderr "Ambiguous parameter: -$option."
X			incr evap_error 1
X			break; # substring search
X		    }
X		    set found $key
X		}
X	    }; # forend substring search for parameter
X	    set option [expr { ($found != 0) ? $found : $option } ]
X	    if { ! [info exists evap_INFO($option)] } {
X		puts stderr "Invalid parameter: -$option."
X		incr evap_error 1
X		continue; # arguments
X	    }
X	}; # ifend substring search
X
X	regexp "$evap_pdt_reg_exp1" $evap_INFO($option) ignore required type list
X
X	if { $type != {w} } {
X	    if { $argc <= 0 } {
X		puts stderr "Value required for parameter -$option."
X		incr evap_error 1
X		continue; # arguments
X	    } else {
X		set value [lindex $argv 0]
X		set argv [lreplace $argv 0 0]
X		incr argc -1
X	    }
X	}
X
X	switch -exact $type {
X
X	    {w} {; # switch
X		set value 1
X	    }
X
X	    {i} {; # integer
X		if { ! [regexp {^[+-]?[0-9]+$} $value] } {
X		    puts stderr "Expecting integer reference, found \"$value\" for parameter -$option."
X		    incr evap_error 1
X		    unset value
X		}
X	    }
X
X	    {r} {; # real
X		if { ! [regexp "^$evap_s*\[+-\]?($evap_d+(\.$evap_d*)?|\.$evap_d+)(\[eE\]\[+-\]?$evap_d+)?$evap_s*\$" $value] } {
X		    puts stderr "Expecting real reference, found \"$value\" for parameter -$option."
X		    incr evap_error 1
X		    unset value
X		}
X	    }
X
X	    {s} {; # string
X	    }
X
X	    {n} {; # name
X	    }
X
X	    {a} {; # application
X	    }
X
X	    {f} {; # file
X		if { [string length $value] > 255 } {
X		    puts stderr "Expecting file reference, found \"$value\" for parameter -$option."
X		    incr evap_error 1
X		    unset value
X		}
X	    }
X
X	    {b} { ; # boolean
X		if { ! [regexp -nocase "$evap_pdt_reg_exp2|$evap_pdt_reg_exp3" $value] } {
X		    puts stderr "Expecting boolean, found \"$value\" for parameter -$option."
X		    incr evap_error 1
X		    unset value
X		}
X	    }
X
X	    {k} {; # keyword - first try an exact match, then a substring match
X		catch {unset found}
X		set keys [split $evap_VALID_VALUES($option) { }]
X		for {set i 0} {$i < [llength $keys] && ! [info exists found]} {incr i 1} {
X		    set key [lindex $keys $i]
X		    if { $value == $key } { set found 1 }
X		}
X		if { ! [info exists found] } {
X		    set length [string length $value]
X		    for {set i 0} {$i < [llength $keys]} {incr i 1} {
X			set key [lindex $keys $i]
X			if { $value == [string range $key 0 [expr $length - 1]] } {
X			    if { [info exists found] } {
X				puts stderr "Ambiguous keyword for parameter -$option: $value."
X				incr evap_error 1
X				break
X			    }
X			    set found $key
X			}
X		    }; # forend
X		    set value [expr { ([info exists found]) ? $found : $value } ]
X		}; # ifend
X		if { ! [info exists found] } {
X		    puts stderr "\"$value\" is not a valid value for the parameter -$option."
X		    incr evap_error 1
X		    unset value
X		}
X	    }
X
X	}; # switchend
X
X	if { ! [info exists value] } { continue }
X
X	if { $list == 1 } { set list 2 }
X	EvaP_set_value 1 $type $list $value $option
X	set index [lsearch $evap_REQUIRED $option]
X	if { $index != -1 } { set evap_REQUIRED [lreplace $evap_REQUIRED $index $index] }
X	if { $list } { set evap_INFO($option) "$required${type}3" }
X
X    }; # whilend arguments
X
X    return [EvaP_fin $MM]
X	
X}; # end evap
X
X
X
X
Xproc EvaP_fin {MM} {
X
X    #
X    # Finish up evaluate_parameters processing:
X    #
X    # If -usage_help, -help or -full_help was requested then do it and exit.  Else,
X    #
X    #  . Store program name in help variables.
X    #  . Perform deferred evaluations.
X    #  . Ensure all $required parameters have been given a value.
X    #  . Ensure the validity of the trailing file list.
X    #  . Exit with a Unix return code of 1 if there were errors and $evap_embed = 0,
X    #    else return to the calling Tcl program with a proper return code.
X    #
X
X    global evap_QUAL
X    global evap_embed ${evap_QUAL}options ${evap_QUAL}Options ${evap_QUAL}opt_help
X    global evap_error evap_full_help evap_usage_help argv0 evap_PARAMETER evap_INFO evap_ALIAS evap_pdt_reg_exp5
X    global evap_d evap_D evap_s evap_S evap_w evap_W evap_pdt_reg_exp4 evap_pdt_reg_exp3 env evap_Help_Hooks evap_pdt_reg_exp6
X    global evap_file_list evap_pdt_reg_exp1 evap_VALID_VALUES evap_ENV evap_EVALUATE evap_DEFAULT_VALUE evap_REQUIRED argc
X
X    # Define Help Hooks text as required.
X
X    if { ! [info exists evap_Help_Hooks(P_HHURFL)] } { set evap_Help_Hooks(P_HHURFL) " file(s)\n" }
X    if { ! [info exists evap_Help_Hooks(P_HHUOFL)] } { set evap_Help_Hooks(P_HHUOFL) " \[file(s)\]\n" }
X    if { ! [info exists evap_Help_Hooks(P_HHUNFL)] } { set evap_Help_Hooks(P_HHUNFL) "\n" }
X    if { ! [info exists evap_Help_Hooks(P_HHBRFL)] } { set evap_Help_Hooks(P_HHBRFL) \
X                                                            "\nfile(s) required by this command\n\n" }
X    if { ! [info exists evap_Help_Hooks(P_HHBOFL)] } { set evap_Help_Hooks(P_HHBOFL) \
X                                                            "\n\[file(s)\] optionally required by this command\n\n" }
X    if { ! [info exists evap_Help_Hooks(P_HHBNFL)] } { set evap_Help_Hooks(P_HHBNFL) "\n" }
X    if { ! [info exists evap_Help_Hooks(P_HHERFL)] } { set evap_Help_Hooks(P_HHERFL) \
X                                                            "Trailing file name(s) required.\n" }
X    if { ! [info exists evap_Help_Hooks(P_HHENFL)] } { set evap_Help_Hooks(P_HHENFL) \
X                                                            "Trailing file name(s) not permitted.\n" }
X
X    if { [info exists ${evap_QUAL}Options(help)] } {
X
X	set type_list(w) switch
X	set type_list(i) integer
X	set type_list(s) string
X	set type_list(r) real
X	set type_list(f) file
X	set type_list(b) boolean
X	set type_list(k) key
X	set type_list(n) name
X	set type_list(a) application
X
X	# Establish the proper pager and open the pipeline.  Do no paging
X	# if the boolean environment variable D_EVAP_DO_PAGE is FALSE.
X
X	set PAGER "more"
X	if { [info exists env(PAGER)] } {
X	    if { $env(PAGER) != "" } { set PAGER "$env(PAGER)" }
X	}
X	if { [info exists env(MANPAGER)] } {
X	    if { $env(MANPAGER) != "" } { set PAGER "$env(MANPAGER)" }
X	}
X	set PAGER "|$PAGER"
X	if { [info exists env(D_EVAP_DO_PAGE)] } {
X	    if { $env(D_EVAP_DO_PAGE) != "" } {
X		if { [regexp -nocase "$evap_pdt_reg_exp3" $env(D_EVAP_DO_PAGE)] } {
X		    set PAGER "stdout"
X		}
X	    }
X	}
X	if { $PAGER != "stdout" } { set PAGER [open "$PAGER" "w"] }
X
X	if { $evap_full_help } { puts -nonewline $PAGER "Command Source:  $argv0\n\n\n\n" }
X	
X	# Print the Message Module text and save any full help.  The key
X	# is the parameter name and the value is a list of strings with
X	# the newline as a separator.  If there is no Message Module or
X	# it's empty then display an abbreviated usage message.
X
X	if { $evap_usage_help || ! [info exists MM] || [llength $MM] <= 0 } {
X
X	    set basename [split $argv0 /]; # only basename for usage help
X	    puts -nonewline $PAGER "\nUsage: [lindex $basename [expr [llength $basename] - 1]]"
X	    set optional {}
X	    foreach p $evap_PARAMETER {
X		if { [regexp {^R..?$} $evap_INFO($p)] } {; # if $required
X		    puts -nonewline $PAGER " -$evap_ALIAS($p)";
X		} else {
X		    append optional " -$evap_ALIAS($p)"
X		}
X	    }
X	    if { $optional != {} } { puts -nonewline $PAGER " \[$optional\]" }
X	    if { [regexp "$evap_pdt_reg_exp5" $evap_file_list] } {
X	        puts -nonewline $PAGER "$evap_Help_Hooks(P_HHUOFL)"
X	    } elseif { [regexp "$evap_pdt_reg_exp6" $evap_file_list] } {
X		puts -nonewline $PAGER "$evap_Help_Hooks(P_HHURFL)"
X	    } else {
X		puts -nonewline $PAGER "$evap_Help_Hooks(P_HHUNFL)"
X	    }
X
X	} else {
X
X	    set parameter_help_in_progress 0
X	    foreach m $MM {
X		if { [regexp {^\.(.*)$} $m ignore p] } {; # look for `dot' leadin character
X		    set parameter_help_in_progress 1
X		    set parameter_help($p) "\n"
X		    continue
X		}
X		if { $parameter_help_in_progress } {
X		    append parameter_help($p) "$m\n"
X		} else {
X		    puts -nonewline $PAGER "$m\n"
X		}
X	    }; # forend all lines in Message Module
X
X	}; # ifend usage_help
X
X	# Pass throught the PDT list printing a standard EvaP help summary.
X
X	puts -nonewline $PAGER "\nParameters:\n"
X	if { ! $evap_full_help } { puts -nonewline $PAGER "\n" }
X
X	foreach p $evap_PARAMETER {
X
X	    if { $evap_full_help } { puts -nonewline $PAGER "\n" }
X	    
X	    if { $p == {help} } {
X		puts -nonewline $PAGER "-$p, $evap_ALIAS($p), usage_help, full_help: Display Command Information\n"
X		if { $evap_full_help } {
X		    puts -nonewline $PAGER "\n\tDisplay information about this command, which includes\n"
X		    puts -nonewline $PAGER "\ta command description with examples, plus a synopsis of\n"
X		    puts -nonewline $PAGER "\tthe command line parameters.  If you specify -full_help\n"
X		    puts -nonewline $PAGER "\trather than -help complete parameter help is displayed\n"
X		    puts -nonewline $PAGER "\tif it's available.\n"
X		}
X		continue; # foreach parameter
X	    }
X
X	    regexp "$evap_pdt_reg_exp1" $evap_INFO($p) ignore required type list
X	    set type $type_list($type)
X	    set is_string [expr { ($type == {string}) ? 1 : 0 }]
X
X	    puts -nonewline $PAGER "-$p, $evap_ALIAS($p): [expr { $list ? "list of " : "" }]$type"
X
X	    if { $type == {key} } {
X		puts -nonewline $PAGER " [join [split $evap_VALID_VALUES($p) " "] ", "], keyend"
X	    }
X
X	    global ${evap_QUAL}opt_$p
X	    set def [info exists ${evap_QUAL}opt_$p]
X	    
X	    if { [regexp {^O$} $required] || $def } {; # if $optional or defined
X		
X		if { ! $def } {; # undefined and $optional
X		    puts -nonewline $PAGER "\n"
X		} else {; # defined (either $optional or $required), display default value(s)
X		    set value [set ${evap_QUAL}opt_$p]
X		    if { $list } {
X			puts -nonewline $PAGER "[expr { [info exists evap_ENV($p)] ? " = $evap_ENV($p), " : " = " }]"
X			puts -nonewline $PAGER "[expr { $is_string ? "(\"" : "(" }][ \
X                                            expr { $is_string ? [join $value "\", \""] : [join $value ", "] }][ \
X                                            expr { $is_string ? "\")\n" : ")\n" }]"
X		    } else {
X			puts -nonewline $PAGER "[expr { [info exists evap_ENV($p)] ? " = $evap_ENV($p), " : " = " }]"
X			puts -nonewline $PAGER "[expr { $is_string ? "\"" : "" }]$value[expr { $is_string ? "\"\n" : "\n" }]"
X		    }
X		}
X	    } elseif { [regexp {^R$} $required] } {; # if $required
X		puts -nonewline $PAGER "[expr { [info exists evap_ENV($p)] ? " = $evap_ENV($p), " : " = " }]"
X		puts -nonewline $PAGER "\$required\n"
X	    } else {
X		puts -nonewline $PAGER "\n"
X	    }; # ifend $optional or defined parameter
X
X	    if { $evap_full_help } {
X		if { [info exists parameter_help($p)] } {
X		    puts -nonewline $PAGER "$parameter_help($p)"
X		} else {
X		    puts -nonewline $PAGER "\n"
X		}
X	    }
X
X	}; # forend all parameters
X
X	if { [regexp "$evap_pdt_reg_exp5" $evap_file_list] } {
X		puts -nonewline $PAGER "$evap_Help_Hooks(P_HHBOFL)"
X	} elseif { [regexp "$evap_pdt_reg_exp6" $evap_file_list] } {
X		puts -nonewline $PAGER "$evap_Help_Hooks(P_HHBRFL)"
X	} else {
X		puts -nonewline $PAGER "$evap_Help_Hooks(P_HHBNFL)"
X	}
X
X	if { $PAGER != "stdout" } {
X	    close $PAGER; # flush the pipeline (required!)
X	}
X	if { $evap_embed } {
X	    return -1;
X	} else {
X	    exit 0
X	}
X
X    }; # ifend help requested
X
X    # Evaluate remaining unspecified command line parameters.  This has been deferred to now so that
X    # if -help was requested the user sees unevaluated boolean, file and bacticked values.
X
X    foreach parameter $evap_PARAMETER {
X	if { ! [info exists evap_EVALUATE($parameter)] && [info exists evap_DEFAULT_VALUE($parameter)] } {
X	    regexp "$evap_pdt_reg_exp1" $evap_INFO($parameter) ignore required type list
X	    if { $type != {w} } {
X		if { $list == 1 } { set list 2 }
X		EvaP_set_value 1 $type  $list $evap_DEFAULT_VALUE($parameter) $parameter
X	    }
X	}; # ifend unevaluated
X    }
X
X    # Store progam name for caller.
X
X    EvaP_set_value 0 {w} 0 $argv0 {help}
X
X    # Ensure all $required parameters have been specified on the command line.
X
X    foreach p $evap_REQUIRED {
X	puts stderr "Parameter $p is required but was omitted."
X	incr evap_error 1
X    }
X
X    # Ensure any required files follow, or none do if that is the case.
X
X    if { [regexp "$evap_pdt_reg_exp4" $evap_file_list] && $argc > 0 } {
X	puts -nonewline stderr "$evap_Help_Hooks(P_HHENFL)"
X	incr evap_error 1
X    }
X    if { [regexp "$evap_pdt_reg_exp6" $evap_file_list] && $argc == 0 } {
X	puts -nonewline stderr "$evap_Help_Hooks(P_HHERFL)"
X	incr evap_error 1
X    }
X
X    # Finish up.
X
X    if { $evap_error > 0 } {	puts stderr "Type $argv0 -? for command line parameter information." }
X
X    if { $evap_error > 0 && $evap_embed == 0 } { exit 1 }
X    if { $evap_error == 0 } {
X	return 1
X    } else {
X	return 0
X    }
X
X}; # end EvaP_fin
X
X
X
X
Xproc EvaP_PDT_error {msg} {
X
X    #
X    # Inform the application developer that they've screwed up!
X    #
X
X    global evap_error
X
X    puts stderr "$msg"
X    incr evap_error 1
X
X}; # end EvaP_PDT_error
X
X
X
X
Xproc EvaP_set_value {evaluate type list v parameter} {
X    
X    #
X    # Store a parameter's value; some parameter types require special type
X    # conversion.  Store values the old way in scalar/list variables of the
X    # form $opt_parameter, as well as the new way in the associative arrays
X    # named $options() and $Options().  'list of' paramaters are are returned
X    # as a string 'joined' with the multi-dimensional array emulation character
X    # \x1C.
X    #
X    # Evaluate items in grave accents (backticks), boolean and files if
X    # `evaluate' is TRUE.
X    #
X    # Handle list syntax (item1, item2, ...) for 'list of' types.
X    #
X    # Lists are a little weird as they may already have default values from the
X    # PDT declaration. The first time a list parameter is specified on the
X    # command line we must first empty the list of its default values.  The
X    # evap_INFO list flag thus can be in one of three states: 1 = the list has
X    # possible default values from the PDT, 2 = first time for this command
X    # line parameter so empty the list and THEN push the parameter's value, and
X    # 3 = from now just keep pushing new command line values on the list.
X    #
X
X    global evap_QUAL
X    global ${evap_QUAL}options ${evap_QUAL}Options evap_EVALUATE
X    set parameter_old "${evap_QUAL}opt_$parameter"
X    global $parameter_old evap_DOS evap_pdt_reg_exp2 evap_pdt_reg_exp3 env evap_d evap_D evap_s evap_S evap_w evap_W
X
X    if { $list == 2 || \
X      ( ! [info exists $parameter_old] && ! [info exists ${evap_QUAL}options($parameter)] &&
X       ! [info exists ${evap_QUAL}Options($parameter)] ) } {
X	set $parameter_old {}
X	set ${evap_QUAL}options($parameter) {}
X	set ${evap_QUAL}Options($parameter) {}
X    }
X
X    if { [regexp {^\(+(.*)\)+$} $v ignore v] } {; # check for list
X	set values [EvaP_decompose_list $v]
X    } else {; # not a list
X        regexp {^['|"](.*)['|"]$} $v ignore v
X	lappend values $v
X    }
X
X    foreach value $values {
X
X	if { $evaluate } {
X
X	    set evap_EVALUATE($parameter) {evaluated}
X	    regexp {^(`*)([^`]*)(`*)$} $value ignore p1 p2 p3
X	    if { $p1 == {`} && $p3 == {`} } {
X		set f [open "| $p2" r]
X		set value {}
X		while { [gets $f line] != -1 } {
X		    append value "$line\n"
X		}
X		set value [string trimright $value \n]
X	    }
X
X	    if { ! $evap_DOS && $type == "f" } {
X		set path [split $value {/}]
X		if { [lindex $path 0] == {~} || [lindex $path 0] == {$HOME} } {
X		    set path [lreplace $path 0 0 $env(HOME)]
X		    set value [join $path {/}]
X		}
X	    }
X
X	    if { $type == "b" } {
X		if { [regexp -nocase "$evap_pdt_reg_exp2" $value] } { set value 1 }
X		if { [regexp -nocase "$evap_pdt_reg_exp3" $value] } { set value 0 }
X	    }
X
X	}; # ifend evaluate
X
X	if { $list } {
X	    lappend $parameter_old $value
X	    if { [set ${evap_QUAL}options($parameter)] == {} && [set ${evap_QUAL}Options($parameter)] == {} } {
X		set ${evap_QUAL}options($parameter) $value
X		set ${evap_QUAL}Options($parameter) $value
X	    } else {
X		set ${evap_QUAL}options($parameter) "[set ${evap_QUAL}options($parameter)]\x1C$value"
X		set ${evap_QUAL}Options($parameter) "[set ${evap_QUAL}Options($parameter)]\x1C$value"
X	    }
X	} else {
X	    set $parameter_old $value
X	    set ${evap_QUAL}options($parameter) $value
X	    set ${evap_QUAL}Options($parameter) $value
X	}
X    }; # forend all values
X
X}; # end EvaP_set_value
X
X
X
X
Xproc EvaP_decompose_list { v } {
X
X    #
X    # Parse a string in EvaP list notation (item1, item2, item-n) and return a Tcl list.
X    # Adapted from Perl's shellword.pl code.
X    #
X
X    set v [string trimleft $v]
X
X    while { $v != "" } {
X
X	set field ""
X
X	while { 1 == 1 } {
X	    if { [regexp  {^"(([^"\\]|\\[\\"])*)"(.*)} $v ignore snippet v1 v] } {
X		regsub -all {\\(.)} $snippet & snippet
X	    } elseif { [regexp {^"} $v] } {
X                puts stderr "Unmatched double quote: $v"
X            } elseif { [regexp {^'(([^'\\]|\\[\\'])*)'(.*)} $v ignore snippet v1 v] } {
X                regsub -all {\\(.)} $snippet & snippet
X            } elseif { [regexp {^'} $v] } {
X	        puts stderr "Unmatched single quote: $v"
X            } elseif { [regexp {^\\(.)} $v snippet] } {
X            } elseif { [regexp "^(\[^ \t\n\r\f\\'\"\]+)(.*)" $v ignore snippet v v1] } {
X	        if { $snippet == {,} } { set snippet {} }
X                set snippet [string trimright $snippet {,}]
X            } else {
X                set v [string trimleft $v]
X		break
X            }
X            append field $snippet
X	}; # whilend all snippets
X
X        lappend values $field
X
X    }; # whilend string is not empty
X
X    return [expr { ([info exists values]) ? $values : "" } ]
X
X}; # end EvaP_decompose_list
X
X
X
X
Xproc evap_pac {prompt I cmds0} {
X
X    #
X    # Process Application Commands
X    #
X    # An application command can be envoked by entering either its full spelling or the alias.
X    #
X
X    upvar $cmds0 cmds 
X    global evap_embed evap_shell env argc argv0 argv evap_s evap_S
X
X    set evap_embed 1;	# enable embedding
X    set evap_shell [expr { ([info exists env(SHELL)] && ($env(SHELL) != "") ) ? $env(SHELL) : "/bin/sh" } ]
X    set cmds(display_application_commands|disac) {evap_disac_proc cmds}
X    set cmds(!) "evap_bang_proc"
X
X    # First, create new associative command name arrays with full/alias names.
X
X    foreach name [array names cmds] {
X        if { [regexp {\|} $name] } {
X            regexp {(.*)\|(.*)} $name junk l a
X	    set long($l) $cmds($name)
X	    set alias($a) $cmds($name)
X        } else {
X	    set long($name) $cmds($name)
X	}
X    }
X
X    for {puts -nonewline stdout "$prompt"} {[gets $I line] != -1} {puts -nonewline stdout "$prompt"} {
X
X        if { [regexp "^$evap_s*$" $line] } {
X            continue
X        }
X
X	if { [regexp "^$evap_s*!(.+)" $line $junk new_line] } {
X	    set line "! $new_line"
X	}
X
X        regexp "$evap_s*($evap_S+)$evap_s*(.*)" $line junk argv0 args
X	if { [info exists long($argv0)] } {
X	    set proc $long($argv0)
X	} elseif { [info exists alias($argv0)] } {
X	    set proc $alias($argv0)
X	} else  {
X            puts -nonewline stderr "Error - unknown command `$argv0'.  Type \"disac -do f\" for a\n"
X	    puts -nonewline stderr "list of valid application commands.  You can then ...\n\n"
X            puts -nonewline stderr "Type \"xyzzy -?\" for help on application command `xyzzy'.\n"
X	    continue
X        }
X	
X	if { $argv0 == "!" } {
X	    set argv [join $args " "]
X            set argc 1
X	} else {
X	    set argv [EvaP_decompose_list $args]
X            set argc [llength $argv]
X	}
X        eval "$proc";		# call the evap/user procedure
X
X    }
X    puts -nonewline stdout "\n"
X
X}; # end evap_pac
X
X 
X
X
Xproc evap_bang_proc {} {
X    
X    #
X    # Issue one or more commands to the user's shell.  If the SHELL environment
X    # variable is not defined or is empty, then /bin/sh is used.
X    #
X
X    global argc argv0 argv evap_shell evap_Help_Hooks
X
X    if { $argv == "" } { return }
X    set cmd $argv
X
X    set Q "bang_pkg_"; evap_setup_for_evap "$Q" "bang"
X    global ${Q}PDT ${Q}MM ${Q}Options
X    set evap_Help_Hooks(P_HHUOFL) " Command(s)\n"
X    set evap_Help_Hooks(P_HHBOFL) "\nA list of shell Commands.\n\n"
X    if { [evap [set ${Q}PDT] [set ${Q}MM] $Q] != 1 } { return }
X
X    if { [catch {puts stdout [exec $evap_shell "-c" "$cmd"]} msg] != 0 } {
X        puts stdout $msg
X    }
X
X}; # end evap_bang_proc
X
X 
X
X
Xproc evap_disac_proc { commands0 } {
X    
X    #
X    # Display the list of legal application commands.
X    #
X
X    global argc argv0 argv
X
X    upvar $commands0 commands
X
X    set Q "disac_pkg_"; evap_setup_for_evap "$Q" "disac"
X    global ${Q}PDT ${Q}MM ${Q}Options
X    if { [evap [set ${Q}PDT] [set ${Q}MM] $Q] != 1 } { return }
X
X    foreach name [array names commands] {
X        if { [regexp {\|} $name] } {
X            regexp {(.*)\|(.*)} $name junk l a
X        } else {
X	    set l $name
X            set a ""
X	}
X        lappend brief $l
X        lappend full [expr { ($a != "") ? "$l, $a" : "$l" } ]
X    }
X
X    if { [set ${Q}Options(output)] == "stdout" } {
X        set H [set ${Q}Options(output)]
X    } else {
X        set H [open [set ${Q}Options(output)] "w"]
X    }
X    if { [set ${Q}Options(display_option)] == "full" } {
X        puts -nonewline $H "\nCommands and aliases for this application:\n\n"
X	puts -nonewline $H "  [join [lsort $full] "\n  "]\n"
X    } else {
X        puts -nonewline $H "[join [lsort $brief] "\n"]\n"
X    }
X    if { $H != "stdout" } {
X	close $H
X    }
X
X}; # end evap_disac_proc
X
X
X
X
Xproc evap_setup_for_evap {Q command} { 
X
X    #
X    # Initialize evap_pac's builtin commands' PDT/MM variables.
X    #
X
X    global ${Q}PDT ${Q}MM evap_message_modules
X
X    set IN [open "|ar p $evap_message_modules ${command}_pdt" "r"]
X    set ${Q}PDT [split [read $IN] \n];                      # initialize Parameter Description Table
X    close $IN
X    set IN [open "|ar p $evap_message_modules ${command}.mm" "r"]
X    set ${Q}MM [split [string trimright [read $IN] \n] \n]; # initialize Message Module
X    close $IN
X
X}; # end setup_for_evap
END_OF_FILE
if test 30094 -ne `wc -c <'src/evap.tcl'`; then
    echo shar: \"'src/evap.tcl'\" unpacked with wrong size!
fi
chmod +x 'src/evap.tcl'
# end of 'src/evap.tcl'
fi
if test -f 'src/sama.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/sama.c'\"
else
echo shar: Extracting \"'src/sama.c'\" \(2074 characters\)
sed "s/^X//" >'src/sama.c' <<'END_OF_FILE'
X
X/* sample_application shows how to embed evaluate_parameters into your application. */
X
X#include <stdio.h>
X#include "../src/evap.h"
X#include "../pdt/sama_pdt_out"  /* sample_application's PDT/MM declarations */
X#include "../pdt/exi_pdt_out"   /* qualified PDT/MM declarations for the `exit' command */
X#include "../pdt/samc_pdt_out"  /* qualified PDT/MM declarations for the `sample_command' command */
X
Xint exi_proc(int argc, char *argv[]);   /* `exit' processor  */
Xint samc_proc(int argc, char * argv[]);	/* `sample_command' processor */
X
X/* sample_application command processors follow, in alphabetical order. */
X
Xint exi_proc(int argc, char *argv[])
X{
X
X  if ( evap( &argc, &argv, exi_pkg_pdt, NULL, exi_pkg_pvt ) != 0 ) { return( 0 ); }
X
X  fprintf( stdout, "Have a nice day!\n" );
X  exit( 0 );
X
X}
X
Xint samc_proc(int argc, char *argv[])
X{
X
X  int c;
X
X  evap_Help_Hooks[P_HHUOFL] = " [Color_List]\n";
X  evap_Help_Hooks[P_HHBOFL] = "\nA Color_List is optionally required by this command.\n";
X  if ( evap( &argc, &argv, samc_pkg_pdt, NULL, samc_pkg_pvt ) != 0 ) { return( 0 ); }
X
X  fprintf( stdout, "In sub samc_proc, value of option `id' = `%s'.\n", samc_pkg_pvt[samc_pkg_P_id].value.string_value );
X  c = argc;
X  while ( c-- > 1 ) {
X    fprintf( stdout, "  color = %s\n", argv[argc-c] );
X  }
X
X  return( 0 );
X
X}
X
X/* Main. */
X
Xint main (int argc, char *argv[])
X
X{
X
X  FILE *I;
X  evap_Application_Command commands[] = {{"exit", "exi", exi_proc}, {"sample_command", "samc", samc_proc}, {NULL, NULL, NULL}};
X
X  evap( &argc, &argv, pdt, NULL, pvt );	/* evaluate_parameters for sample_application */
X
X  /* Let evaluate_parameters parse all user input for the application, and then call the actual command processor. */
X  
X  if ( pvt[P_input].specified ) {
X    if ( (I=fopen( pvt[P_input].value.file_value, "r" )) == NULL ) {
X      fprintf( stderr, "Cannot open input file %s!\n", pvt[P_input].value.file_value );
X      exit( 1 );
X    }
X  } else { I = stdin; }
X
X  evap_pac( "sama>", I, commands ); /* process application commands */
X
X  fclose( I );
X  exit( 0 );
X
X} /* end main */
END_OF_FILE
if test 2074 -ne `wc -c <'src/sama.c'`; then
    echo shar: \"'src/sama.c'\" unpacked with wrong size!
fi
chmod +x 'src/sama.c'
# end of 'src/sama.c'
fi
if test -f 'src/sama.pl' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/sama.pl'\"
else
echo shar: Extracting \"'src/sama.pl'\" \(1863 characters\)
sed "s/^X//" >'src/sama.pl' <<'END_OF_FILE'
X#!/usr/local/bin/perl
X
X# sample_application shows how to embed evaluate_parameters into your application.
X
Xrequire "src/evap.pl";
X
Xsub setup_for_evap { 
X
X    # Simply read the PDT and MM files and initialize the evap variables for the specified package.
X
X    local( $pkg, $command ) = @_;
X
X    open( IN, "<pdt/${command}_pdt" );
X    eval "@${pkg}'PDT = <IN>;";                        # initialize Parameter Description Table
X    close( IN );
X    open( IN, "<mm/${command}.mm" );
X    eval "@${pkg}'MM = grep( \$@ = s/\n\$//, <IN> );"; # initialize Message Module
X    close( IN );
X
X} # end setup_for_evap
X
X# sample_application command processors follow, in alphabetical order.
X 
Xsub exi_proc {
X
X    package exi_pkg;		# qualify %Options
X
X    &main'setup_for_evap( "exi_pkg", "exi" );
X    if ( &main'evap( *PDT, *MM ) != 1 ) { return; }
X
X    print STDOUT "Have a nice day!\n";
X    exit( 0 );
X
X} # end exi_proc
X
Xsub samc_proc {
X
X    package samc_pkg;		# qualify %Options
X
X    &main'setup_for_evap( "samc_pkg", "samc" );
X    $evap'evap_Help_Hooks{'P_HHUOFL'} = " [Color_List]\n";
X    $evap'evap_Help_Hooks{'P_HHBOFL'} = "\nA Color_List is optionally required by this command.\n\n";
X    if ( &main'evap( *PDT, *MM ) != 1 ) { return; }
X
X    print STDOUT "In sub samc_proc, value of option `id' = `$Options{'id'}'.\n";
X    foreach $color (@ARGV) {
X        print STDOUT "  color = $color\n";
X    }
X
X} # end samc_proc
X
X# Main.
X
X%commands =  ("exit|exi", "exi_proc", "sample_command|samc", "samc_proc");
X
X&setup_for_evap( "main", "sama" );
X&evap( *PDT, *MM );		# evaluate_parameters for sample_application
X
X# Let evaluate_parameters process all user input for the application, and then call the actual command processor.
X
X$I = 'sama_input_handle';
Xopen( $I, "$Options{'input'}" );
X
X&evap_pac( "sama>", $I, %commands ); # process application commands
X
Xclose( $I );
Xexit( 0 );
END_OF_FILE
if test 1863 -ne `wc -c <'src/sama.pl'`; then
    echo shar: \"'src/sama.pl'\" unpacked with wrong size!
fi
chmod +x 'src/sama.pl'
# end of 'src/sama.pl'
fi
if test -f 'src/sama.tcl' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/sama.tcl'\"
else
echo shar: Extracting \"'src/sama.tcl'\" \(2011 characters\)
sed "s/^X//" >'src/sama.tcl' <<'END_OF_FILE'
X#!/usr/local/bin/wish -f
X
X# sample_application shows how to embed evaluate_parameters into your application.
X
Xsource "src/evap.tcl"
X
Xproc setup_for_evap {Q command} { 
X
X    # Simply read the PDT and MM files and initialize the evap variables for the specified package.
X
X    global ${Q}PDT ${Q}MM
X
X    set IN [open "pdt/${command}_pdt" "r"]
X    set ${Q}PDT [split [read $IN] \n];                      # initialize Parameter Description Table
X    close $IN
X    set IN [open "mm/${command}.mm" "r"]
X    set ${Q}MM [split [string trimright [read $IN] \n] \n]; # initialize Message Module
X    close $IN
X
X}; # end setup_for_evap
X
X# sample_application command processors follow, in alphabetical order.
X
Xproc exi_proc {} {
X
X    set Q "exi_pkg_"; setup_for_evap "$Q" "exi"
X    global ${Q}PDT ${Q}MM ${Q}Options
X    if { [evap [set ${Q}PDT] [set ${Q}MM] $Q]  != 1 } { return }
X
X    puts -nonewline stdout "Have a nice day!\n"
X    exit 0
X
X}; # end exi_proc
X
Xproc samc_proc {} {
X
X    global argc argv evap_Help_Hooks
X
X    set Q "samc_pkg_"; setup_for_evap "$Q" "samc"
X    global ${Q}PDT ${Q}MM ${Q}Options
X    set evap_Help_Hooks(P_HHUOFL) " \[Color_List\]\n"
X    set evap_Help_Hooks(P_HHBOFL) "\nA Color_List is optionally required by this command.\n\n"
X    if { [evap [set ${Q}PDT] [set ${Q}MM] $Q] != 1 } { return }
X
X    puts -nonewline stdout "In sub samc_proc, value of option `id' = `[set ${Q}Options(id)]'.\n"
X    foreach color $argv {
X        puts -nonewline stdout "  color = $color\n"
X    }
X
X}; # end samc_proc
X
X# Main.
X
Xset commands(exit|exi) "exi_proc"; set commands(sample_command|samc) "samc_proc"
X
Xsetup_for_evap "" "sama"
Xevap $PDT $MM;                 # evaluate_parameters for sample_application
X
X# Let evaluate_parameters process all user input for the application, and then call the actual command processor.
X
Xif { $Options(input) == "stdin" } {
X    set I "$Options(input)"
X} else {
X    set I [open "$Options(input)" "r"]
X}
X
Xevap_pac "sama>" $I commands; # process application commands
X
Xclose $I
Xexit 0
END_OF_FILE
if test 2011 -ne `wc -c <'src/sama.tcl'`; then
    echo shar: \"'src/sama.tcl'\" unpacked with wrong size!
fi
chmod +x 'src/sama.tcl'
# end of 'src/sama.tcl'
fi
if test -f 'src/sample.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/sample.c'\"
else
echo shar: Extracting \"'src/sample.c'\" \(1560 characters\)
sed "s/^X//" >'src/sample.c' <<'END_OF_FILE'
X#include <stdio.h>
X#include "./evap.h"
X#include "../pdt/sample_pdt_out"
X
Xint main(int argc,
X	 char *argv[]);
X
Xint main (int argc, char *argv[])
X
X/* evap - a typical example, type-converted values, types, lists */
X
X{
X  int i;
X  evap_List_Value *lve;		/* list value entry */
X
X  evap ( &argc, &argv, pdt, NULL, pvt ); /* evaluate parameters */
X  printf( "\nProgram name:\n  %s\n\n", pvt[P_HELP].unconverted_value );
X
X  if ( pvt[P_verbose].specified ) {
X    printf( "verbose = %d\n", pvt[P_verbose].value.switch_value );
X  }
X  printf( "command = \"%s\"\n", pvt[P_command].value.string_value );
X  printf( "scale_factor = %f\n", pvt[P_scale_factor].value.real_value );
X  printf( "millisecond_update_interval = %d\n",
X	 pvt[P_millisecond_update_interval].value.integer_value );
X  printf( "ignore_output_file_column_one = %d\n",
X	 pvt[P_ignore_output_file_column_one].value.boolean_value );
X  printf( "output = %s\n", pvt[P_output].value.file_value );
X  printf( "queue = %s\n", pvt[P_queue].value.key_value );
X  printf( "destination = %s\n", pvt[P_destination].value.application_value );
X
X  printf( "'list of' tty = " );
X  lve = pvt[P_tty].list;
X  while ( lve->unconverted_value != NULL ) {
X    printf( "\"%s\"", lve->value.name_value );
X    lve++;			/* next list value entry */
X    printf( "%s", lve->unconverted_value !=NULL ? ", " : "" );
X  } /* whilend */
X  printf( "\n" );
X
X  if (argc > 1) {
X    printf("\nFile names:\n  ");
X    for(i=1; i < argc; i++)
X      printf("%s%s", argv[i], (i < argc-1) ? " " : "");
X    printf("\n");
X  }
X
X  exit( 0 );
X
X} /* end main */
END_OF_FILE
if test 1560 -ne `wc -c <'src/sample.c'`; then
    echo shar: \"'src/sample.c'\" unpacked with wrong size!
fi
chmod +x 'src/sample.c'
# end of 'src/sample.c'
fi
if test -f 'src/sample.pl' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/sample.pl'\"
else
echo shar: Extracting \"'src/sample.pl'\" \(3918 characters\)
sed "s/^X//" >'src/sample.pl' <<'END_OF_FILE'
X#!/usr/local/bin/perl
X#
X# evap - essentially identical to the C version of sample!
X     
Xrequire "src/evap.pl";
X
X$PDT =<<'end-of-PDT';
XPDT (./libevapmm.a/sample.mm) sample
X  verbose, v: switch
X  command, c: string = D_SAMPLE_COMMAND, "ps -el"
X  scale_factor, sf: real = 1.2340896e-1
X  millisecond_update_interval, mui: integer = $required
X  ignore_output_file_column_one, iofco: boolean = TRUE
X  output, o: file = stdout
X  queue, q: key plotter, postscript, text, printer, keyend = printer
X  destination, d: application = `hostname`
X  tty, t: list of name = ("/dev/console", "/dev/tty0", "/dev/tty1")
XPDTEND optional_file_list
Xend-of-PDT
X
X$MM =<<'end-of-MM';
Xsample
X
X	A sample program demonstrating typical evaluate_parameters
X	usage.
X
X	Examples:
X
X	  sample
X	  sample -usage_help
X	  sample -?
X	  sample -full_help
X          sample -mui 1234
X.verbose
X        A 'switch' type parameter emulates a typical standalone
X        switch. If the switch is specified evaluate_parameters
X        returns a '1'.
X.command
X        A 'string' type parameter is just a list of characters,
X        which must be quoted if it contains whitespace. 
X        NOTE:  for this parameter you can also create and
X        initialize the environment variable D_SAMPLE_COMMAND to
X        override the standard default value for this command
X        line parameter.  All types except 'switch' may have a
X        default environment variable for easy user customization.
X.scale_factor
X        A 'real' type parameter must be a real number that may
X        contain a leading sign, a decimal point and an exponent.
X.millisecond_update_interval
X        An 'integer' type parameter must consist of all digits
X        with an optional leading sign.  NOTE: this parameter's
X        default value is '$required', meaning that
X        evaluate_parameters ensures that this parameter is
X        specified and given a valid value.  All types except
X        'switch' may have a default value of '$required'.
X.ignore_output_file_column_one
X        A 'boolean' type parameter may be TRUE/YES/ON/1 or
X        FALSE/NO/OFF/0, either upper or lower case.  If TRUE,
X        evaluate_parameters returns a value of '1', else '0'.
X.output
X        A 'file' type parameter expects a filename.  For Unix
X        $HOME and ~ are expanded.  For evap/Perl 'stdin' and
X	'stdout' are converted to '-' and '>-' so they can be
X	used in a Perl 'open' function.
X.queue
X        A 'key' type parameter enumerates valid values.  Only the
X        specified keywords can be entered on the command line.
X.destination
X	An 'application' type parameter is not type-checked in
X	any - the treatment of this type of parameter is
X	application specific.  NOTE:  this parameter' default
X	value is enclosed in grave accents (or "backticks").
X	evaluate_parameters executes the command and uses it's
X	standard output as the default value for the parameter.
X.tty
X	A 'name' type parameter is similar to a string except
X	that embedded white-space is not allowed.  NOTE: this
X	parameter is also a LIST, meaning that it can be
X	specified multiple times and that each value is pushed
X        onto a Perl LIST variable.  In general you should quote
X        all list elements.  All types except 'switch' may be
X	'list of'.
Xend-of-MM
X
X@PDT = split( /\n/, $PDT );
X@MM = split( /\n/, $MM );
X
X&evap( *PDT, *MM );		# evaluate parameters
Xprint "\nProgram name:\n  $opt_help\n\n";
X
Xif ( defined( $opt_verbose) ) { print "verbose = $opt_verbose\n"; }
Xprint "command = \"$opt_command\"\n";
Xprint "scale_factor  = $opt_scale_factor\n";
Xprint "millisecond_update_interval = $opt_millisecond_update_interval\n";
Xprint "ignore_output_file_column_one = $opt_ignore_output_file_column_one\n";
Xprint "output = $opt_output\n";
Xprint "queue = $opt_queue\n";
Xprint "destination = $opt_destination\n";
Xprint "'list of' tty = \"", join( '", "', @opt_tty), "\"\n";
X
Xprint "\nFile names:\n  ", join( ' ', @ARGV ), "\n" if @ARGV;
END_OF_FILE
if test 3918 -ne `wc -c <'src/sample.pl'`; then
    echo shar: \"'src/sample.pl'\" unpacked with wrong size!
fi
chmod +x 'src/sample.pl'
# end of 'src/sample.pl'
fi
if test -f 'src/sample.tcl' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/sample.tcl'\"
else
echo shar: Extracting \"'src/sample.tcl'\" \(3765 characters\)
sed "s/^X//" >'src/sample.tcl' <<'END_OF_FILE'
X#!/usr/local/bin/wish -f
X#
X# evap - essentially identical to the C version of sample!
X     
Xsource "src/evap.tcl"
X
Xset PDT \
X{PDT (./libevapmm.a/sample.mm) sample
X  verbose, v: switch
X  command, c: string = D_SAMPLE_COMMAND, "ps -el"
X  scale_factor, sf: real = 1.2340896e-1
X  millisecond_update_interval, mui: integer = $required
X  ignore_output_file_column_one, iofco: boolean = TRUE
X  output, o: file = stdout
X  queue, q: key plotter, postscript, text, printer, keyend = printer
X  destination, d: application = `hostname`
X  tty, t: list of name = ("/dev/console", "/dev/tty0", "/dev/tty1")
XPDTEND optional_file_list}
X
Xset MM \
X{sample
X
X	A sample program demonstrating typical evaluate_parameters
X	usage.
X
X	Examples:
X
X	  sample
X	  sample -usage_help
X	  sample -?
X	  sample -full_help
X          sample -mui 1234
X.verbose
X        A 'switch' type parameter emulates a typical standalone
X        switch. If the switch is specified evaluate_parameters
X        returns a '1'.
X.command
X        A 'string' type parameter is just a list of characters,
X        which must be quoted if it contains whitespace. 
X        NOTE:  for this parameter you can also create and
X        initialize the environment variable D_SAMPLE_COMMAND to
X        override the standard default value for this command
X        line parameter.  All types except 'switch' may have a
X        default environment variable for easy user customization.
X.scale_factor
X        A 'real' type parameter must be a real number that may
X        contain a leading sign, a decimal point and an exponent.
X.millisecond_update_interval
X        An 'integer' type parameter must consist of all digits
X        with an optional leading sign.  NOTE: this parameter's
X        default value is '$required', meaning that
X        evaluate_parameters ensures that this parameter is
X        specified and given a valid value.  All types except
X        'switch' may have a default value of '$required'.
X.ignore_output_file_column_one
X        A 'boolean' type parameter may be TRUE/YES/ON/1 or
X        FALSE/NO/OFF/0, either upper or lower case.  If TRUE,
X        evaluate_parameters returns a value of '1', else '0'.
X.output
X        A 'file' type parameter expects a filename.  For Unix
X        $HOME and ~ are expanded.
X.queue
X        A 'key' type parameter enumerates valid values.  Only the
X        specified keywords can be entered on the command line.
X.destination
X	An 'application' type parameter is not type-checked in
X	any - the treatment of this type of parameter is
X	application specific.  NOTE:  this parameter' default
X	value is enclosed in grave accents (or "backticks").
X	evaluate_parameters executes the command and uses it's
X	standard output as the default value for the parameter.
X.tty
X	A 'name' type parameter is similar to a string except
X	that embedded white-space is not allowed.  NOTE: this
X	parameter is also a LIST, meaning that it can be
X	specified multiple times and that each value is pushed
X        onto a Tcl LIST variable.}
X
Xset PDT [split $PDT "\n"]
Xset MM [split $MM "\n"]
X
Xevap $PDT $MM;			# evaluate parameters
Xputs -nonewline "\nProgram name:\n  $opt_help\n\n"
X
Xif { [info exists opt_verbose] } { puts -nonewline "verbose = $opt_verbose\n" }
Xputs -nonewline "command = \"$opt_command\"\n"
Xputs -nonewline "scale_factor  = $opt_scale_factor\n"
Xputs -nonewline "millisecond_update_interval = $opt_millisecond_update_interval\n"
Xputs -nonewline "ignore_output_file_column_one = $opt_ignore_output_file_column_one\n"
Xputs -nonewline "output = $opt_output\n"
Xputs -nonewline "queue = $opt_queue\n"
Xputs -nonewline "destination = $opt_destination\n"
Xputs -nonewline "'list of' tty = \"[join $opt_tty {", "}]\"\n"
X
Xif { $argc > 0 } {
X    puts -nonewline "\nFile names:\n  [join $argv { }]\n"
X}
X
Xexit 0
END_OF_FILE
if test 3765 -ne `wc -c <'src/sample.tcl'`; then
    echo shar: \"'src/sample.tcl'\" unpacked with wrong size!
fi
chmod +x 'src/sample.tcl'
# end of 'src/sample.tcl'
fi
if test -f 'src/sample1.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/sample1.c'\"
else
echo shar: Extracting \"'src/sample1.c'\" \(791 characters\)
sed "s/^X//" >'src/sample1.c' <<'END_OF_FILE'
X#include <stdio.h>
X#include "./evap.h"
X#include "../pdt/sample_pdt_out"
X
Xint main(int argc,
X	 char *argv[]);
X
Xint main (int argc, char *argv[])
X
X/* evap 1 - array version, unconverted values, no types, no lists */
X
X{
X  int i;
X
X  evap (&argc, &argv, pdt, NULL, pvt); /* evaluate parameters */
X  printf("\nProgram name:\n  %s\n", pvt[P_HELP].unconverted_value);
X
X  if (P_NUMBER_OF_PARAMETERS > 1 ) {
X    printf("\nCommand line parameters and values:\n");
X    for (i=1; i < P_NUMBER_OF_PARAMETERS; i++)
X      printf("  Parameter %s=\"%s\"\n", pvt[i].parameter,
X            pvt[i].unconverted_value);
X  }
X
X  if (argc > 1) {
X    printf("\nFile names:\n  ");
X    for(i=1; i < argc; i++)
X      printf("%s%s", argv[i], (i < argc-1) ? " " : "");
X    printf("\n");
X  }
X
X  exit( 0 );
X
X} /* end main */
END_OF_FILE
if test 791 -ne `wc -c <'src/sample1.c'`; then
    echo shar: \"'src/sample1.c'\" unpacked with wrong size!
fi
chmod +x 'src/sample1.c'
# end of 'src/sample1.c'
fi
if test -f 'src/sample1.pl' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/sample1.pl'\"
else
echo shar: Extracting \"'src/sample1.pl'\" \(1454 characters\)
sed "s/^X//" >'src/sample1.pl' <<'END_OF_FILE'
X#!/usr/local/bin/perl
X#
X# evap - essentially identical to the C version of sample!
X#        Same as sample.pl except we get our command line
X#        parameters from the associative array %Options.
X#        Also knows about Perl 4 versus Perl 5.  Also gets
X#        its PDT and MM data from the same files used by
X#        the C sample programs.
X     
Xrequire "src/evap.pl";
X
Xeval 'BEGIN {}';
X$Perl_version_major = $@ ? 4 : 5;
X
Xopen( IN, "<pdt/sample_pdt" );
X@PDT = <IN>;
Xclose( IN );
X
Xopen( IN, "<mm/sample.mm" );
X@MM = <IN>;
Xclose( IN );
X@MM = grep( @_ = s/\n$//, @MM );
X
X&evap( *PDT, *MM );		# evaluate parameters
Xprint "\nProgram name:\n  $Options{'help'}\n\n";
X
Xif ( defined( $Options{'verbose'} ) ) { print "\nverbose = $Options{'verbose'}\n"; }
Xprint "command = \"$Options{'command'}\"\n";
Xprint "scale_factor  = $Options{'scale_factor'}\n";
Xprint "millisecond_update_interval = $Options{'millisecond_update_interval'}\n";
Xprint "ignore_output_file_column_one = $Options{'ignore_output_file_column_one'}\n";
Xprint "output = $Options{'output'}\n";
Xprint "queue = $Options{'queue'}\n";
Xprint "destination = $Options{'destination'}\n";
Xif ( $Perl_version_major == 5 ) {
X    eval q[$tty_list = $Options{'tty'}; print "Perl 5 'list of' tty = \"", join( '", "', @$tty_list ), "\"\n";];
X} else {
X    print "Perl 4 'list of' tty = \"", join( '", "', split( $;, $Options{'tty'} ) ), "\"\n";
X}
X
Xprint "\nFile names:\n  ", join( ' ', @ARGV ), "\n" if @ARGV;
END_OF_FILE
if test 1454 -ne `wc -c <'src/sample1.pl'`; then
    echo shar: \"'src/sample1.pl'\" unpacked with wrong size!
fi
chmod +x 'src/sample1.pl'
# end of 'src/sample1.pl'
fi
if test -f 'src/sample2.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/sample2.c'\"
else
echo shar: Extracting \"'src/sample2.c'\" \(1618 characters\)
sed "s/^X//" >'src/sample2.c' <<'END_OF_FILE'
X#include <stdio.h>
X#include "./evap.h"
X#include "../pdt/sample_pdt_out"
X
Xint main(int argc,
X	 char *argv[]);
X
X/* evap 2 - pointer version, unconverted values, types, lists */
X
Xint main(int argc, char *argv[])
X{
X
X  evap_List_Value *lve;		/* list value entry */
X  evap_Parameter_Value *pvte;	/* parameter value table entry */
X
X  evap (&argc, &argv, pdt, NULL, pvt); /* evaluate parameters */
X  printf("\nProgram name:\n  %s\n", pvt[P_HELP].unconverted_value);
X
X  if (P_NUMBER_OF_PARAMETERS > 1) {
X
X    printf("\nCommand parameters and values:\n");
X    pvte = &pvt[1];		/* ignore -help parameter */
X
X    while (pvte->parameter != NULL) {
X
X      lve = pvte->list;		/* get 'list of' indicator */
X      printf( "\n   \"%s%s\" parameter \"%s\" ...\n",
X	     (lve != NULL) ? "list of " : "", evap_Type_Strings[pvte->type],
X	     pvte->parameter );
X
X      if ( lve == NULL ) {	/* not 'list of' parameter */
X	printf( "           value = \"%s\"\n", pvte->unconverted_value );
X      } else {
X	printf( "          values = (" ); 
X
X	while (lve->unconverted_value != NULL ) {
X
X	  printf(" \"%s\"", lve->unconverted_value);
X	  lve++;		/* next list value entry */
X	  printf( "%s", lve->unconverted_value !=NULL ? ", " : "" );
X
X	} /* whilend */
X
X	printf( " )\n" );
X      } /* ifend */
X
X      pvte++;			/* next parameter value table entry */
X
X    } /* whilend */
X
X  } /* ifend command line parameters */
X
X  if (argc > 1) {		/* if trailing file names */
X
X    printf("\nFile names:\n  ");
X    while (*++argv != NULL)
X      printf("%s%s",*argv, (*argv != NULL) ? " " : "");
X    printf("\n");
X
X  } /* ifend */
X
X  exit( 0 );
X
X} /* end main */
END_OF_FILE
if test 1618 -ne `wc -c <'src/sample2.c'`; then
    echo shar: \"'src/sample2.c'\" unpacked with wrong size!
fi
# end of 'src/sample2.c'
fi
echo shar: End of archive 1 \(of 1\).
cp /dev/null ark1isdone
MISSING=""
for I in 1 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have the archive.
    echo "Now:  make -f Makefile.smp"
    rm -f ark[1-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0
