/******************************************************************************
*
*  NSSDC/CDF                                                    CDFinquire.
*
*  Version 1.5a, 28-Sep-95, Hughes STX.
*
*  Modification history:
*
*   V1.0  23-Mar-92, J Love     Original version.
*   V1.1  16-Sep-92, J Love     CDF V2.3 (shareable/NeXT/zVar).
*   V1.2   2-Nov-92, J Love     Added variable values display.
*   V1.3  26-Jan-94, J Love     CDF V2.4.
*   V1.4  27-Oct-94, J Love	CDF V2.5.
*   V1.4a  6-Apr-95, J Love	POSIX.
*   V1.5  13-Sep-95, J Love	Added CDFexport defaults.
*   V1.5a 28-Sep-95, J Love	Macintosh dialog filtering.  Outline default
*				button.
*
******************************************************************************/

#include "cdfinq.h"

/******************************************************************************
* Increased stack size for Borland C on IBM PC.
******************************************************************************/

#if defined(BORLANDC)
extern unsigned _stklen = BORLANDC_STACK_SIZE;
#endif

/******************************************************************************
* Local function prototypes.
******************************************************************************/

static char *epochToken PROTOARGs((int zMode));
static char *majorityToken PROTOARGs((int zMode));
static char *zModeToken PROTOARGs((int zMode));
static char *No PROTOARGs((Logical state));

/******************************************************************************
* Main.
******************************************************************************/

MAIN {
#if defined(mac)
  strcpyX (pgmName, "CDFinquire", MAX_PROGRAM_NAME_LEN);
  MacExecuteSO (InquireCDF, InquireQOPs);
  if (FreeMemory(NULL,FatalError) > 0) DisplayWarning ("Abandoned buffers.");
  return EXIT_SUCCESS_;
#else
  Logical success;
  strcpyX (pgmName, "CDFinquire", MAX_PROGRAM_NAME_LEN);
  success = InquireCDF (argc, argv);
  if (FreeMemory(NULL,FatalError) > 0) DisplayWarning ("Abandoned buffers.");
  return BOO(success,EXIT_SUCCESS_,EXIT_FAILURE_);
#endif
}

/******************************************************************************
* InquireCDF.
******************************************************************************/

Logical InquireCDF (argC, argV)
int argC;
char *argV[];
{
  QOP *qop;
  static char *validQuals[] = { "id", "page", "nopage", NULL };
  static int optRequired[] = { FALSE, FALSE, FALSE, 0 };
  Logical qopError = FALSE;
  
  switch (argC) {
    case 1:
      PageOLH ("cdfinq.olh", argV[0]);
      return TRUE;
    default:
      qop = Qop (argC, argV, validQuals, optRequired);
      if (qop == NULL) return FALSE;

      /***********************************************************************
      * Check for `id' qualifier.
      ***********************************************************************/

      if (!qop->qualEntered[IDqual]) {
	DisplayError ("Missing qualifier (`id').");
	qopError = TRUE;
      }

      /***********************************************************************
      * Check for `page' qualifier.
      ***********************************************************************/

      qopError = qopError | !TFqualifier(qop,&pagingOn,PAGEqual,NOPAGEqual,
					 DEFAULTpageINQ,"page");

      /************************************************************************
      * Free QOP memory and check for an error.
      ************************************************************************/

      FreeMemory (qop, FatalError);
      if (qopError) return FALSE;

      break;
  }

  /****************************************************************************
  * Display CDF version/release/increment/subincrement and toolkit defaults.
  ****************************************************************************/

  DisplayVerRelInc ();
  DisplayToolkitDefaults ();

  return TRUE;
}

/******************************************************************************
* DisplayVerRelInc.
******************************************************************************/

void DisplayVerRelInc () {
  long version, release, increment; char subincrement;
  CDFlib (GET_, LIB_VERSION_, &version,
		LIB_RELEASE_, &release,
		LIB_INCREMENT_, &increment,
		LIB_subINCREMENT_, &subincrement,
	  NULL_);
  WriteOutSO ("CDF distribution V%ld.%ld.%ld%c\n",
	      version, release, increment, subincrement);
  return;
}

/******************************************************************************
* DisplayToolkitDefaults.
******************************************************************************/

void DisplayToolkitDefaults () {
#if !defined(mac)
  char text[MAX_SCREENLINE_LEN+1];
  static char *valuesTokens[] = { "none", "nrv", "rv", "all", "named" };
#endif

  WriteOut (stdout, "Toolkit defaults...\n");

#if defined(mac)
  WriteOut (stdout, "    On a Macintosh the defaults for a\n");
  WriteOut (stdout, "    toolkit program are shown in the initial\n");
  WriteOut (stdout, "    parameters/qualifiers dialog box.\n");
#else
  /****************************************************************************
  * CDFconvert.
  ****************************************************************************/
  WriteOut (stdout, "\n");
  WriteOut (stdout, "  CDFconvert\n");
#if defined(vms)
  sprintf (text, "    /%sLOG\n", No(DEFAULTlogCVT));
  WriteOut (stdout, text);
  sprintf (text, "    /%sPERCENT\n", No(DEFAULTpctCVT));
  WriteOut (stdout, text);
  sprintf (text, "    /%sDELETE\n", No(DEFAULTdelCVT));
  WriteOut (stdout, text);
  sprintf (text, "    /%sNEG2POSFP0\n", No(DEFAULT_NEGtoPOSfp0));
  WriteOut (stdout, text);
  sprintf (text, "    /%sPAGE\n", No(DEFAULTpageCVT));
  WriteOut (stdout, text);
  sprintf (text, "    /ZMODE=%s\n", zModeToken(DEFAULTzModeCVT));
  WriteOut (stdout, text);
  sprintf (text, "    /REPORT=%s\n",
	   StatusCodeReportOptions(REPORTerrorsDEFAULT,
				   REPORTwarningsDEFAULT,
				   REPORTinfosDEFAULT));
  WriteOut (stdout, text);
  sprintf (text, "    /%sSTATISTICS\n", No(DEFAULTstatsCVT));
  WriteOut (stdout, text);
#else
  sprintf (text, "    -%slog\n", No(DEFAULTlogCVT));
  WriteOut (stdout, text);
  sprintf (text, "    -%spercent\n", No(DEFAULTpctCVT));
  WriteOut (stdout, text);
  sprintf (text, "    -%sdelete\n", No(DEFAULTdelCVT));
  WriteOut (stdout, text);
  sprintf (text, "    -%sneg2posfp0\n", No(DEFAULT_NEGtoPOSfp0));
  WriteOut (stdout, text);
  sprintf (text, "    -%spage\n", No(DEFAULTpageCVT));
  WriteOut (stdout, text);
  sprintf (text, "    -zmode %s\n", zModeToken(DEFAULTzModeCVT));
  WriteOut (stdout, text);
  sprintf (text, "    -report %s\n",
	   StatusCodeReportOptions(REPORTerrorsDEFAULT,
				   REPORTwarningsDEFAULT,
				   REPORTinfosDEFAULT));
  WriteOut (stdout, text);
  sprintf (text, "    -%sstatistics\n", No(DEFAULTstatsCVT));
  WriteOut (stdout, text);
#endif
  /****************************************************************************
  * CDFcompare.
  ****************************************************************************/
  WriteOut (stdout, "\n");
  WriteOut (stdout, "  CDFcompare\n");
#if defined(vms)
  sprintf (text, "    /%sLOG\n", No(DEFAULTlogCMP));
  WriteOut (stdout, text);
  sprintf (text, "    /%sATTR\n", No(DEFAULTattrCMP));
  WriteOut (stdout, text);
  sprintf (text, "    /%sVAR\n", No(DEFAULTvarCMP));
  WriteOut (stdout, text);
  sprintf (text, "    /%sNUMBER\n", No(DEFAULTnumberCMP));
  WriteOut (stdout, text);
  sprintf (text, "    /%sPERCENT\n", No(DEFAULTpctCMP));
  WriteOut (stdout, text);
  sprintf (text, "    /%sETC\n", No(DEFAULTetcCMP));
  WriteOut (stdout, text);
  sprintf (text, "    /%sPAGE\n", No(DEFAULTpageCMP));
  WriteOut (stdout, text);
  sprintf (text, "    /%sNEG2POSFP0\n", No(DEFAULT_NEGtoPOSfp0));
  WriteOut (stdout, text);
  sprintf (text, "    /ZMODES=(%s,%s)\n",
	   zModeToken(DEFAULTzModeCMP), zModeToken(DEFAULTzModeCMP));
  WriteOut (stdout, text);
  sprintf (text, "    /%sLOCATION\n", No(DEFAULTlocationCMP));
  WriteOut (stdout, text);
  sprintf (text, "    /REPORT=%s\n",
	   StatusCodeReportOptions(REPORTerrorsDEFAULT,
				   REPORTwarningsDEFAULT,
				   REPORTinfosDEFAULT));
  WriteOut (stdout, text);
  sprintf (text, "    /%sSTATISTICS\n", No(DEFAULTstatsCMP));
  WriteOut (stdout, text);
#else
  sprintf (text, "    -%slog\n", No(DEFAULTlogCMP));
  WriteOut (stdout, text);
  sprintf (text, "    -%sattr\n", No(DEFAULTattrCMP));
  WriteOut (stdout, text);
  sprintf (text, "    -%svar\n", No(DEFAULTvarCMP));
  WriteOut (stdout, text);
  sprintf (text, "    -%snumber\n", No(DEFAULTnumberCMP));
  WriteOut (stdout, text);
  sprintf (text, "    -%spercent\n", No(DEFAULTpctCMP));
  WriteOut (stdout, text);
  sprintf (text, "    -%setc\n", No(DEFAULTetcCMP));
  WriteOut (stdout, text);
  sprintf (text, "    -%spage\n", No(DEFAULTpageCMP));
  WriteOut (stdout, text);
  sprintf (text, "    -%sneg2posfp0\n", No(DEFAULT_NEGtoPOSfp0));
  WriteOut (stdout, text);
  sprintf (text, "    -zmodes \"%s,%s\"\n",
	   zModeToken(DEFAULTzModeCMP), zModeToken(DEFAULTzModeCMP));
  WriteOut (stdout, text);
  sprintf (text, "    -%slocation\n", No(DEFAULTlocationCMP));
  WriteOut (stdout, text);
  sprintf (text, "    -report %s\n",
	   StatusCodeReportOptions(REPORTerrorsDEFAULT,
				   REPORTwarningsDEFAULT,
				   REPORTinfosDEFAULT));
  WriteOut (stdout, text);
  sprintf (text, "    -%sstatistics\n", No(DEFAULTstatsCMP));
  WriteOut (stdout, text);
#endif
  /****************************************************************************
  * CDFstats.
  ****************************************************************************/
  WriteOut (stdout, "\n");
  WriteOut (stdout, "  CDFstats\n");
#if defined(vms)
  sprintf (text, "    /%sRANGE\n", No(DEFAULTrangeSTATS));
  WriteOut (stdout, text);
  sprintf (text, "    /%sFILL\n", No(DEFAULTfillSTATS));
  WriteOut (stdout, text);
  sprintf (text, "    /%sFORMAT\n", No(DEFAULTformatSTATS));
  WriteOut (stdout, text);
  sprintf (text, "    /%sPAGE\n", No(DEFAULTpageSTATS));
  WriteOut (stdout, text);
  sprintf (text, "    /%sNEG2POSFP0\n", No(DEFAULT_NEGtoPOSfp0));
  WriteOut (stdout, text);
  sprintf (text, "    /ZMODE=%s\n", zModeToken(DEFAULTzModeSTATS));
  WriteOut (stdout, text);
  sprintf (text, "    /REPORT=%s\n",
	   StatusCodeReportOptions(REPORTerrorsDEFAULT,
	   			   REPORTwarningsDEFAULT,
		  		   REPORTinfosDEFAULT));
  WriteOut (stdout, text);
  sprintf (text, "    /%sUPDATE_VALIDS\n", No(DEFAULTupValidsSTATS));
  WriteOut (stdout, text);
  sprintf (text, "    /%sUPDATE_SCALES\n", No(DEFAULTupScalesSTATS));
  WriteOut (stdout, text);
  sprintf (text, "    /%sUPDATE_MONOTONIC\n", No(DEFAULTupMonoSTATS));
  WriteOut (stdout, text);
#else
  sprintf (text, "    -%srange\n", No(DEFAULTrangeSTATS));
  WriteOut (stdout, text);
  sprintf (text, "    -%sfill\n", No(DEFAULTfillSTATS));
  WriteOut (stdout, text);
  sprintf (text, "    -%sformat\n", No(DEFAULTformatSTATS));
  WriteOut (stdout, text);
  sprintf (text, "    -%spage\n", No(DEFAULTpageSTATS));
  WriteOut (stdout, text);
  sprintf (text, "    -%sneg2posfp0\n", No(DEFAULT_NEGtoPOSfp0));
  WriteOut (stdout, text);
  sprintf (text, "    -zmode %s\n", zModeToken(DEFAULTzModeSTATS));
  WriteOut (stdout, text);
  sprintf (text, "    -report %s\n",
	   StatusCodeReportOptions(REPORTerrorsDEFAULT,
	   			   REPORTwarningsDEFAULT,
		       		   REPORTinfosDEFAULT));
  WriteOut (stdout, text);
  sprintf (text, "    -%supdate_valids\n", No(DEFAULTupValidsSTATS));
  WriteOut (stdout, text);
  sprintf (text, "    -%supdate_scales\n", No(DEFAULTupScalesSTATS));
  WriteOut (stdout, text);
  sprintf (text, "    -%supdate_monotonic\n", No(DEFAULTupMonoSTATS));
  WriteOut (stdout, text);
#endif
  /****************************************************************************
  * CDFinquire.
  ****************************************************************************/
  WriteOut (stdout, "\n");
  WriteOut (stdout, "  CDFinquire\n");
#if defined(vms)
  WriteOut (stdout, BOO(DEFAULTidINQ,"    /ID\n",""));
  sprintf (text, "    /%sPAGE\n", No(DEFAULTpageINQ));
  WriteOut (stdout, text);
#else
  WriteOut (stdout, BOO(DEFAULTidINQ,"    -id\n",""));
  sprintf (text, "    -%spage\n", No(DEFAULTpageINQ));
  WriteOut (stdout, text);
#endif
  /****************************************************************************
  * SkeletonCDF.
  ****************************************************************************/
  WriteOut (stdout, "\n");
  WriteOut (stdout, "  SkeletonCDF\n");
#if defined(vms)
  sprintf (text, "    /%sLOG\n", No(DEFAULTlogSKT2CDF));
  WriteOut (stdout, text);
  sprintf (text, "    /%sDELETE\n", No(DEFAULTdeleteSKT2CDF));
  WriteOut (stdout, text);
  sprintf (text, "    /%sFILLVAL\n", No(DEFAULTfillvalSKT2CDF));
  WriteOut (stdout, text);
  sprintf (text, "    /%sNEG2POSFP0\n", No(DEFAULT_NEGtoPOSfp0));
  WriteOut (stdout, text);
  sprintf (text, "    /REPORT=%s\n",
	   StatusCodeReportOptions(REPORTerrorsDEFAULT,
				   REPORTwarningsDEFAULT,
				   REPORTinfosDEFAULT));
  WriteOut (stdout, text);
#else
  sprintf (text, "    -%slog\n", No(DEFAULTlogSKT2CDF));
  WriteOut (stdout, text);
  sprintf (text, "    -%sdelete\n", No(DEFAULTdeleteSKT2CDF));
  WriteOut (stdout, text);
  sprintf (text, "    -%sfillval\n", No(DEFAULTfillvalSKT2CDF));
  WriteOut (stdout, text);
  sprintf (text, "    -%sneg2posfp0\n", No(DEFAULT_NEGtoPOSfp0));
  WriteOut (stdout, text);
  sprintf (text, "    -report %s\n",
	   StatusCodeReportOptions(REPORTerrorsDEFAULT,
				   REPORTwarningsDEFAULT,
				   REPORTinfosDEFAULT));
  WriteOut (stdout, text);
#endif
  /****************************************************************************
  * SkeletonTable.
  ****************************************************************************/
  WriteOut (stdout, "\n");
  WriteOut (stdout, "  SkeletonTable\n");
#if defined(vms)
  sprintf (text, "    /%sLOG\n", No(DEFAULTlogCDF2SKT));
  WriteOut (stdout, text);
  sprintf (text, "    /%sFORMAT\n", No(DEFAULTformatCDF2SKT));
  WriteOut (stdout, text);
  sprintf (text, "    /VALUES=%s\n", valuesTokens[DEFAULTvaluesCDF2SKT]);
  WriteOut (stdout, text);
  sprintf (text, "    /%sNEG2POSFP0\n", No(DEFAULT_NEGtoPOSfp0));
  WriteOut (stdout, text);
  sprintf (text, "    /%sSCREEN\n", No(DEFAULTscreenCDF2SKT));
  WriteOut (stdout, text);
  sprintf (text, "    /%sPAGE\n", No(DEFAULTpageCDF2SKT));
  WriteOut (stdout, text);
  sprintf (text, "    /ZMODE=%s\n", zModeToken(DEFAULTzModeCDF2SKT));
  WriteOut (stdout, text);
  sprintf (text, "    /REPORT=%s\n",
	   StatusCodeReportOptions(REPORTerrorsDEFAULT,
	   			   REPORTwarningsDEFAULT,
		  		   REPORTinfosDEFAULT));
  WriteOut (stdout, text);
#else
  sprintf (text, "    -%slog\n", No(DEFAULTlogCDF2SKT));
  WriteOut (stdout, text);
  sprintf (text, "    -%sformat\n", No(DEFAULTformatCDF2SKT));
  WriteOut (stdout, text);
  sprintf (text, "    -values %s\n", valuesTokens[DEFAULTvaluesCDF2SKT]);
  WriteOut (stdout, text);
  sprintf (text, "    -%sneg2posfp0\n", No(DEFAULT_NEGtoPOSfp0));
  WriteOut (stdout, text);
  sprintf (text, "    -%sscreen\n", No(DEFAULTscreenCDF2SKT));
  WriteOut (stdout, text);
  sprintf (text, "    -%spage\n", No(DEFAULTpageCDF2SKT));
  WriteOut (stdout, text);
  sprintf (text, "    -zmode %s\n", zModeToken(DEFAULTzModeCDF2SKT));
  WriteOut (stdout, text);
  sprintf (text, "    -report %s\n",
	   StatusCodeReportOptions(REPORTerrorsDEFAULT,
	   			   REPORTwarningsDEFAULT,
		  		   REPORTinfosDEFAULT));
  WriteOut (stdout, text);
#endif
  /****************************************************************************
  * CDFedit.
  ****************************************************************************/
  WriteOut (stdout, "\n");
  WriteOut (stdout, "  CDFedit\n");
#if defined(vms)
  sprintf (text, "    /%sBROWSE\n", No(DEFAULTbrowseEDIT));
  WriteOut (stdout, text);
  sprintf (text, "    /ZMODE=%s\n", zModeToken(DEFAULTzModeEDIT));
  WriteOut (stdout, text);
  sprintf (text, "    /%sFORMAT\n", No(DEFAULTformatEDIT));
  WriteOut (stdout, text);
  sprintf (text, "    /%sPROMPT\n", No(DEFAULTpromptEDIT));
  WriteOut (stdout, text);
  sprintf (text, "    /%sNEG2POSFP0\n", No(DEFAULT_NEGtoPOSfp0));
  WriteOut (stdout, text);
  sprintf (text, "    /REPORT=%s\n",
	   StatusCodeReportOptions(REPORTerrorsDEFAULT,
				   REPORTwarningsDEFAULT,
				   REPORTinfosDEFAULT));
  WriteOut (stdout, text);
  sprintf (text, "    /%sSTATISTICS\n", No(DEFAULTstatsEDIT));
  WriteOut (stdout, text);
#else
  sprintf (text, "    -%sbrowse\n", No(DEFAULTbrowseEDIT));
  WriteOut (stdout, text);
  sprintf (text, "    -zmode %s\n", zModeToken(DEFAULTzModeEDIT));
  WriteOut (stdout, text);
  sprintf (text, "    -%sformat\n", No(DEFAULTformatEDIT));
  WriteOut (stdout, text);
  sprintf (text, "    -%sprompt\n", No(DEFAULTpromptEDIT));
  WriteOut (stdout, text);
  sprintf (text, "    -%sneg2posfp0\n", No(DEFAULT_NEGtoPOSfp0));
  WriteOut (stdout, text);
  sprintf (text, "    -report %s\n",
	   StatusCodeReportOptions(REPORTerrorsDEFAULT,
				   REPORTwarningsDEFAULT,
				   REPORTinfosDEFAULT));
  WriteOut (stdout, text);
  sprintf (text, "    -%sstatistics\n", No(DEFAULTstatsEDIT));
  WriteOut (stdout, text);
#endif
  /****************************************************************************
  * CDFexport.
  ****************************************************************************/
  WriteOut (stdout, "\n");
  WriteOut (stdout, "  CDFexport\n");
#if defined(vms)
  sprintf (text, "    /ZMODE=%s\n", zModeToken(DEFAULTzModeEXPORT));
  WriteOut (stdout, text);
  sprintf (text, "    /%sNEG2POSFP0\n", No(DEFAULT_NEGtoPOSfp0));
  WriteOut (stdout, text);
  sprintf (text, "    /REPORT=%s\n",
	   StatusCodeReportOptions(REPORTerrorsDEFAULT,
				   REPORTwarningsDEFAULT,
				   REPORTinfosDEFAULT));
  WriteOut (stdout, text);
  sprintf (text, "    /%sSTATISTICS\n", No(DEFAULTstatsEXPORT));
  WriteOut (stdout, text);
  sprintf (text,
	   "    /INITIAL=(%sFILTER,%sFILLS,%sFORMAT,%sFILLVAL,%sVALIDMIN,",
	   No(DEFAULTeachFilterEXPORT), No(DEFAULTfillsEXPORT),
	   No(DEFAULTformatEXPORT), No(DEFAULTfillvalEXPORT),
	   No(DEFAULTvalidminEXPORT));
  sprintf (EofS(text), "%sPREALLOCATE,\n", No(DEFAULTpreAllocateEXPORT));
  WriteOut (stdout, text);
  sprintf (text,
	   "              %sVALIDMAX,%sMONOTON,%sRECORD,%sINDICES,",
	   No(DEFAULTvalidmaxEXPORT), No(DEFAULTmonotonEXPORT),
	   No(DEFAULTrecordEXPORT), No(DEFAULTindicesEXPORT));
  sprintf (EofS(text), "%sOUTPUT,%sDELETE,\n",
	   No(DEFAULToutputEXPORT), No(DEFAULTdeleteEXPORT));
  WriteOut (stdout, text);
  sprintf (text,
	   "              %sEXCLUSIVE,%s,%s,%s,%s%s)\n",
	   No(DEFAULTexclusiveEXPORT), epochToken(DEFAULTepochEXPORT),
	   BOO(DEFAULTsingleEXPORT,"SINGLE","MULTI"),
	   BOO(DEFAULTnetworkEXPORT,"NETWORK","HOST"),
	   BOO(DEFAULThorizontalEXPORT,"HORIZONTAL","VERTICAL"),
	   majorityToken(DEFAULTmajorityEXPORT));
  WriteOut (stdout, text);
#else
  sprintf (text, "    -zmode %s\n", zModeToken(DEFAULTzModeEXPORT));
  WriteOut (stdout, text);
  sprintf (text, "    -%sneg2posfp0\n", No(DEFAULT_NEGtoPOSfp0));
  WriteOut (stdout, text);
  sprintf (text, "    -report %s\n",
	   StatusCodeReportOptions(REPORTerrorsDEFAULT,
				   REPORTwarningsDEFAULT,
				   REPORTinfosDEFAULT));
  WriteOut (stdout, text);
  sprintf (text, "    -%sstatistics\n", No(DEFAULTstatsEXPORT));
  WriteOut (stdout, text);
  sprintf (text,
	   "    -initial \"%sfilter,%sfills,%sformat,%sfillval,%svalidmin,",
	   No(DEFAULTeachFilterEXPORT), No(DEFAULTfillsEXPORT),
	   No(DEFAULTformatEXPORT), No(DEFAULTfillvalEXPORT),
	   No(DEFAULTvalidminEXPORT));
  sprintf (EofS(text), "%spreallocate,\n", No(DEFAULTpreAllocateEXPORT));
  WriteOut (stdout, text);
  sprintf (text,
	   "              %svalidmax,%smonoton,%srecord,%sindices,",
	   No(DEFAULTvalidmaxEXPORT), No(DEFAULTmonotonEXPORT),
	   No(DEFAULTrecordEXPORT), No(DEFAULTindicesEXPORT));
  sprintf (EofS(text), "%soutput,%sdelete,\n",
	   No(DEFAULToutputEXPORT), No(DEFAULTdeleteEXPORT));
  WriteOut (stdout, text);
  sprintf (text,
	   "              %sexclusive,%s,%s,%s,%s%s\"\n",
	   No(DEFAULTexclusiveEXPORT), epochToken(DEFAULTepochEXPORT),
	   BOO(DEFAULTsingleEXPORT,"single","multi"),
	   BOO(DEFAULTnetworkEXPORT,"network","host"),
	   BOO(DEFAULThorizontalEXPORT,"horizontal","vertical"),
	   majorityToken(DEFAULTmajorityEXPORT));
  WriteOut (stdout, text);
#endif
  /****************************************************************************
  * CDFlist.
  ****************************************************************************/
  WriteOut (stdout, "\n");
  WriteOut (stdout, "  CDFlist\n");
#if defined(vms)
  sprintf (text,
	   "    /INITIAL=(%sERASE,%sFILTER,%sFILL,%sFORMAT,%sNEG2POSFP0,\n",
	   No(DEFAULTeraseLIST), No(DEFAULTfilterLIST),
	   No(DEFAULTfillLIST),  No(DEFAULTformatLIST),
	   No(DEFAULT_NEGtoPOSfp0));
  WriteOut (stdout, text);
  sprintf (text,
	   "              %s,%s,%s,%s%s)\n",
	   BOO(DEFAULTsingleLIST,"SINGLE","MULTI"),
	   BOO(DEFAULTnetworkLIST,"NETWORK","HOST"),
	   BOO(DEFAULThorizontalLIST,"HORIZONTAL","VERTICAL"),
	   BOO(DEFAULTepochLIST,"EPOCH","EPOCH1"),
	   BOO(DEFAULTzModeLIST,",ZMODE",""));
  WriteOut (stdout, text);
#else
  sprintf (text,
	   "    -initial \"%serase,%sfilter,%sfill,%sformat,%sneg2posfp0,\n",
	   No(DEFAULTeraseLIST), No(DEFAULTfilterLIST),
	   No(DEFAULTfillLIST),  No(DEFAULTformatLIST),
	   No(DEFAULT_NEGtoPOSfp0));
  WriteOut (stdout, text);
  sprintf (text,
	   "              %s,%s,%s,%s%s\"\n",
	   (DEFAULTsingleLIST ? "single" : "multi"),
	   (DEFAULTnetworkLIST ? "network" : "host"),
	   (DEFAULThorizontalLIST ? "horizontal" : "vertical"),
	   (DEFAULTepochLIST ? "epoch" : "epoch1"),
	   (DEFAULTzModeLIST ? ",zmode" : ""));
  WriteOut (stdout, text);
#endif
  /****************************************************************************
  * CDFwalk.
  ****************************************************************************/
  WriteOut (stdout, "\n");
  WriteOut (stdout, "  CDFwalk\n");
#if defined(vms)
  sprintf (text, "    /INITIAL=(%sFORMAT,%sNEG2POSFP0)\n",
	   No(DEFAULTformatWALK), No(DEFAULT_NEGtoPOSfp0));
  WriteOut (stdout, text);
#else
  sprintf (text, "    -initial \"%sformat,%sneg2posfp0\"\n",
	   No(DEFAULTformatWALK), No(DEFAULT_NEGtoPOSfp0));
  WriteOut (stdout, text);
#endif
  WriteOut (stdout, "\n");
#endif
  return;
}

/******************************************************************************
* zModeToken.
******************************************************************************/

static char *zModeToken (zMode)
int zMode;
{
  switch (zMode) {
    case zMODEoff: return "0";
    case zMODEon1: return "1";
    case zMODEon2: return "2";
  }
  return "?";
}

/******************************************************************************
* majorityToken.
******************************************************************************/

static char *majorityToken (majority)
int majority;
{
  switch (majority) {
    case INPUT_MAJOR: return "";
    case ROW_MAJOR:
#if defined(vms)
      return ",ROW";
#else
      return ",row";
#endif
    case COL_MAJOR:
#if defined(vms)
      return ",COLUMN";
#else
      return ",column";
#endif
  }
  return "?";
}

/******************************************************************************
* epochToken.
******************************************************************************/

static char *epochToken (epochStyle)
int epochStyle;
{
  switch (epochStyle) {
    case EPOCH0_STYLE:
#if defined(vms)
      return "EPOCH";
#else
      return "epoch";
#endif
    case EPOCH1_STYLE:
#if defined(vms)
      return "EPOCH1";
#else
      return "epoch1";
#endif
    case EPOCH2_STYLE:
#if defined(vms)
      return "EPOCH2";
#else
      return "epoch2";
#endif
    case EPOCH3_STYLE:
#if defined(vms)
      return "EPOCH3";
#else
      return "epoch3";
#endif
    case EPOCHf_STYLE:
#if defined(vms)
      return "EPOCHf";
#else
      return "epochf";
#endif
    case EPOCHx_STYLE:
#if defined(vms)
      return "EPOCHx";
#else
      return "epochx";
#endif
  }
  return "?";
}

/******************************************************************************
* No.
******************************************************************************/

static char *No (state)
Logical state;
{
  switch (state) {
    case TRUE: return "";
#if defined(vms)
    case FALSE: return "NO";
#else
    case FALSE: return "no";
#endif
  }
  return "?";
}

/******************************************************************************
* InquireQOPs.
*    Returns TRUE if execution should continue.
******************************************************************************/

#if defined(mac)
Logical InquireQOPs (argC, argV)
int *argC;
char **argV[];
{
  DialogPtr dialogP;
  DialogRecord dRecord;
  WindowPtr behind = (WindowPtr) -1;
  ControlHandle controlHs[MAXIMUMin+1];
  Rect iRect;
  short itemN, iType;
  static Logical first = TRUE;
  char cancelTitle[] = "Cancel";

  static Logical pageOutput = DEFAULTpageINQ;
  static Logical showId = DEFAULTidINQ;

  /****************************************************************************
  * Create the dialog and get the control handles.
  ****************************************************************************/

  dialogP = GetNewDialog (QOPri, &dRecord, behind);
  
  for (itemN = 1; itemN <= MAXIMUMin; itemN++) {
     GetDItem (dialogP, itemN, &iType, (Handle *) &controlHs[itemN], &iRect);
  }

  /****************************************************************************
  * Set the control values.
  ****************************************************************************/

  if (pageOutput) SetCtlValue (controlHs[PAGEin], 1);
  if (showId) SetCtlValue (controlHs[IDin], 1);
  
  SetDItem (dialogP, (short) ODBin, (short) userItem,
	    (Handle) OutlineDefaultButton, &iRect);

  /****************************************************************************
  * Change the "Quit" button to a "Cancel" button after the first time.
  ****************************************************************************/

  if (first)
    first = FALSE;
  else
    SetCTitle (controlHs[CANCELin], CtoPstr(cancelTitle));

  /****************************************************************************
  * Display the dialog and wait for user actions.
  ****************************************************************************/
    
  ShowWindow ((WindowPtr) dialogP);
  SetCursor (ARROW_CURSOR);

  for (;;) {
    ModalDialog (FilterDialogQOPso, &itemN);
    switch (itemN) {
      /************************************************************************
      * Ok.
      ************************************************************************/
      case OKin: {
	int n;

	/**********************************************************************
	* Get the value of each control.
	**********************************************************************/

	pageOutput = GetCtlValue (controlHs[PAGEin]);

	/**********************************************************************
	* Build argc/argv.
	**********************************************************************/

        *argC = 3;
        *argV = (char **) AllocateMemory (*argC * sizeof(char *), FatalError);
	
	n = 0;
	MAKEstrARGv (argV, n, pgmName)
	MAKEstrARGv (argV, n, "-id")
	MAKEbooARGv (argV, n, pageOutput, "-page", "-nopage")

	/**********************************************************************
	* Close the dialog and return.
	**********************************************************************/
        CloseDialog (dialogP);
        return TRUE;
      }
      /************************************************************************
      * Help.
      ************************************************************************/
      case HELPin: {
        int n;
        *argC = 1;
        *argV = (char **) AllocateMemory (*argC * sizeof(char *), FatalError);
	n = 0;
	MAKEstrARGv (argV, n, pgmName)
	CloseDialog (dialogP);
        return TRUE;
      }
      /************************************************************************
      * Cancel.
      ************************************************************************/
      case CANCELin:
        CloseDialog (dialogP);
        return FALSE;
      /************************************************************************
      * Check boxes.
      ************************************************************************/
      case PAGEin:
        SetCtlValue (controlHs[itemN], BOO(GetCtlValue(controlHs[itemN]),0,1));
        break;
    }
  }
}
#endif
