[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8. Add-on packages for AutoGen

This chapter includes several programs that either work closely with AutoGen (extracting definitions or providing special formatting functions), or leverage off of AutoGen technology. There is also a formatting library that helps make AutoGen possible.

AutoOpts ought to appear in this list as well, but since it is the primary reason why many people would even look into AutoGen at all, I decided to leave it in the list of chapters.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.1 Automated Finite State Machine

The templates to generate a finite state machine in C or C++ is included with AutoGen. The documentation is not. The documentation is in HTML format for viewing, or you can download FSM.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.2 Combined RPC Marshalling

The templates and NFSv4 definitions are not included with AutoGen in any way. The folks that designed NFSv4 noticed that much time and bandwidth was wasted sending queries and responses when many of them could be bundled. The protocol bundles the data, but there is no support for it in rpcgen. That means you have to write your own code to do that. Until now. Download this and you will have a large, complex example of how to use AutoXDR for generating the marshaling and unmarshaling of combined RPC calls. There is a brief example on the web, but you should download AutoXDR.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.3 Automated Event Management

Large software development projects invariably have a need to manage the distribution and display of state information and state changes. In other words, they need to manage their software events. Generally, each such project invents its own way of accomplishing this and then struggles to get all of its components to play the same way. It is a difficult process and not always completely successful. This project helps with that.

AutoEvents completely separates the tasks of supplying the data needed for a particular event from the methods used to manage the distribution and display of that event. Consequently, the programmer writing the code no longer has to worry about that part of the problem. Likewise the persons responsible for designing the event management and distribution no longer have to worry about getting programmers to write conforming code.

This is a work in progress. See my web page on the subject, if you are interested. I have some useful things put together, but it is not ready to call a product.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.4 Bit Maps and Enumerations

AutoGen provides two templates for managing enumerations and bit maps (flag words). They produce an enumeration of the enum or #defines for the bit maps, plus conversion functions for converting a string into one of these values or converting one of these values into a human readable string. Finally, for enumerations, you may specify one or more sets of dispatching functions that will be selected by identifying a keyword prefix of a string (see section the dispatch attribute in Strings to Enums and Back).

There is a separate project that produces a GDB add-on that will add these capabilities into GDB for bit masks. (GDB does just fine with enumerations.)


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.4.1 Enumerations

str2enum.tpl

Produce an enumeration for a list of input “cmd”s (names). Optionally, produce functions to:

The header file produced will contain the enumeration and declarations for the optional procedures. The code (‘.c’) file will contain these optional procedures, but can be omitted if the no-code attribute is specified.

The following attributes are recognized with the str2enum template:

cmd

You must provide a series of these attributes: they specify the list of names used in the enumeration. Specific values for the names may be specified by specifying a numeric index for these attributes. e.g. cmd[5] = mumble; will cause

 
FOO_CMD_MUMBLE = 5

to be inserted into the enumeration. Do not specify a value of “invalid”, unless you specify the invalid-name attribute. (In that case, do not specify a cmd value that matches the invalid-name value.)

prefix

This specifies the first segment of each enumeration name. If not specified, the first segment of the enumeration definition file name will be used. e.g. ‘foo-bar.def’ will default to a FOO prefix.

type

Normally, there is a second constant segment following the prefix. If not specified, it will be CMD, so if both prefix and type were to default from ‘foo-bar.def’, you will have enumeration values prefixed with FOO_CMD_. If specified as the empty string, there will be no “type” component to the name and the default constant prefix will thus be FOO_.

base-name

This specifies the base name of the output files, enumeration type and the translation functions. The default is to use the basename(3) of the definition file. e.g. ‘foo-bar.def’ results in a base-name of foo-bar.

invalid-val

The default invalid value is zero. Sometimes, it is useful for zero to be valid. If so, you can specify ~0 or the empty string to be invalid. The empty string will cause the enumeration count (maximum value plus 1) to be the invalid value.

invalid-name

By default, the invalid value is emitted into the enumeration as FOO_INVALID_CMD. Specifying this attribute will replace INVALID with whatever you place in this attribute.

add-on-text

Additional text to insert into the code or header file.

ao-file

Which file to insert the text into. There are four choices, only two of which are relevant for the ‘str2enum’ template: “enum-header”, “enum-code”, “mask-header” or “mask-code”.

ao-text

The text to insert.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.4.2 Strings to Enums and Back

A continuation of the attributes for the ‘str2enum.tpl’ template.

no-code

Do not emit any string to enumeration or enumeration to string code at all. If this is specified, the remainder of the attributes have no effect.

no-name

Do not emit the enumeration to name function.

no-case

When looking up a string, the case of the input string is ignored.

alias

A single punctuation character can be interpreted as a command. The first character of this attribute is the aliased character and the remainder the aliased-to command. e.g. “#comment” makes ’#’ an alias for the comment command. “#comment” must still be listed in the cmd attributes.

length

Specify how lengths are to be handled. Under the covers, gperf(1) is used to map a string to an enumeration value. The code it produces requires the string length to be passed in. You may pass in the length yourself, or the generated code may figure it out, or you may ask for that length to be returned back after being figured out.

You have four choices with the length attribute:

partial

Normally, a name must fully match to be found successfully. This attribute causes the generated code to look for partial matches if the full match gperf function fails. Partial matches must be at least two characters long.

undef-str

by default, the display string for an undefined value is “* UNDEFINED *”. Use this to change that.

equate

A series of punctuation characters considered equivalent. Typically, “-_” but sometimes (Tandem) “-_^”. Do not use ’#’ in the list of characters.

dispatch

A lookup procedure will call a dispatch function for the procedure named after the keyword identified at the start of a string. Other than as specially noted below, for every named “cmd”, must have a handling function, plus another function to handle errors, with “invalid” (or the invalid-name value) as the cmd name. Multiple dispatch definitions will produce multiple dispatching functions, each with (potentially) unique argument lists and return types.

You may also use add-on-text to “#define” one function to another, thus allowing one function to handle multiple keywords or commands. The d-nam and d-ret attributes are required. The d-arg, d-omit and d-only attributes are optional:

d-nam

This must be a printf format string with one formatting element: %s. The %s will be replaced by each cmd name. The %s will be stripped and the result will be combined with the base name to construct the dispatch procedure name.

d-ret

The return type of the dispatched function, even if “void”.

d-arg

If there are additional arguments that are to be passed through to the dispatched function, specify this as though it were part of the procedure header. (It will be glued into the dispatching function as is and sedded into what is needed for the dispatched function.)

d-omit

Instead of providing handling functions for all of the cmd names, the invalid function will be called for omitted command codes.

d-only

You need only provide functions for the names listed by d-only, plus the “invalid” name. All other command values will trigger calls to the invalid handling function. Note that the invalid call can distinguish from a command that could not be found by examining the value of its first (id) argument.

The handler functions will have the command enumeration as its first first argument, a pointer to a constant string that will be the character after the parsed command (keyword) name, plus any d-arg arguments that follow that.

As an example, a file ‘samp-chk.def’ containing this:

 
AutoGen Definitions str2enum;
cmd = one, two; invalid-name = oops;
dispatch = { d-nam = 'hdl_%s_cmd'; d-ret = void; };

will produce a header containing:

 
typedef enum {
    SAMP_OOPS_CMD = 0,
    SAMP_CMD_ONE      = 1,
    SAMP_CMD_TWO      = 2,
    SAMP_COUNT_CMD
} samp_chk_enum_t;

extern samp_chk_enum_t
find_samp_chk_cmd(char const * str, size_t len);

typedef void(samp_chk_handler_t)(
    samp_chk_enum_t id, char const * str);

samp_chk_handler_t
        hdl_oops_cmd, hdl_one_cmd,  hdl_two_cmd;

extern void
disp_samp_chk(char * str, size_t len);

extern char const *
samp_chk_name(samp_chk_enum_t id);

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.4.3 Bit Maps and Masks

str2mask.tpl

This template leverages highly off of enumerations (see section Enumerations). It will produce a header file with bit masks defined for each bit specified with a cmd attribute. 63 is the highest legal bit number because this template has not been extended to cope with multiple word masks. (Patches would be welcome.)

There are a few constraints on the names allowed:

no-code and no-name are honored. dispatch is not. The lookup function will examine each token in an input string, determine which bit is specified and add it into a result. The names may be prefixed with a hyphen (-) or tilde (~) to remove the bit(s) from the cumulative result. If the string begins with a plus (+), hyphen or tilde, a “base value” parameter is used for the starting mask, otherwise the conversion starts with zero.

Beyond the enumeration attributes that are used (or ignored), the ‘str2mask’ template accepts a mask attribute. It takes a few “subattributes”:

m-name

a special name for a sub-collection of the mask bits

m-bit

The name of each previously defined bit(s). If the desired previously defined value is a mask, that m-name must be suffixed with “-mask”.

m-invert

When all done collecting the bits, x-or the value with the mask of all the bits in the collection.

A mask of all bits in the collection is always generated.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.5 Invoking columns

This program was designed for the purpose of generating compact, columnized tables. It will read a list of text items from standard in or a specified input file and produce a columnized listing of all the non-blank lines. Leading white space on each line is preserved, but trailing white space is stripped. Methods of applying per-entry and per-line embellishments are provided. See the formatting and separation arguments below.

This program is used by AutoGen to help clean up and organize its output.

See ‘autogen/agen5/fsm.tpl’ and the generated output ‘pseudo-fsm.h’.

This function was not implemented as an expression function because either it would have to be many expression functions, or a provision would have to be added to provide options to expression functions. Maybe not a bad idea, but it is not being implemented at the moment.

A side benefit is that you can use it outside of autogen to columnize input, a la the ls command.

This section was generated by AutoGen, using the agtexi-cmd template and the option descriptions for the columns program. This software is released under the GNU General Public License, version 3 or later.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.5.1 columns help/usage (‘--help’)

This is the automatically generated usage text for columns.

The text printed is the same whether selected with the help option (‘--help’) or the more-help option (‘--more-help’). more-help will print the usage text by passing it through a pager program. more-help is disabled on platforms without a working fork(2) function. The PAGER environment variable is used to select the program, defaulting to ‘more’. Both will exit with a status code of 0.

 
columns (GNU AutoGen) - Columnize Input Text - Ver. 1.2
Usage:  columns [ -<flag> [<val>] | --<name>[{=| }<val>] ]...

Specify the output dimensions:

  Flg Arg Option-Name    Description
   -W Num width          Maximum Line Width
                                - it must be in the range:
                                  16 to 4095
   -c Num columns        Desired number of columns
                                - it must be in the range:
                                  1 to 2048
   -w Num col-width      Set width of each column
                                - it must be in the range:
                                  1 to 2048
      Num tab-width      tab width

Specify how to lay out the text:

  Flg Arg Option-Name    Description
      Num spread         maximum spread added to column width
                                - it must be in the range:
                                  1 to 1024
      no  fill           Fill lines with input
                                - prohibits these options:
                                spread
                                col-width
                                by-columns
   -I Str indent         Line prefix or indentation
      Str first-indent   First line prefix
                                - requires the option 'indent'
   -f Str format         Formatting string for each input
   -S Str separation     Separation string - follows all but last
      Str line-separation string at end of all lines but last
      Str ending         string at end of last line

Specify the ordering of the entries:

  Flg Arg Option-Name    Description
      no  by-columns     Print entries in column order
   -s opt sort           Sort input text

Redirecting stdin to an alternate file:

  Flg Arg Option-Name    Description
   -i Str input          Input file (if not stdin)

Version, usage and configuration options:

  Flg Arg Option-Name    Description
   -v opt version        output version information and exit
   -? no  help           display extended usage information and exit
   -! no  more-help      extended usage information passed thru pager
   -> opt save-opts      save the option state to a config file
   -< Str load-opts      load options from a config file
                                - disabled as '--no-load-opts'
                                - may appear multiple times

Options are specified by doubled hyphens and their name or by a single
hyphen and the flag character.

The following option preset mechanisms are supported:
 - reading file ./.columnsrc
 - reading file $HOME/.columnsrc
 - examining environment variables named COLUMNS_*
Packaged by Bruce (2014-08-30)
Report columns bugs to bkorb@gnu.org

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.5.2 dimensions options

Specify the output dimensions.

width option (-W).

This is the “maximum line width” option. This option takes a number argument ‘num’. This option specifies the full width of the output line, including any start-of-line indentation. The output will fill each line as completely as possible, unless the column width has been explicitly specified. If the maximum width is less than the length of the widest input, you will get a single column of output.

columns option (-c).

This is the “desired number of columns” option. This option takes a number argument ‘count’. Use this option to specify exactly how many columns to produce. If that many columns will not fit within line_width, then the count will be reduced to the number that fit.

col-width option (-w).

This is the “set width of each column” option. This option takes a number argument ‘num’. Use this option to specify exactly how many characters are to be allocated for each column. If it is narrower than the widest entry, it will be over-ridden with the required width.

tab-width option.

This is the “tab width” option. This option takes a number argument ‘num’. If an indentation string contains tabs, then this value is used to compute the ending column of the prefix string.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.5.3 treatment options

Specify how to lay out the text.

spread option.

This is the “maximum spread added to column width” option. This option takes a number argument ‘num’. Use this option to specify exactly how many characters may be added to each column. It allows you to prevent columns from becoming too far apart. Without this option, ‘columns’ will attempt to widen columns to fill the full width.

fill option.

This is the “fill lines with input” option.

This option has some usage constraints. It:

Instead of columnizing the input text, fill the output lines with the input lines. Blank lines on input will cause a blank line in the output, unless the output is sorted. With sorted output, blank lines are ignored.

indent option (-I).

This is the “line prefix or indentation” option. This option takes a string argument ‘l-pfx’. If a number, then this many spaces will be inserted at the start of every line. Otherwise, it is a line prefix that will be inserted at the start of every line.

first-indent option.

This is the “first line prefix” option. This option takes a string argument ‘l-pfx’.

This option has some usage constraints. It:

If a number, then this many spaces will be inserted at the start of the first line. Otherwise, it is a line prefix that will be inserted at the start of that line. If its length exceeds "indent", then it will be emitted on a line by itself, suffixed by any line separation string. For example:

 
$ columns --first='#define TABLE' -c 2 -I4 --line=' \' <<_EOF_
one
two
three
four
_EOF_
#define TABLE \
    one   two \
    three four

format option (-f).

This is the “formatting string for each input” option. This option takes a string argument ‘fmt-str’. If you need to reformat each input text, the argument to this option is interpreted as an sprintf(3) format that is used to produce each output entry.

separation option (-S).

This is the “separation string - follows all but last” option. This option takes a string argument ‘sep-str’. Use this option if, for example, you wish a comma to appear after each entry except the last.

line-separation option.

This is the “string at end of all lines but last” option. This option takes a string argument ‘sep-str’. Use this option if, for example, you wish a backslash to appear at the end of every line, except the last.

ending option.

This is the “string at end of last line” option. This option takes a string argument ‘end-str’. This option puts the specified string at the end of the output.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.5.4 ordering options

Specify the ordering of the entries.

by-columns option.

This is the “print entries in column order” option. Normally, the entries are printed out in order by rows and then columns. This option will cause the entries to be ordered within columns. The final column, instead of the final row, may be shorter than the others.

sort option (-s).

This is the “sort input text” option. This option takes an optional string argument ‘key-pat’. Causes the input text to be sorted. If an argument is supplied, it is presumed to be a pattern and the sort is based upon the matched text. If the pattern starts with or consists of an asterisk (*), then the sort is case insensitive.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.5.5 input-text options

Redirecting stdin to an alternate file.

input option (-i).

This is the “input file (if not stdin)” option. This option takes a string argument ‘file’. This program normally runs as a filter, reading from standard input, columnizing and writing to standard out. This option redirects input to a file.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.5.6 presetting/configuring columns

Any option that is not marked as not presettable may be preset by loading values from configuration ("rc" or "ini") files, and values from environment variables named COLUMNS and COLUMNS_<OPTION_NAME>. <OPTION_NAME> must be one of the options listed above in upper case and segmented with underscores. The COLUMNS variable will be tokenized and parsed like the command line. The remaining variables are tested for existence and their values are treated like option arguments.

libopts will search in 2 places for configuration files:

The environment variables PWD, and HOME are expanded and replaced when ‘columns’ runs. For any of these that are plain files, they are simply processed. For any that are directories, then a file named ‘.columnsrc’ is searched for within that directory and processed.

Configuration files may be in a wide variety of formats. The basic format is an option name followed by a value (argument) on the same line. Values may be separated from the option name with a colon, equal sign or simply white space. Values may be continued across multiple lines by escaping the newline with a backslash.

Multiple programs may also share the same initialization file. Common options are collected at the top, followed by program specific segments. The segments are separated by lines like:

 
[COLUMNS]

or by

 
<?program columns>

Do not mix these styles within one configuration file.

Compound values and carefully constructed string values may also be specified using XML syntax:

 
<option-name>
   <sub-opt>...&lt;...&gt;...</sub-opt>
</option-name>

yielding an option-name.sub-opt string value of

 
"...<...>..."

AutoOpts does not track suboptions. You simply note that it is a hierarchicly valued option. AutoOpts does provide a means for searching the associated name/value pair list (see: optionFindValue).

The command line options relating to configuration and/or usage help are:

version (-v)

Print the program version to standard out, optionally with licensing information, then exit 0. The optional argument specifies how much licensing detail to provide. The default is to print just the version. The licensing infomation may be selected with an option argument. Only the first letter of the argument is examined:

version

Only print the version. This is the default.

copyright

Name the copyright usage licensing terms.

verbose

Print the full copyright usage licensing terms.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.5.7 columns exit status

One of the following exit values will be returned:

0 (EXIT_SUCCESS)

Successful program execution.

1 (EXIT_FAILURE)

The operation failed or the command syntax was not valid.

66 (EX_NOINPUT)

A specified configuration file could not be loaded.

70 (EX_SOFTWARE)

libopts had an internal operational error. Please report it to autogen-users@lists.sourceforge.net. Thank you.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.5.8 columns See Also

This program is documented more fully in the Columns section of the Add-On chapter in the AutoGen Info system documentation.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.6 Invoking getdefs

If no input argument is provided or is set to simply "-", and if stdin is not a tty, then the list of input files will be read from stdin. This program extracts AutoGen definitions from a list of source files. Definitions are delimited by /*=<entry-type> <entry-name>\n and =*/\n. From that, this program creates a definition of the following form:

 
    #line nnn "source-file-name"
    entry_type = {
        name = entry_name;
        ...
    };
  1. The ellipsis ... is filled in by text found between the two delimiters. Each line of text is stripped of anything before the first asterisk, then leading asterisks, then any leading or trailing white space.
  2. If what is left starts with what looks like a name followed by a colon, then it is interpreted as a name followed by a value.
  3. If the first character of the value is either a single or double quote, then you are responsible for quoting the text as it gets inserted into the output definitions. So, if you want whitespace at the beginnings of the lines of text, you must do something like this:
     
     * mumble:
     * "  this is some\n"
     * "  indented text."
    
  4. If the <entry-name> is followed by a comma, the word ifdef (or ifndef) and a name if_name, then the above entry will be under ifdef control.
     
    /*=group entry_name, ifdef FOO
     * attr: attribute value
    =*/
    

    Will produce the following:

     
    #ifdef FOO
    #line nnn "source-file-name"
    group = {
        name = entry_name;
        attr = 'attribute value';
    };
    #endif
    
  5. If you use of the subblock option, you can specify a nested value, See getdefs subblock. That is, this text:
     
     * arg:  int, this, what-it-is
    

    with the --subblock=arg=type,name,doc option would yield:

     
    arg = { type = int; name = this; doc = what-it-is; };
    

This section was generated by AutoGen, using the agtexi-cmd template and the option descriptions for the getdefs program. This software is released under the GNU General Public License, version 3 or later.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.6.1 getdefs help/usage (‘help’)

This is the automatically generated usage text for getdefs.

The text printed is the same whether selected with the help option (‘help’) or the more-help option (‘more-help’). more-help will print the usage text by passing it through a pager program. more-help is disabled on platforms without a working fork(2) function. The PAGER environment variable is used to select the program, defaulting to ‘more’. Both will exit with a status code of 0.

 
getdefs (GNU AutoGen) - AutoGen Definition Extraction Tool - Ver. 1.5
Usage:  getdefs [ <option-name>[{=| }<val>] ]...

Specify which definitions are of interest and what to say about them:

   Arg Option-Name    Description
   Str defs-to-get    Regexp to look for after the "/*="
   Str subblock       subblock definition names
                                - may appear multiple times
   Str listattr       attribute with list of values
                                - may appear multiple times

specify how to number the definitions:

   Arg Option-Name    Description
   opt ordering       Alphabetize or use named file
                                - disabled as '--no-ordering'
                                - enabled by default
   Num first-index    The first index to apply to groups

Definition insertion options:

   Arg Option-Name    Description
   opt filelist       Insert source file names into defs
   Str assign         Global assignments
                                - may appear multiple times
   Str common-assign  Assignments common to all blocks
                                - may appear multiple times
   Str copy           File(s) to copy into definitions
                                - may appear multiple times
   opt srcfile        Insert source file name into each def
   opt linenum        Insert source line number into each def

specify which files to search for markers:

   Arg Option-Name    Description
   Str input          Input file to search for defs
                                - may appear multiple times
                                - default option for unnamed options

Definition output disposition options::

   Arg Option-Name    Description
   Str output         Output file to open
                                - an alternate for 'autogen'
   opt autogen        Invoke AutoGen with defs
                                - disabled as '--no-autogen'
                                - enabled by default
   Str template       Template Name
   Str agarg          AutoGen Argument
                                - prohibits the option 'output'
                                - may appear multiple times
   Str base-name      Base name for output file(s)
                                - prohibits the option 'output'

Version, usage and configuration options:

   Arg Option-Name    Description
   opt version        output version information and exit
   no  help           display extended usage information and exit
   no  more-help      extended usage information passed thru pager
   opt save-opts      save the option state to a config file
   Str load-opts      load options from a config file
                                - disabled as '--no-load-opts'
                                - may appear multiple times

All arguments are named options.
If no 'input' argument is provided or is set to simply "-", and if 'stdin'
is not a 'tty', then the list of input files will be read from 'stdin'.

The following option preset mechanisms are supported:
 - reading file /dev/null
This program extracts AutoGen definitions from a list of source files.
Definitions are delimited by '/*=<entry-type> <entry-name>\n' and '=*/\n'.
Packaged by Bruce (2014-08-30)
Report getdefs bugs to bkorb@gnu.org

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.6.2 def-selection options

Specify which definitions are of interest and what to say about them.

defs-to-get option.

This is the “regexp to look for after the "/*="” option. This option takes a string argument ‘reg-ex’. If you want definitions only from a particular category, or even with names matching particular patterns, then specify this regular expression for the text that must follow the /*=.

subblock option.

This is the “subblock definition names” option. This option takes a string argument ‘sub-def’.

This option has some usage constraints. It:

This option is used to create shorthand entries for nested definitions. For example, with:

using subblock thus

--subblock=arg=argname,type,null

and defining an arg thus

arg: this, char *

will then expand to:

arg = { argname = this; type = "char *"; };

The "this, char *" string is separated at the commas, with the white space removed. You may use characters other than commas by starting the value string with a punctuation character other than a single or double quote character. You may also omit intermediate values by placing the commas next to each other with no intervening white space. For example, "+mumble++yes+" will expand to:
arg = { argname = mumble; null = "yes"; };.

listattr option.

This is the “attribute with list of values” option. This option takes a string argument ‘def’.

This option has some usage constraints. It:

This option is used to create shorthand entries for definitions that generally appear several times. That is, they tend to be a list of values. For example, with:
listattr=foo defined, the text:
foo: this, is, a, multi-list will then expand to:
foo = 'this', 'is', 'a', 'multi-list';
The texts are separated by the commas, with the white space removed. You may use characters other than commas by starting the value string with a punctuation character other than a single or double quote character.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.6.3 enumerating options

specify how to number the definitions.

ordering option.

This is the “alphabetize or use named file” option. This option takes an optional string argument ‘file-name’.

This option has some usage constraints. It:

By default, ordering is alphabetical by the entry name. Use, no-ordering if order is unimportant. Use ordering with no argument to order without case sensitivity. Use ordering=<file-name> if chronological order is important. getdefs will maintain the text content of file-name. file-name need not exist.

first-index option.

This is the “the first index to apply to groups” option. This option takes a number argument ‘first-index’. By default, the first occurrence of a named definition will have an index of zero. Sometimes, that needs to be a reserved value. Provide this option to specify a different starting point.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.6.4 doc-insert options

Definition insertion options.

filelist option.

This is the “insert source file names into defs” option. This option takes an optional string argument ‘file’. Inserts the name of each input file into the output definitions. If no argument is supplied, the format will be:

 
infile = '%s';

If an argument is supplied, that string will be used for the entry name instead of infile.

assign option.

This is the “global assignments” option. This option takes a string argument ‘ag-def’.

This option has some usage constraints. It:

The argument to each copy of this option will be inserted into the output definitions, with only a semicolon attached.

common-assign option.

This is the “assignments common to all blocks” option. This option takes a string argument ‘ag-def’.

This option has some usage constraints. It:

The argument to each copy of this option will be inserted into each output definition, with only a semicolon attached.

copy option.

This is the “file(s) to copy into definitions” option. This option takes a string argument ‘file’.

This option has some usage constraints. It:

The content of each file named by these options will be inserted into the output definitions.

srcfile option.

This is the “insert source file name into each def” option. This option takes an optional string argument ‘file’. Inserts the name of the input file where a definition was found into the output definition. If no argument is supplied, the format will be:

 
srcfile = '%s';

If an argument is supplied, that string will be used for the entry name instead of srcfile.

linenum option.

This is the “insert source line number into each def” option. This option takes an optional string argument ‘def-name’. Inserts the line number in the input file where a definition was found into the output definition. If no argument is supplied, the format will be:

 
linenum = '%s';

If an argument is supplied, that string will be used for the entry name instead of linenum.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.6.5 input-files options

specify which files to search for markers.

input option.

This is the “input file to search for defs” option. This option takes a string argument ‘src-file’.

This option has some usage constraints. It:

All files that are to be searched for definitions must be named on the command line or read from stdin. If there is only one input option and it is the string, "-", then the input file list is read from stdin. If a command line argument is not an option name and does not contain an assignment operator (=), then it defaults to being an input file name. At least one input file must be specified.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.6.6 doc-output options

Definition output disposition options:.

output option.

This is the “output file to open” option. This option takes a string argument ‘file’.

This option has some usage constraints. It:

If you are not sending the output to an AutoGen process, you may name an output file instead.

autogen option.

This is the “invoke autogen with defs” option. This option takes an optional string argument ‘ag-cmd’.

This option has some usage constraints. It:

This is the default output mode. Specifying no-autogen is equivalent to output=-. If you supply an argument to this option, that program will be started as if it were AutoGen and its standard in will be set to the output definitions of this program.

template option.

This is the “template name” option. This option takes a string argument ‘file’. Specifies the template name to be used for generating the final output.

agarg option.

This is the “autogen argument” option. This option takes a string argument ‘ag-opt’.

This option has some usage constraints. It:

This is a pass-through argument. It allows you to specify any arbitrary argument to be passed to AutoGen.

base-name option.

This is the “base name for output file(s)” option. This option takes a string argument ‘name’.

This option has some usage constraints. It:

When output is going to AutoGen, a base name must either be supplied or derived. If this option is not supplied, then it is taken from the template option. If that is not provided either, then it is set to the base name of the current directory.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.6.7 presetting/configuring getdefs

Any option that is not marked as not presettable may be preset by loading values from configuration ("rc" or "ini") files.

libopts will search in ‘/dev/null’ for configuration (option) data. If this is a plain file, it is simply processed. If it is a directory, then a file named ‘.getdefsrc’ is searched for within that directory.

Configuration files may be in a wide variety of formats. The basic format is an option name followed by a value (argument) on the same line. Values may be separated from the option name with a colon, equal sign or simply white space. Values may be continued across multiple lines by escaping the newline with a backslash.

Multiple programs may also share the same initialization file. Common options are collected at the top, followed by program specific segments. The segments are separated by lines like:

 
[GETDEFS]

or by

 
<?program getdefs>

Do not mix these styles within one configuration file.

Compound values and carefully constructed string values may also be specified using XML syntax:

 
<option-name>
   <sub-opt>...&lt;...&gt;...</sub-opt>
</option-name>

yielding an option-name.sub-opt string value of

 
"...<...>..."

AutoOpts does not track suboptions. You simply note that it is a hierarchicly valued option. AutoOpts does provide a means for searching the associated name/value pair list (see: optionFindValue).

The command line options relating to configuration and/or usage help are:

version

Print the program version to standard out, optionally with licensing information, then exit 0. The optional argument specifies how much licensing detail to provide. The default is to print just the version. The licensing infomation may be selected with an option argument. Only the first letter of the argument is examined:

version

Only print the version. This is the default.

copyright

Name the copyright usage licensing terms.

verbose

Print the full copyright usage licensing terms.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.6.8 getdefs exit status

One of the following exit values will be returned:

0 (EXIT_SUCCESS)

Successful program execution.

1 (EXIT_FAILURE)

The operation failed or the command syntax was not valid.

66 (EX_NOINPUT)

A specified configuration file could not be loaded.

70 (EX_SOFTWARE)

libopts had an internal operational error. Please report it to autogen-users@lists.sourceforge.net. Thank you.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.6.9 getdefs See Also

This program is documented more fully in the Getdefs section of the Add-On chapter in the AutoGen Info system documentation.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.7 Invoking xml2ag

This program will convert any arbitrary XML file into equivalent AutoGen definitions, and invoke AutoGen. The template used will be derived from either:

One or the other must be provided, or the program will exit with a failure message.

The base-name for the output will similarly be either:

The definitions derived from XML generally have an extra layer of definition. Specifically, this XML input:

 
<mumble attr="foo">
  mumble-1
  <grumble>
  grumble, grumble, grumble.
</grumble>mumble, mumble
</mumble>

Will get converted into this:

 
mumble = {
  grumble = {
    text = 'grumble, grumble, grumble';
  };
  text = 'mumble-1';
  text = 'mumble, mumble';
};

Please notice that some information is lost. AutoGen cannot tell that "grumble" used to lie between the mumble texts. Also please note that you cannot assign:

 
grumble = 'grumble, grumble, grumble.';

because if another "grumble" has an attribute or multiple texts, it becomes impossible to have the definitions be the same type (compound or text values).

This section was generated by AutoGen, using the agtexi-cmd template and the option descriptions for the xml2ag program. This software is released under the GNU General Public License, version 3 or later.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.7.1 xml2ag help/usage (‘--help’)

This is the automatically generated usage text for xml2ag.

The text printed is the same whether selected with the help option (‘--help’) or the more-help option (‘--more-help’). more-help will print the usage text by passing it through a pager program. more-help is disabled on platforms without a working fork(2) function. The PAGER environment variable is used to select the program, defaulting to ‘more’. Both will exit with a status code of 0.

 
xml2ag (GNU AutoGen) - XML to AutoGen Definiton Converter - Ver. 5.18.4
Usage:  xml2ag [ -<flag> [<val>] | --<name>[{=| }<val>] ]... [ <def-file> ]

All other options are derived from autogen:

  Flg Arg Option-Name    Description
   -O Str output         Output file in lieu of AutoGen processing

All other options:

  Flg Arg Option-Name    Description
   -L Str templ-dirs     Search for templates in DIR
                                - may appear multiple times
   -T Str override-tpl   Use TPL-FILE for the template
      Str definitions    Read definitions from FILE
      Str shell          name or path name of shell to use
   -m no  no-fmemopen    Do not use in-mem streams
      Str equate         characters considered equivalent
   -b Str base-name      Specify NAME as the base name for output
      no  source-time    set mod times to latest source
      no  writable       Allow output files to be writable
                                - disabled as '--not-writable'
      Num loop-limit     Limit on increment loops
                                - is scalable with a suffix: k/K/m/M/g/G/t/T
                                - it must lie in one of the ranges:
                                  -1 exactly, or
                                  1 to 16777216
   -t Num timeout        Limit server shell operations to SECONDS
                                - it must be in the range:
                                  0 to 3600
      KWd trace          tracing level of detail
      Str trace-out      tracing output file or filter
      no  show-defs      Show the definition tree
      no  used-defines   Show the definitions used
   -C no  core           Leave a core dump on a failure exit
   -s Str skip-suffix    Skip the file with this SUFFIX
                                - prohibits the option 'select-suffix'
                                - may appear multiple times
   -o Str select-suffix  specify this output suffix
                                - may appear multiple times
   -D Str define         name to add to definition list
                                - may appear multiple times
   -U Str undefine       definition list removal pattern
                                - an alternate for 'define'
   -M opt make-dep       emit make dependency file
                                - may appear multiple times

Version, usage and configuration options:

  Flg Arg Option-Name    Description
   -v opt version        output version information and exit
   -? no  help           display extended usage information and exit
   -! no  more-help      extended usage information passed thru pager

Options are specified by doubled hyphens and their name or by a single
hyphen and the flag character.
This program will convert any arbitrary XML file into equivalent AutoGen
definitions, and invoke AutoGen.

The valid "trace" option keywords are:
  nothing       debug-message server-shell  templates     block-macros
  expressions   everything
  or an integer from 0 through 6
The template will be derived from either: * the ``--override-tpl'' command
line option * a top level XML attribute named, "template"

The ``base-name'' for the output will similarly be either: * the
``--base-name'' command line option * the base name of the .xml file
Packaged by Bruce (2014-08-30)
Report xml2ag bugs to bkorb@gnu.org

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.7.2 the-xml2ag-option options

All other options are derived from autogen.

output option (-O).

This is the “output file in lieu of autogen processing” option. This option takes a string argument ‘file’. By default, the output is handed to an AutoGen for processing. However, you may save the definitions to a file instead.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.7.3 autogen-options options

All other options. These options are mostly just passed throug to autogen. The one exception is --override-tpl which replaces the default template in the output definitions. It does not get passed through on the command line.

templ-dirs option (-L).

This is the “search for templates in ‘dir’” option. This option takes a string argument ‘DIR’.

This option has some usage constraints. It:

Pass-through AutoGen argument

override-tpl option (-T).

This is the “use ‘tpl-file’ for the template” option. This option takes a string argument ‘TPL-FILE’. Pass-through AutoGen argument

lib-template option (-l).

This is the “load autogen macros from ‘tpl-file’” option. This option takes a string argument ‘TPL-FILE’.

This option has some usage constraints. It:

Pass-through AutoGen argument

NOTE: THIS OPTION IS DEPRECATED

definitions option.

This is the “read definitions from ‘file’” option. This option takes a string argument ‘FILE’. Pass-through AutoGen argument

shell option.

This is the “name or path name of shell to use” option. This option takes a string argument ‘shell’. Pass-through AutoGen argument

no-fmemopen option (-m).

This is the “do not use in-mem streams” option. Pass-through AutoGen argument

equate option.

This is the “characters considered equivalent” option. This option takes a string argument ‘char-list’. Pass-through AutoGen argument

base-name option (-b).

This is the “specify name as the base name for output” option. This option takes a string argument ‘NAME’. Pass-through AutoGen argument

source-time option.

This is the “set mod times to latest source” option. Pass-through AutoGen argument

writable option.

This is the “allow output files to be writable” option.

This option has some usage constraints. It:

Pass-through AutoGen argument

loop-limit option.

This is the “limit on increment loops” option. This option takes a number argument ‘lim’. Pass-through AutoGen argument

timeout option (-t).

This is the “limit server shell operations to seconds” option. This option takes a number argument ‘SECONDS’. Pass-through AutoGen argument

trace option.

This is the “tracing level of detail” option. This option takes a keyword argument ‘level’.

This option has some usage constraints. It:

Pass-through AutoGen argument

trace-out option.

This is the “tracing output file or filter” option. This option takes a string argument ‘file’. Pass-through AutoGen argument

show-defs option.

This is the “show the definition tree” option. Pass-through AutoGen argument

used-defines option.

This is the “show the definitions used” option. Pass-through AutoGen argument

core option (-C).

This is the “leave a core dump on a failure exit” option.

This option has some usage constraints. It:

Many systems default to a zero sized core limit. If the system has the sys/resource.h header and if this option is supplied, then in the failure exit path, autogen will attempt to set the soft core limit to whatever the hard core limit is. If that does not work, then an administrator must raise the hard core size limit.

skip-suffix option (-s).

This is the “skip the file with this ‘suffix’” option. This option takes a string argument ‘SUFFIX’.

This option has some usage constraints. It:

Pass-through AutoGen argument

select-suffix option (-o).

This is the “specify this output suffix” option. This option takes a string argument ‘SUFFIX’.

This option has some usage constraints. It:

Pass-through AutoGen argument

define option (-D).

This is the “name to add to definition list” option. This option takes a string argument ‘value’.

This option has some usage constraints. It:

Pass-through AutoGen argument

undefine option (-U).

This is the “definition list removal pattern” option. This option takes a string argument ‘name-pat’.

This option has some usage constraints. It:

Pass-through AutoGen argument

make-dep option (-M).

This is the “emit make dependency file” option. This option takes an optional string argument ‘type’.

This option has some usage constraints. It:

Pass-through AutoGen argument


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.7.4 xml2ag exit status

One of the following exit values will be returned:

0 (EXIT_SUCCESS)

Successful program execution.

1 (EXIT_FAILURE)

The operation failed or the command syntax was not valid.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.8 Replacement for Stdio Formatting Library

Using the ‘printf’ formatting routines in a portable fashion has always been a pain, and this package has been way more pain than anyone ever imagined. Hopefully, with this release of snprintfv, the pain is now over for all time.

The issues with portable usage are these:

  1. Argument number specifiers are often either not implemented or are buggy. Even GNU libc, version 1 got it wrong.
  2. ANSI/ISO "forgot" to provide a mechanism for computing argument lists for vararg procedures.
  3. The argument array version of printf (‘printfv()’) is not generally available, does not work with the native printf, and does not have a working argument number specifier in the format specification. (Last I knew, anyway.)
  4. You cannot fake varargs by calling ‘vprintf()’ with an array of arguments, because ANSI does not require such an implementation and some vendors play funny tricks because they are allowed to.

These four issues made it impossible for AutoGen to ship without its own implementation of the ‘printf’ formatting routines. Since we were forced to do this, we decided to make the formatting routines both better and more complete :-). We addressed these issues and added the following features to the common printf API:

  1. The formatted output can be written to
  2. The formatting functions can be augmented with your own functions. These functions are allowed to consume more than one character from the format, but must commence with a unique character. For example,
     
    "%{struct stat}\n"
    

    might be used with ’{’ registered to a procedure that would look up "struct stat" in a symbol table and do appropriate things, consuming the format string through the ’}’ character.

Gary V. Vaughan was generous enough to supply this implementation. Many thanks!!

For further details, the reader is referred to the snprintfv documentation. These functions are also available in the template processing as ‘sprintf’ (see section sprintf’ - format a string), ‘printf’ (see section printf’ - format to stdout), ‘fprintf’ (see section fprintf’ - format to a file), and ‘shellf’ (see section shellf’ - format a string, run shell).


[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated by Bruce Korb on August 30, 2014 using texi2html 1.82.