/*
 *  DO NOT EDIT THIS FILE   (opts.c)
 *  
 *  It has been autogen-ed  Friday November  5, 1999 at 01:42:00 PM PST
 *  From the definitions    opts.def
 *  and the template file   ../autoopts/options.tpl
 */

static const char zCopyright[] =
       "columns copyright (c) 1999 Bruce Korb, all rights reserved";
static const char zCopyrightNotice[] =
       "columns is free software.\n"
       "\n"
       "You may redistribute it and/or modify it under the terms of the\n"
       "GNU General Public License, as published by the Free Software\n"
       "Foundation; either version 2, or (at your option) any later version.\n"
       "\n"
       "columns is distributed in the hope that it will be useful,\n"
       "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
       "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
       "See the GNU General Public License for more details.\n"
       "\n"
       "You should have received a copy of the GNU General Public License\n"
       "along with columns.  See the file \"COPYING\".  If not,\n"
       "write to:  The Free Software Foundation, Inc.,\n"
       "           59 Temple Place - Suite 330,\n"
       "           Boston,  MA  02111-1307, USA.";
#include "opts.h"

extern tUsageProc optionUsage;

#ifndef NULL
#  define NULL 0x0
#endif

#ifndef EXIT_SUCCESS
#  define  EXIT_SUCCESS 0
#  define  EXIT_FAILURE 1
#endif

/*
 *  global included definitions
 */
#include <stdio.h>
#include <errno.h>
#ifdef HAVE_CONFIG_H
#  include "config.h"
#endif
#ifdef USE_FOPEN_BINARY
#  define FOPEN_BINARY_FLAG "b"
#else
#  define FOPEN_BINARY_FLAG
#endif

/*
 *  Width option description:
 */
tSCC    zWidthText[] =
       "Maximum Line Width";
tSCC    zWidth_NAME[] =               "WIDTH";
#define zNotWidth_Pfx                 (const char*)NULL
#define zNotWidth_Name                (const char*)NULL
tSCC    zWidth_Name[] =               "width";

/*
 *  Columns option description:
 */
tSCC    zColumnsText[] =
       "Desired number of columns";
tSCC    zColumns_NAME[] =             "COLUMNS";
#define zNotColumns_Pfx               (const char*)NULL
#define zNotColumns_Name              (const char*)NULL
tSCC    zColumns_Name[] =             "columns";

/*
 *  Col_Width option description:
 */
tSCC    zCol_WidthText[] =
       "Set width of each column";
tSCC    zCol_Width_NAME[] =           "COL_WIDTH";
#define zNotCol_Width_Pfx             (const char*)NULL
#define zNotCol_Width_Name            (const char*)NULL
tSCC    zCol_Width_Name[] =           "col-width";

/*
 *  Spread option description:
 */
tSCC    zSpreadText[] =
       "maximum spread added to column width";
tSCC    zSpread_NAME[] =              "SPREAD";
#define zNotSpread_Pfx                (const char*)NULL
#define zNotSpread_Name               (const char*)NULL
tSCC    zSpread_Name[] =              "spread";

/*
 *  Indent option description:
 */
tSCC    zIndentText[] =
       "Line prefix or indentation";
tSCC    zIndent_NAME[] =              "INDENT";
#define zNotIndent_Pfx                (const char*)NULL
#define zNotIndent_Name               (const char*)NULL
tSCC    zIndent_Name[] =              "indent";

/*
 *  First_Indent option description with
 *  "Must also have options" and "Incompatible options":
 */
tSCC    zFirst_IndentText[] =
       "First line prefix";
tSCC    zFirst_Indent_NAME[] =        "FIRST_INDENT";
#define zNotFirst_Indent_Pfx          (const char*)NULL
#define zNotFirst_Indent_Name         (const char*)NULL
tSCC    zFirst_Indent_Name[] =        "first-indent";
static const int
    aFirst_IndentMustList[] = {
    INDEX_OPT_INDENT, NO_EQUIVALENT};

/*
 *  Tab_Width option description:
 */
tSCC    zTab_WidthText[] =
       "tab width";
tSCC    zTab_Width_NAME[] =           "TAB_WIDTH";
#define zNotTab_Width_Pfx             (const char*)NULL
#define zNotTab_Width_Name            (const char*)NULL
tSCC    zTab_Width_Name[] =           "tab-width";

/*
 *  Sort option description:
 */
tSCC    zSortText[] =
       "Sort input text";
tSCC    zSort_NAME[] =                "SORT";
#define zNotSort_Pfx                  (const char*)NULL
#define zNotSort_Name                 (const char*)NULL
tSCC    zSort_Name[] =                "sort";

/*
 *  Format option description:
 */
tSCC    zFormatText[] =
       "Formatting string for each input";
tSCC    zFormat_NAME[] =              "FORMAT";
#define zNotFormat_Pfx                (const char*)NULL
#define zNotFormat_Name               (const char*)NULL
tSCC    zFormat_Name[] =              "format";

/*
 *  Separation option description:
 */
tSCC    zSeparationText[] =
       "Separation string - follows all but last";
tSCC    zSeparation_NAME[] =          "SEPARATION";
#define zNotSeparation_Pfx            (const char*)NULL
#define zNotSeparation_Name           (const char*)NULL
tSCC    zSeparation_Name[] =          "separation";

/*
 *  Line_Separation option description:
 */
tSCC    zLine_SeparationText[] =
       "string at end of all lines but last";
tSCC    zLine_Separation_NAME[] =     "LINE_SEPARATION";
#define zNotLine_Separation_Pfx       (const char*)NULL
#define zNotLine_Separation_Name      (const char*)NULL
tSCC    zLine_Separation_Name[] =     "line-separation";

/*
 *  By_Columns option description:
 */
tSCC    zBy_ColumnsText[] =
       "Print entries in column order";
tSCC    zBy_Columns_NAME[] =          "BY_COLUMNS";
#define zNotBy_Columns_Pfx            (const char*)NULL
#define zNotBy_Columns_Name           (const char*)NULL
tSCC    zBy_Columns_Name[] =          "by-columns";

/*
 *  Input option description:
 */
tSCC    zInputText[] =
       "Input file (if not stdin)";
tSCC    zInput_NAME[] =               "INPUT";
#define zNotInput_Pfx                 (const char*)NULL
#define zNotInput_Name                (const char*)NULL
tSCC    zInput_Name[] =               "input";
/*
 *  Help option description:
 */
tSCC zHelpText[]  = "Display usage information and exit";
tSCC zHelp_Name[] = "help";

/*
 *  More_Help option description:
 */
tSCC zMore_HelpText[]  = "Extended usage information passed thru pager";
tSCC zMore_Help_Name[] = "more-help";

/*
 *  Version option description:
 */
tSCC zVersionText[]  = "Output version information and exit";
tSCC zVersion_Name[] = "version";
/*
 *  Procedures to call when option(s) are encountered
 */
static tOptProc doOptInput;

/*
 *  These are always callable, whether
 *  TEST_COLUMNS_OPTS is defined or not
 */
static tOptProc doUsageOpt;
extern tOptProc doVersion;
extern tOptProc doPagedUsage;

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *
 *  Define the Columns Option Descriptions.
 */
static tOptDesc optDesc[ OPTION_CT ] = {
  {  /* entry idx, value */ 0, VALUE_OPT_WIDTH,
     /* equiv idx, value */ 0, VALUE_OPT_WIDTH,
     /* option argument  */ ARG_MUST,
     /* equivalenced to  */ NO_EQUIVALENT,
     /* min, max, act ct */ 0, 1, 0,
     /* opt state flags  */ OPTST_NUMERIC | OPTST_DISABLED | OPTST_INIT,
     /* last opt argumnt */ (char*)79,
     /* arg list/cookie  */ (void*)NULL,
     /* must/cannot opts */ (const int*)NULL, (const int*)NULL,
     /* option proc      */ (tpOptProc)NULL,
     /* desc, NAME, name */ zWidthText,  zWidth_NAME,
                            zWidth_Name,
     /* disablement strs */ zNotWidth_Name, zNotWidth_Pfx },

  {  /* entry idx, value */ 1, VALUE_OPT_COLUMNS,
     /* equiv idx, value */ 1, VALUE_OPT_COLUMNS,
     /* option argument  */ ARG_MUST,
     /* equivalenced to  */ NO_EQUIVALENT,
     /* min, max, act ct */ 0, 1, 0,
     /* opt state flags  */ OPTST_NUMERIC | OPTST_DISABLED | OPTST_INIT,
     /* last opt argumnt */ (char*)0,
     /* arg list/cookie  */ (void*)NULL,
     /* must/cannot opts */ (const int*)NULL, (const int*)NULL,
     /* option proc      */ (tpOptProc)NULL,
     /* desc, NAME, name */ zColumnsText,  zColumns_NAME,
                            zColumns_Name,
     /* disablement strs */ zNotColumns_Name, zNotColumns_Pfx },

  {  /* entry idx, value */ 2, VALUE_OPT_COL_WIDTH,
     /* equiv idx, value */ 2, VALUE_OPT_COL_WIDTH,
     /* option argument  */ ARG_MUST,
     /* equivalenced to  */ NO_EQUIVALENT,
     /* min, max, act ct */ 0, 1, 0,
     /* opt state flags  */ OPTST_NUMERIC | OPTST_DISABLED | OPTST_INIT,
     /* last opt argumnt */ (char*)0,
     /* arg list/cookie  */ (void*)NULL,
     /* must/cannot opts */ (const int*)NULL, (const int*)NULL,
     /* option proc      */ (tpOptProc)NULL,
     /* desc, NAME, name */ zCol_WidthText,  zCol_Width_NAME,
                            zCol_Width_Name,
     /* disablement strs */ zNotCol_Width_Name, zNotCol_Width_Pfx },

  {  /* entry idx, value */ 3, VALUE_OPT_SPREAD,
     /* equiv idx, value */ 3, VALUE_OPT_SPREAD,
     /* option argument  */ ARG_MUST,
     /* equivalenced to  */ NO_EQUIVALENT,
     /* min, max, act ct */ 0, 1, 0,
     /* opt state flags  */ OPTST_NUMERIC | OPTST_DISABLED | OPTST_INIT,
     /* last opt argumnt */ (char*)0,
     /* arg list/cookie  */ (void*)NULL,
     /* must/cannot opts */ (const int*)NULL, (const int*)NULL,
     /* option proc      */ (tpOptProc)NULL,
     /* desc, NAME, name */ zSpreadText,  zSpread_NAME,
                            zSpread_Name,
     /* disablement strs */ zNotSpread_Name, zNotSpread_Pfx },

  {  /* entry idx, value */ 4, VALUE_OPT_INDENT,
     /* equiv idx, value */ 4, VALUE_OPT_INDENT,
     /* option argument  */ ARG_MUST,
     /* equivalenced to  */ NO_EQUIVALENT,
     /* min, max, act ct */ 0, 1, 0,
     /* opt state flags  */ OPTST_DISABLED | OPTST_INIT,
     /* last opt argumnt */ (char*)NULL,
     /* arg list/cookie  */ (void*)NULL,
     /* must/cannot opts */ (const int*)NULL, (const int*)NULL,
     /* option proc      */ (tpOptProc)NULL,
     /* desc, NAME, name */ zIndentText,  zIndent_NAME,
                            zIndent_Name,
     /* disablement strs */ zNotIndent_Name, zNotIndent_Pfx },

  {  /* entry idx, value */ 5, VALUE_OPT_FIRST_INDENT,
     /* equiv idx, value */ 5, VALUE_OPT_FIRST_INDENT,
     /* option argument  */ ARG_MUST,
     /* equivalenced to  */ NO_EQUIVALENT,
     /* min, max, act ct */ 0, 1, 0,
     /* opt state flags  */ OPTST_DISABLED | OPTST_INIT,
     /* last opt argumnt */ (char*)NULL,
     /* arg list/cookie  */ (void*)NULL,
     /* must/cannot opts */ aFirst_IndentMustList, (const int*)NULL,
     /* option proc      */ (tpOptProc)NULL,
     /* desc, NAME, name */ zFirst_IndentText,  zFirst_Indent_NAME,
                            zFirst_Indent_Name,
     /* disablement strs */ zNotFirst_Indent_Name, zNotFirst_Indent_Pfx },

  {  /* entry idx, value */ 6, VALUE_OPT_TAB_WIDTH,
     /* equiv idx, value */ 6, VALUE_OPT_TAB_WIDTH,
     /* option argument  */ ARG_MUST,
     /* equivalenced to  */ NO_EQUIVALENT,
     /* min, max, act ct */ 0, 1, 0,
     /* opt state flags  */ OPTST_NUMERIC | OPTST_DISABLED | OPTST_INIT,
     /* last opt argumnt */ (char*)8,
     /* arg list/cookie  */ (void*)NULL,
     /* must/cannot opts */ (const int*)NULL, (const int*)NULL,
     /* option proc      */ (tpOptProc)NULL,
     /* desc, NAME, name */ zTab_WidthText,  zTab_Width_NAME,
                            zTab_Width_Name,
     /* disablement strs */ zNotTab_Width_Name, zNotTab_Width_Pfx },

  {  /* entry idx, value */ 7, VALUE_OPT_SORT,
     /* equiv idx, value */ 7, VALUE_OPT_SORT,
     /* option argument  */ ARG_MAY,
     /* equivalenced to  */ NO_EQUIVALENT,
     /* min, max, act ct */ 0, 1, 0,
     /* opt state flags  */ OPTST_DISABLED | OPTST_INIT,
     /* last opt argumnt */ (char*)NULL,
     /* arg list/cookie  */ (void*)NULL,
     /* must/cannot opts */ (const int*)NULL, (const int*)NULL,
     /* option proc      */ (tpOptProc)NULL,
     /* desc, NAME, name */ zSortText,  zSort_NAME,
                            zSort_Name,
     /* disablement strs */ zNotSort_Name, zNotSort_Pfx },

  {  /* entry idx, value */ 8, VALUE_OPT_FORMAT,
     /* equiv idx, value */ 8, VALUE_OPT_FORMAT,
     /* option argument  */ ARG_MUST,
     /* equivalenced to  */ NO_EQUIVALENT,
     /* min, max, act ct */ 0, 1, 0,
     /* opt state flags  */ OPTST_DISABLED | OPTST_INIT,
     /* last opt argumnt */ (char*)NULL,
     /* arg list/cookie  */ (void*)NULL,
     /* must/cannot opts */ (const int*)NULL, (const int*)NULL,
     /* option proc      */ (tpOptProc)NULL,
     /* desc, NAME, name */ zFormatText,  zFormat_NAME,
                            zFormat_Name,
     /* disablement strs */ zNotFormat_Name, zNotFormat_Pfx },

  {  /* entry idx, value */ 9, VALUE_OPT_SEPARATION,
     /* equiv idx, value */ 9, VALUE_OPT_SEPARATION,
     /* option argument  */ ARG_MUST,
     /* equivalenced to  */ NO_EQUIVALENT,
     /* min, max, act ct */ 0, 1, 0,
     /* opt state flags  */ OPTST_DISABLED | OPTST_INIT,
     /* last opt argumnt */ (char*)NULL,
     /* arg list/cookie  */ (void*)NULL,
     /* must/cannot opts */ (const int*)NULL, (const int*)NULL,
     /* option proc      */ (tpOptProc)NULL,
     /* desc, NAME, name */ zSeparationText,  zSeparation_NAME,
                            zSeparation_Name,
     /* disablement strs */ zNotSeparation_Name, zNotSeparation_Pfx },

  {  /* entry idx, value */ 10, VALUE_OPT_LINE_SEPARATION,
     /* equiv idx, value */ 10, VALUE_OPT_LINE_SEPARATION,
     /* option argument  */ ARG_MUST,
     /* equivalenced to  */ NO_EQUIVALENT,
     /* min, max, act ct */ 0, 1, 0,
     /* opt state flags  */ OPTST_DISABLED | OPTST_INIT,
     /* last opt argumnt */ (char*)NULL,
     /* arg list/cookie  */ (void*)NULL,
     /* must/cannot opts */ (const int*)NULL, (const int*)NULL,
     /* option proc      */ (tpOptProc)NULL,
     /* desc, NAME, name */ zLine_SeparationText,  zLine_Separation_NAME,
                            zLine_Separation_Name,
     /* disablement strs */ zNotLine_Separation_Name, zNotLine_Separation_Pfx },

  {  /* entry idx, value */ 11, VALUE_OPT_BY_COLUMNS,
     /* equiv idx, value */ 11, VALUE_OPT_BY_COLUMNS,
     /* option argument  */ ARG_NONE,
     /* equivalenced to  */ NO_EQUIVALENT,
     /* min, max, act ct */ 0, 1, 0,
     /* opt state flags  */ OPTST_DISABLED | OPTST_INIT,
     /* last opt argumnt */ (char*)NULL,
     /* arg list/cookie  */ (void*)NULL,
     /* must/cannot opts */ (const int*)NULL, (const int*)NULL,
     /* option proc      */ (tpOptProc)NULL,
     /* desc, NAME, name */ zBy_ColumnsText,  zBy_Columns_NAME,
                            zBy_Columns_Name,
     /* disablement strs */ zNotBy_Columns_Name, zNotBy_Columns_Pfx },

  {  /* entry idx, value */ 12, VALUE_OPT_INPUT,
     /* equiv idx, value */ 12, VALUE_OPT_INPUT,
     /* option argument  */ ARG_MUST,
     /* equivalenced to  */ NO_EQUIVALENT,
     /* min, max, act ct */ 0, 1, 0,
     /* opt state flags  */ OPTST_DISABLED | OPTST_INIT,
     /* last opt argumnt */ (char*)NULL,
     /* arg list/cookie  */ (void*)NULL,
     /* must/cannot opts */ (const int*)NULL, (const int*)NULL,
     /* option proc      */ doOptInput,
     /* desc, NAME, name */ zInputText,  zInput_NAME,
                            zInput_Name,
     /* disablement strs */ zNotInput_Name, zNotInput_Pfx },

  {  /* entry idx, value */ INDEX_OPT_VERSION, VALUE_OPT_VERSION,
     /* equiv idx value  */ NO_EQUIVALENT, 0,
     /* option argument  */ ARG_MAY,
     /* equivalenced to  */ NO_EQUIVALENT,
     /* min, max act ct  */ 0, 1, 0,
     /* opt state flags  */ OPTST_INIT,
     /* last opt argumnt */ (char*)NULL,
     /* arg list/cookie  */ (void*)NULL,
     /* must/cannot opts */ (const int*)NULL,  (const int*)NULL,
     /* option proc      */ doVersion,
     /* desc, NAME, name */ zVersionText,      (const char*)NULL,
                            zVersion_Name,
     /* disablement strs */ (const char*)NULL, (const char*)NULL },

  {  /* entry idx, value */ INDEX_OPT_HELP, VALUE_OPT_HELP,
     /* equiv idx value  */ NO_EQUIVALENT, 0,
     /* option argument  */ ARG_NONE,
     /* equivalenced to  */ NO_EQUIVALENT,
     /* min, max act ct  */ 0, 1, 0,
     /* opt state flags  */ OPTST_INIT,
     /* last opt argumnt */ (char*)NULL,
     /* arg list/cookie  */ (void*)NULL,
     /* must/cannot opts */ (const int*)NULL,  (const int*)NULL,
     /* option proc      */ doUsageOpt,
     /* desc, NAME, name */ zHelpText,         (const char*)NULL,
                            zHelp_Name,
     /* disablement strs */ (const char*)NULL, (const char*)NULL },

  {  /* entry idx, value */ INDEX_OPT_MORE_HELP, VALUE_OPT_MORE_HELP,
     /* equiv idx value  */ NO_EQUIVALENT, 0,
     /* option argument  */ ARG_NONE,
     /* equivalenced to  */ NO_EQUIVALENT,
     /* min, max act ct  */ 0, 1, 0,
     /* opt state flags  */ OPTST_INIT,
     /* last opt argumnt */ (char*)NULL,
     /* arg list/cookie  */ (void*)NULL,
     /* must/cannot opts */ (const int*)NULL,  (const int*)NULL,
     /* option proc      */ doPagedUsage,
     /* desc, NAME, name */ zMore_HelpText,    (const char*)NULL,
                            zMore_Help_Name,
     /* disablement strs */ (const char*)NULL, (const char*)NULL }
};

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *
 *  Define the Columns Option Environment
 */
tSCC   zPROGNAME[]   = "COLUMNS";
tSCC   zUsageTitle[] = COLUMNS_FULL_VERSION 
    "\nUSAGE:  %s [-<flag> [<val>]]... [--<name>[{=| }<val>]]... \n";
#define zRcName     (tCC*)NULL
#define apzHomeList (tCC**)NULL
#define zExplain (const char*)NULL

tSCC    zDetail[]     = "\n"
       "This program was designed for the purpose of generating compact,\n"
       "columnized tables.  It will read a list of text items from standard\n"
       "in or a specified input file and produce a columnized listing of\n"
       "all the non-blank lines.  Leading white space on each line is\n"
       "preserved, but trailing white space is stripped.  Methods of\n"
       "applying per-entry and per-line embellishments are provided.\n"
       "See the formatting and separation arguments below.\n"
       "\n"
       "This program is used by AutoGen to help clean up and organize\n"
       "its output." "\n";

#define zDetailFile (const char*)NULL
extern  tUsageProc optionUsage;
tSCC    zFullVersion[] = COLUMNS_FULL_VERSION;

tOptions columnsOptions = {
    OPTIONS_STRUCT_VERSION,
    (char*)NULL,    (char*)NULL,    zPROGNAME,
    zRcName,        zCopyright,     zCopyrightNotice,
    zFullVersion,   apzHomeList,    zUsageTitle,
    zExplain,       zDetail,        zDetailFile,
    optionUsage,
    ( OPTPROC_NONE
    + OPTPROC_ERRSTOP
    + OPTPROC_SHORTOPT
    + OPTPROC_LONGOPT
    + OPTPROC_NO_REQ_OPT
    + OPTPROC_NO_ARGS ),
    0, (char*)NULL,
    { INDEX_OPT_MORE_HELP,
       0 /* no option state saving */,
      NO_EQUIVALENT /* no '-#' option */,
      NO_EQUIVALENT /* no '-#' option */ },
    OPTION_CT, 13,
    optDesc
};

/*
 *  Create the static procedure(s) declared above.
 */
    static void
doUsageOpt( tOptions*  pOpts, tOptDesc* pOD )
{
    USAGE( EXIT_SUCCESS );
}
/*
 *  Generated option processing procedures
 */
/* * * * * * *
 *
 *   For the "Input Option".
 */
    static void
doOptInput( tOptions* pOptions, tOptDesc* pOptDesc )
{
    FILE* fp = freopen( pOptDesc->pzLastArg, "r" FOPEN_BINARY_FLAG, stdin );
    if (fp == (FILE*)NULL) {
        fprintf( stderr, "Error %d (%s) opening %s\n",
                 errno, strerror( errno ), pOptDesc->pzLastArg );
        USAGE( EXIT_FAILURE );
    }
}

