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

7.3.2 Generated main Procedures

AutoOpts can generate the main procedure in certain circumstances. It will do this to help with integrating with the guile library environment, and for creating a program to convert command line options into environment variables for use in processing shell script options and for testing the command line interface.

If guile-main has been specified and if this is specified as well, then this code will be inserted into the actual main() procedure before gh_enter() is called.

Creates a guile-style main and inner-main procedures. The inner main procedure will call optionProcess() and will invoke any code specified by this attribute. If this attribute does not specify any code, then calls to the AutoOpts library procedure export_options_to_guile() and then scm_shell() will be inserted into inner_main().

If you need to specify the content of the main procedure generated for the "option testing" program, you can do that with this attribute. The result will be a procedure that looks like this:

int main( int argc, char** argv ) {
[+  main-text  +]
    return EXIT_SUCCESS;

Creates a test main procedure for testing option processing. The resulting program may also be used for several purposes.

  1. If the text of test-main is short (3 or fewer characters), the generated main() will call putBourneShell. That routine will emit Bourne shell commands that can be eval-ed by a Bourne-derived shell to incorporate the digested options into the shell's environment, See section 7.7 AutoOpts for Shell Scripts. You would use it thus:
    eval "`./programopts $@`"
    test -z "${OPTION_CT}" ] && exit 1
    test ${OPTION_CT} -gt 0 && shift ${OPTION_CT}

  2. If the text of test-main contains putShellParse, the program will generate portable Bourne shell commands that will parse the command line options. The expectation is that this result will be copied into a shell script and used there, See section 7.7 AutoOpts for Shell Scripts.

  3. Any other text must be the name of a routine that you will write yourself. That routine will be called after processing the command line options and it will be passed the option processing descriptor pointer as its sole argument.

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

This document was generated by Bruce Korb on May 5, 2003 using texi2html

Viewable With Any Browser   AutoGen Home