/* -*- buffer-read-only: t -*- vi: set ro: * * DO NOT EDIT THIS FILE (opts.c) * * It has been AutoGen-ed Saturday July 28, 2007 at 01:02:41 PM PDT * From the definitions opts.def * and the template file options * * Generated from AutoOpts 30:0:5 templates. */ /* * This file was produced by an AutoOpts template. AutoOpts is a * copyrighted work. This source file is not encumbered by AutoOpts * licensing, but is provided under the licensing terms chosen by the * columns author or copyright holder. AutoOpts is licensed under * the terms of the LGPL. The redistributable library (``libopts'') is * licensed under the terms of either the LGPL or, at the users discretion, * the BSD license. See the AutoOpts and/or libopts sources for details. * * This source file is copyrighted and licensed under the following terms: * * columns copyright 1999-2007 Bruce Korb - all rights reserved * * columns is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * columns is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #include #define OPTION_CODE_COMPILE 1 #include "opts.h" #ifdef __cplusplus extern "C" { #endif tSCC zCopyright[] = "columns copyright (c) 1999-2007 Bruce Korb, all rights reserved"; tSCC zCopyrightNotice[] = "columns is free software: you can redistribute it and/or modify it\n\ under the terms of the GNU General Public License as published by the\n\ Free Software Foundation, either version 3 of the License, or\n\ (at your option) any later version.\n\n\ columns is distributed in the hope that it will be useful, but\n\ 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 along\n\ with this program. If not, see ."; extern tUsageProc optionUsage; /* * global included definitions */ #include #include #include #ifdef HAVE_CONFIG_H # include "config.h" #endif #ifndef NULL # define NULL 0 #endif #ifndef EXIT_SUCCESS # define EXIT_SUCCESS 0 #endif #ifndef EXIT_FAILURE # define EXIT_FAILURE 1 #endif /* * Width option description: */ tSCC zWidthText[] = "Maximum Line Width"; tSCC zWidth_NAME[] = "WIDTH"; tSCC zWidth_Name[] = "width"; #define zWidthDefaultArg ((char const*)79) #define WIDTH_FLAGS (OPTST_DISABLED \ | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC)) /* * Columns option description: */ tSCC zColumnsText[] = "Desired number of columns"; tSCC zColumns_NAME[] = "COLUMNS"; tSCC zColumns_Name[] = "columns"; #define zColumnsDefaultArg ((char const*)0) #define COLUMNS_FLAGS (OPTST_DISABLED \ | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC)) /* * Col_Width option description: */ tSCC zCol_WidthText[] = "Set width of each column"; tSCC zCol_Width_NAME[] = "COL_WIDTH"; tSCC zCol_Width_Name[] = "col-width"; #define zCol_WidthDefaultArg ((char const*)0) #define COL_WIDTH_FLAGS (OPTST_DISABLED \ | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC)) /* * Spread option description: */ tSCC zSpreadText[] = "maximum spread added to column width"; tSCC zSpread_NAME[] = "SPREAD"; tSCC zSpread_Name[] = "spread"; #define zSpreadDefaultArg ((char const*)0) #define SPREAD_FLAGS (OPTST_DISABLED \ | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC)) /* * Indent option description: */ tSCC zIndentText[] = "Line prefix or indentation"; tSCC zIndent_NAME[] = "INDENT"; tSCC zIndent_Name[] = "indent"; #define INDENT_FLAGS (OPTST_DISABLED \ | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) /* * First_Indent option description with * "Must also have options" and "Incompatible options": */ tSCC zFirst_IndentText[] = "First line prefix"; tSCC zFirst_Indent_NAME[] = "FIRST_INDENT"; tSCC zFirst_Indent_Name[] = "first-indent"; static const int aFirst_IndentMustList[] = { INDEX_OPT_INDENT, NO_EQUIVALENT }; #define FIRST_INDENT_FLAGS (OPTST_DISABLED \ | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) /* * Tab_Width option description: */ tSCC zTab_WidthText[] = "tab width"; tSCC zTab_Width_NAME[] = "TAB_WIDTH"; tSCC zTab_Width_Name[] = "tab-width"; #define zTab_WidthDefaultArg ((char const*)8) #define TAB_WIDTH_FLAGS (OPTST_DISABLED \ | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC)) /* * Sort option description: */ tSCC zSortText[] = "Sort input text"; tSCC zSort_NAME[] = "SORT"; tSCC zSort_Name[] = "sort"; #define SORT_FLAGS (OPTST_DISABLED \ | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) | OPTST_ARG_OPTIONAL) /* * Format option description: */ tSCC zFormatText[] = "Formatting string for each input"; tSCC zFormat_NAME[] = "FORMAT"; tSCC zFormat_Name[] = "format"; #define FORMAT_FLAGS (OPTST_DISABLED \ | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) /* * Separation option description: */ tSCC zSeparationText[] = "Separation string - follows all but last"; tSCC zSeparation_NAME[] = "SEPARATION"; tSCC zSeparation_Name[] = "separation"; #define SEPARATION_FLAGS (OPTST_DISABLED \ | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) /* * Line_Separation option description: */ tSCC zLine_SeparationText[] = "string at end of all lines but last"; tSCC zLine_Separation_NAME[] = "LINE_SEPARATION"; tSCC zLine_Separation_Name[] = "line-separation"; #define LINE_SEPARATION_FLAGS (OPTST_DISABLED \ | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) /* * By_Columns option description: */ tSCC zBy_ColumnsText[] = "Print entries in column order"; tSCC zBy_Columns_NAME[] = "BY_COLUMNS"; tSCC zBy_Columns_Name[] = "by-columns"; #define BY_COLUMNS_FLAGS (OPTST_DISABLED) /* * Input option description: */ tSCC zInputText[] = "Input file (if not stdin)"; tSCC zInput_NAME[] = "INPUT"; tSCC zInput_Name[] = "input"; #define INPUT_FLAGS (OPTST_DISABLED \ | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) /* * Help/More_Help/Version option descriptions: */ tSCC zHelpText[] = "Display usage information and exit"; tSCC zHelp_Name[] = "help"; tSCC zMore_HelpText[] = "Extended usage information passed thru pager"; tSCC zMore_Help_Name[] = "more-help"; tSCC zVersionText[] = "Output version information and exit"; tSCC zVersion_Name[] = "version"; /* * Declare option callback procedures */ extern tOptProc optionNumericVal, optionPagedUsage, optionPrintVersion; static tOptProc doOptInput, doUsageOpt; /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Define the Columns Option Descriptions. */ static tOptDesc optDesc[ OPTION_CT ] = { { /* entry idx, value */ 0, VALUE_OPT_WIDTH, /* equiv idx, value */ 0, VALUE_OPT_WIDTH, /* equivalenced to */ NO_EQUIVALENT, /* min, max, act ct */ 0, 1, 0, /* opt state flags */ WIDTH_FLAGS, 0, /* last opt argumnt */ { zWidthDefaultArg }, /* arg list/cookie */ NULL, /* must/cannot opts */ NULL, NULL, /* option proc */ optionNumericVal, /* desc, NAME, name */ zWidthText, zWidth_NAME, zWidth_Name, /* disablement strs */ NULL, NULL }, { /* entry idx, value */ 1, VALUE_OPT_COLUMNS, /* equiv idx, value */ 1, VALUE_OPT_COLUMNS, /* equivalenced to */ NO_EQUIVALENT, /* min, max, act ct */ 0, 1, 0, /* opt state flags */ COLUMNS_FLAGS, 0, /* last opt argumnt */ { zColumnsDefaultArg }, /* arg list/cookie */ NULL, /* must/cannot opts */ NULL, NULL, /* option proc */ optionNumericVal, /* desc, NAME, name */ zColumnsText, zColumns_NAME, zColumns_Name, /* disablement strs */ NULL, NULL }, { /* entry idx, value */ 2, VALUE_OPT_COL_WIDTH, /* equiv idx, value */ 2, VALUE_OPT_COL_WIDTH, /* equivalenced to */ NO_EQUIVALENT, /* min, max, act ct */ 0, 1, 0, /* opt state flags */ COL_WIDTH_FLAGS, 0, /* last opt argumnt */ { zCol_WidthDefaultArg }, /* arg list/cookie */ NULL, /* must/cannot opts */ NULL, NULL, /* option proc */ optionNumericVal, /* desc, NAME, name */ zCol_WidthText, zCol_Width_NAME, zCol_Width_Name, /* disablement strs */ NULL, NULL }, { /* entry idx, value */ 3, VALUE_OPT_SPREAD, /* equiv idx, value */ 3, VALUE_OPT_SPREAD, /* equivalenced to */ NO_EQUIVALENT, /* min, max, act ct */ 0, 1, 0, /* opt state flags */ SPREAD_FLAGS, 0, /* last opt argumnt */ { zSpreadDefaultArg }, /* arg list/cookie */ NULL, /* must/cannot opts */ NULL, NULL, /* option proc */ optionNumericVal, /* desc, NAME, name */ zSpreadText, zSpread_NAME, zSpread_Name, /* disablement strs */ NULL, NULL }, { /* entry idx, value */ 4, VALUE_OPT_INDENT, /* equiv idx, value */ 4, VALUE_OPT_INDENT, /* equivalenced to */ NO_EQUIVALENT, /* min, max, act ct */ 0, 1, 0, /* opt state flags */ INDENT_FLAGS, 0, /* last opt argumnt */ { NULL }, /* arg list/cookie */ NULL, /* must/cannot opts */ NULL, NULL, /* option proc */ NULL, /* desc, NAME, name */ zIndentText, zIndent_NAME, zIndent_Name, /* disablement strs */ NULL, NULL }, { /* entry idx, value */ 5, VALUE_OPT_FIRST_INDENT, /* equiv idx, value */ 5, VALUE_OPT_FIRST_INDENT, /* equivalenced to */ NO_EQUIVALENT, /* min, max, act ct */ 0, 1, 0, /* opt state flags */ FIRST_INDENT_FLAGS, 0, /* last opt argumnt */ { NULL }, /* arg list/cookie */ NULL, /* must/cannot opts */ aFirst_IndentMustList, NULL, /* option proc */ NULL, /* desc, NAME, name */ zFirst_IndentText, zFirst_Indent_NAME, zFirst_Indent_Name, /* disablement strs */ NULL, NULL }, { /* entry idx, value */ 6, VALUE_OPT_TAB_WIDTH, /* equiv idx, value */ 6, VALUE_OPT_TAB_WIDTH, /* equivalenced to */ NO_EQUIVALENT, /* min, max, act ct */ 0, 1, 0, /* opt state flags */ TAB_WIDTH_FLAGS, 0, /* last opt argumnt */ { zTab_WidthDefaultArg }, /* arg list/cookie */ NULL, /* must/cannot opts */ NULL, NULL, /* option proc */ optionNumericVal, /* desc, NAME, name */ zTab_WidthText, zTab_Width_NAME, zTab_Width_Name, /* disablement strs */ NULL, NULL }, { /* entry idx, value */ 7, VALUE_OPT_SORT, /* equiv idx, value */ 7, VALUE_OPT_SORT, /* equivalenced to */ NO_EQUIVALENT, /* min, max, act ct */ 0, 1, 0, /* opt state flags */ SORT_FLAGS, 0, /* last opt argumnt */ { NULL }, /* arg list/cookie */ NULL, /* must/cannot opts */ NULL, NULL, /* option proc */ NULL, /* desc, NAME, name */ zSortText, zSort_NAME, zSort_Name, /* disablement strs */ NULL, NULL }, { /* entry idx, value */ 8, VALUE_OPT_FORMAT, /* equiv idx, value */ 8, VALUE_OPT_FORMAT, /* equivalenced to */ NO_EQUIVALENT, /* min, max, act ct */ 0, 1, 0, /* opt state flags */ FORMAT_FLAGS, 0, /* last opt argumnt */ { NULL }, /* arg list/cookie */ NULL, /* must/cannot opts */ NULL, NULL, /* option proc */ NULL, /* desc, NAME, name */ zFormatText, zFormat_NAME, zFormat_Name, /* disablement strs */ NULL, NULL }, { /* entry idx, value */ 9, VALUE_OPT_SEPARATION, /* equiv idx, value */ 9, VALUE_OPT_SEPARATION, /* equivalenced to */ NO_EQUIVALENT, /* min, max, act ct */ 0, 1, 0, /* opt state flags */ SEPARATION_FLAGS, 0, /* last opt argumnt */ { NULL }, /* arg list/cookie */ NULL, /* must/cannot opts */ NULL, NULL, /* option proc */ NULL, /* desc, NAME, name */ zSeparationText, zSeparation_NAME, zSeparation_Name, /* disablement strs */ NULL, NULL }, { /* entry idx, value */ 10, VALUE_OPT_LINE_SEPARATION, /* equiv idx, value */ 10, VALUE_OPT_LINE_SEPARATION, /* equivalenced to */ NO_EQUIVALENT, /* min, max, act ct */ 0, 1, 0, /* opt state flags */ LINE_SEPARATION_FLAGS, 0, /* last opt argumnt */ { NULL }, /* arg list/cookie */ NULL, /* must/cannot opts */ NULL, NULL, /* option proc */ NULL, /* desc, NAME, name */ zLine_SeparationText, zLine_Separation_NAME, zLine_Separation_Name, /* disablement strs */ NULL, NULL }, { /* entry idx, value */ 11, VALUE_OPT_BY_COLUMNS, /* equiv idx, value */ 11, VALUE_OPT_BY_COLUMNS, /* equivalenced to */ NO_EQUIVALENT, /* min, max, act ct */ 0, 1, 0, /* opt state flags */ BY_COLUMNS_FLAGS, 0, /* last opt argumnt */ { NULL }, /* arg list/cookie */ NULL, /* must/cannot opts */ NULL, NULL, /* option proc */ NULL, /* desc, NAME, name */ zBy_ColumnsText, zBy_Columns_NAME, zBy_Columns_Name, /* disablement strs */ NULL, NULL }, { /* entry idx, value */ 12, VALUE_OPT_INPUT, /* equiv idx, value */ 12, VALUE_OPT_INPUT, /* equivalenced to */ NO_EQUIVALENT, /* min, max, act ct */ 0, 1, 0, /* opt state flags */ INPUT_FLAGS, 0, /* last opt argumnt */ { NULL }, /* arg list/cookie */ NULL, /* must/cannot opts */ NULL, NULL, /* option proc */ doOptInput, /* desc, NAME, name */ zInputText, zInput_NAME, zInput_Name, /* disablement strs */ NULL, NULL }, #ifdef NO_OPTIONAL_OPT_ARGS # define VERSION_OPT_FLAGS OPTST_IMM | OPTST_NO_INIT #else # define VERSION_OPT_FLAGS OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) | \ OPTST_ARG_OPTIONAL | OPTST_IMM | OPTST_NO_INIT #endif { /* entry idx, value */ INDEX_OPT_VERSION, VALUE_OPT_VERSION, /* equiv idx value */ NO_EQUIVALENT, 0, /* equivalenced to */ NO_EQUIVALENT, /* min, max, act ct */ 0, 1, 0, /* opt state flags */ VERSION_OPT_FLAGS, 0, /* last opt argumnt */ { NULL }, /* arg list/cookie */ NULL, /* must/cannot opts */ NULL, NULL, /* option proc */ optionPrintVersion, /* desc, NAME, name */ zVersionText, NULL, zVersion_Name, /* disablement strs */ NULL, NULL }, #undef VERSION_OPT_FLAGS { /* entry idx, value */ INDEX_OPT_HELP, VALUE_OPT_HELP, /* equiv idx value */ NO_EQUIVALENT, 0, /* equivalenced to */ NO_EQUIVALENT, /* min, max, act ct */ 0, 1, 0, /* opt state flags */ OPTST_IMM | OPTST_NO_INIT, 0, /* last opt argumnt */ { NULL }, /* arg list/cookie */ NULL, /* must/cannot opts */ NULL, NULL, /* option proc */ doUsageOpt, /* desc, NAME, name */ zHelpText, NULL, zHelp_Name, /* disablement strs */ NULL, NULL }, { /* entry idx, value */ INDEX_OPT_MORE_HELP, VALUE_OPT_MORE_HELP, /* equiv idx value */ NO_EQUIVALENT, 0, /* equivalenced to */ NO_EQUIVALENT, /* min, max, act ct */ 0, 1, 0, /* opt state flags */ OPTST_IMM | OPTST_NO_INIT, 0, /* last opt argumnt */ { NULL }, /* arg list/cookie */ NULL, /* must/cannot opts */ NULL, NULL, /* option proc */ optionPagedUsage, /* desc, NAME, name */ zMore_HelpText, NULL, zMore_Help_Name, /* disablement strs */ NULL, NULL } }; /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Define the Columns Option Environment */ tSCC zPROGNAME[] = "COLUMNS"; tSCC zUsageTitle[] = "columns (GNU AutoGen) - Columnize Input Text - Ver. 1.1\n\ USAGE: %s [ - [] | --[{=| }] ]...\n"; #define zRcName NULL #define apzHomeList NULL tSCC zBugsAddr[] = "autogen-users@lists.sourceforge.net"; #define zExplain 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"; tSCC zFullVersion[] = COLUMNS_FULL_VERSION; /* extracted from ../autoopts/optcode.tpl near line 428 */ #if defined(ENABLE_NLS) # define OPTPROC_BASE OPTPROC_TRANSLATE static tOptionXlateProc translate_option_strings; #else # define OPTPROC_BASE OPTPROC_NONE # define translate_option_strings NULL #endif /* ENABLE_NLS */ #define columns_full_usage NULL #define columns_short_usage NULL tOptions columnsOptions = { OPTIONS_STRUCT_VERSION, 0, NULL, /* original argc + argv */ ( OPTPROC_BASE + OPTPROC_ERRSTOP + OPTPROC_SHORTOPT + OPTPROC_LONGOPT + OPTPROC_NO_REQ_OPT + OPTPROC_NO_ARGS ), 0, NULL, /* current option index, current option */ NULL, NULL, zPROGNAME, zRcName, zCopyright, zCopyrightNotice, zFullVersion, apzHomeList, zUsageTitle, zExplain, zDetail, optDesc, zBugsAddr, /* address to send bugs to */ NULL, NULL, /* extensions/saved state */ optionUsage, /* usage procedure */ translate_option_strings, /* translation procedure */ /* * Indexes to special options */ { INDEX_OPT_MORE_HELP, 0 /* no option state saving */, NO_EQUIVALENT /* index of '-#' option */, NO_EQUIVALENT /* index of default opt */ }, 16 /* full option count */, 13 /* user option count */, columns_full_usage, columns_short_usage }; /* * Create the static procedure(s) declared above. */ static void doUsageOpt( tOptions* pOptions, tOptDesc* pOptDesc ) { USAGE( EXIT_SUCCESS ); } /* * * * * * * * * For the input option. */ static void doOptInput( tOptions* pOptions, tOptDesc* pOptDesc ) { /* extracted from opts.def, line 209 */ 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 ); } } /* extracted from ../autoopts/optcode.tpl near line 537 */ #if ENABLE_NLS #include #include #include #include #include static char* AO_gettext( char const* pz ); static void coerce_it(void** s); static char* AO_gettext( char const* pz ) { char* pzRes; if (pz == NULL) return NULL; pzRes = _(pz); if (pzRes == pz) return pzRes; pzRes = strdup( pzRes ); if (pzRes == NULL) { fputs( _("No memory for duping translated strings\n"), stderr ); exit( EXIT_FAILURE ); } return pzRes; } static void coerce_it(void** s) { *s = AO_gettext(*s); } #define COERSION(_f) \ coerce_it((void*)&(columnsOptions._f)) /* * This invokes the translation code (e.g. gettext(3)). */ static void translate_option_strings( void ) { /* * Guard against re-translation. It won't work. The strings will have * been changed by the first pass through this code. One shot only. */ if (option_usage_text.field_ct == 0) return; /* * Do the translations. The first pointer follows the field count field. * The field count field is the size of a pointer. */ { char** ppz = (char**)(void*)&(option_usage_text); int ix = option_usage_text.field_ct; do { ppz++; *ppz = AO_gettext(*ppz); } while (--ix > 0); } option_usage_text.field_ct = 0; { tOptDesc* pOD = columnsOptions.pOptDesc; int ix = columnsOptions.optCt; for (;;) { pOD->pzText = AO_gettext(pOD->pzText); pOD->pz_NAME = AO_gettext(pOD->pz_NAME); pOD->pz_Name = AO_gettext(pOD->pz_Name); pOD->pz_DisableName = AO_gettext(pOD->pz_DisableName); pOD->pz_DisablePfx = AO_gettext(pOD->pz_DisablePfx); if (--ix <= 0) break; pOD++; } } COERSION(pzCopyright); COERSION(pzCopyNotice); COERSION(pzFullVersion); COERSION(pzUsageTitle); COERSION(pzExplain); COERSION(pzDetail); } #endif /* ENABLE_NLS */ #ifdef __cplusplus } #endif /* opts.c ends here */