AutoGen - The Automated Program Generator: 7.8.1 local-only use

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

### 7.8.1 local-only use

To use AutoOpts in your application where you do not have to worry about distribution issues, your issues are simple and few.

- Create a file ``myopts.def'`, according to the documentation above. It is probably easiest to start with the example in Quick Start and edit it into the form you need.
- Run AutoGen to create the option interface file (`myopts.h`) and the option descriptor code (`myopts.c`):

      autogen myopts.def

- In all your source files where you need to refer to option state, `#include "myopts.h"`.
- In your main routine, code something along the lines of:

      #define ARGC_MIN some-lower-limit
      #define ARGC_MAX some-upper-limit
      main( int argc, char** argv )
      {
          {
              int arg_ct = optionProcess( &myprogOptions, argc, argv );
              argc -= arg_ct;
              if ((argc < ARGC_MIN) || (argc > ARGC_MAX)) {
                  fprintf( stderr, "%s ERROR:  remaining args (%d) "
                           "out of range\n", myprogOptions.pzProgName,
                           argc );

                  USAGE( EXIT_FAILURE );
              }
              argv += arg_ct;
          }
          if (HAVE_OPT(OPTN_NAME))
              respond_to_optn_name();
          ...
      }

- Compile ``myopts.c'` and link your program with the following additional arguments:

      myopts.c -I$prefix/include -L $prefix/lib -lopts

  These values can be derived from the "autoopts-config" script:

      myopts.c `autoopts-config cflags` `autoopts-config ldflags`

This document was generated by Bruce Korb on April, 9 2006 using texi2html 1.76.