@c Generator: GNU source-highlight, by Lorenzo Bettini, http://www.gnu.org/software/src-highlite
@smallexample
@r{@i{/*}}@r{@i{ test_conf_parser.c test }}@r{@i{*/}}

@r{@i{/*}}@r{@i{ test all kinds of options and the conf file parser }}@r{@i{*/}}

@b{#include} @t{<stdlib.h>}
@b{#include} @t{<stdio.h>}

@b{#include} @t{"test_conf_parser_cmd.h"}

@b{static} @b{struct} my_args_info args_info;

@b{int}
main (@b{int} argc, @b{char} **argv)
@{  
  @b{int} i;
  @b{int} result = 0;

  @b{if} (test_conf_parser_cmd_parser (argc, argv, &args_info) != 0) @{
    result = 1;
    @b{goto} stop;
  @}

  @r{@i{/*}}@r{@i{ override cmd options, but do not initialize args_info, check for required options }}@r{@i{*/}}
  @b{if} (test_conf_parser_cmd_parser_configfile
      (args_info.conf_file_arg, &args_info, 1, 0, 1) != 0) 
    @{
      result = 1;
      @b{goto} stop;
    @}

  printf (@t{"value of required: %s\n"}, args_info.required_arg);
  printf (@t{"value of string: %s\n"}, args_info.string_arg);
  printf (@t{"value of no-short_given: %d\n"}, args_info.no_short_given);
  printf (@t{"value of int: %d\n"}, args_info.int_arg);
  printf (@t{"value of float: %f\n"}, args_info.float_arg);

  printf (@t{"value of multi-string_given: %d\n"}, args_info.multi_string_given);
  @b{for} (i = 0; i < args_info.multi_string_given; ++i)
    printf (@t{"  value of multi-string: %s\n"}, args_info.multi_string_arg [i]);

  printf (@t{"value of multi-string-def_given: %d\n"},
          args_info.multi_string_def_given);
  @b{for} (i = 0; i < args_info.multi_string_def_given; ++i)
    printf (@t{"  value of multi-string-def: %s\n"},
            args_info.multi_string_def_arg [i]);
  @b{if} (!args_info.multi_string_def_given && args_info.multi_string_def_arg [0])
    printf (@t{"default value of multi-string-def: %s\n"},
            args_info.multi_string_def_arg [0]);

  printf (@t{"value of opta: %s\n"}, args_info.opta_arg);

  printf (@t{"noarg given %d times\n"}, args_info.noarg_given);
  printf (@t{"noarg_noshort given %d times\n"}, args_info.noarg_noshort_given);

  printf (@t{"opt-arg given: %d\n"}, args_info.opt_arg_given);
  printf (@t{"opt-arg value: %s\n"}, (args_info.opt_arg_arg ? args_info.opt_arg_arg : @t{"not given"}));

  @b{if} (args_info.file_save_given) @{
    @b{if} (test_conf_parser_cmd_parser_file_save (args_info.file_save_arg, &args_info) == EXIT_FAILURE)
      result = 1;
    @b{else}
      printf (@t{"saved configuration file %s\n"}, args_info.file_save_arg);
  @}

 stop:
  test_conf_parser_cmd_parser_free (&args_info);

  @b{return} result;
@}

@end smallexample