--- trunk/SHAPES/visualizerCmd.c 2004/06/24 19:06:47 1300 +++ trunk/SHAPES/visualizerCmd.c 2004/07/20 20:22:43 1361 @@ -1,7 +1,7 @@ /* File autogenerated by gengetopt version 2.12.1 generated with the following command: - gengetopt --file-name=visualizerCmd + gengetopt --file-name=visualizerCmd --unamed-opts=SHAPEFILE [OUTPUTFILE] The developers of gengetopt consider the fixed text that goes in all gengetopt output files to be in the public domain: @@ -37,17 +37,15 @@ void clear_given (struct gengetopt_args_info *args_inf { args_info->help_given = 0 ; args_info->version_given = 0 ; - args_info->shape_given = 0 ; - args_info->output_given = 0 ; args_info->grid_given = 0 ; + args_info->range_given = 0 ; } static void clear_args (struct gengetopt_args_info *args_info) { - args_info->shape_arg = NULL; - args_info->output_arg = NULL; args_info->grid_arg = 101 ; + args_info->range_arg = 10 ; } void @@ -61,13 +59,12 @@ cmdline_parser_print_help (void) { cmdline_parser_print_version (); printf("\n" - "Usage: %s [OPTIONS]...\n", CMDLINE_PARSER_PACKAGE); + "Usage: %s [OPTIONS]... [SHAPEFILE [OUTPUTFILE]]...\n", CMDLINE_PARSER_PACKAGE); printf("\n"); - printf("%s\n"," -h, --help Print help and exit"); - printf("%s\n"," -V, --version Print version and exit"); - printf("%s\n"," -s, --shape=filename shape file name"); - printf("%s\n"," -o, --output=filename output file name"); - printf("%s\n"," -g, --grid=INT number of grid points in each coordinate (default=\n `101')"); + printf("%s\n"," -h, --help Print help and exit"); + printf("%s\n"," -V, --version Print version and exit"); + printf("%s\n"," -g, --grid=INT number of grid points in each coordinate (default=\n `101')"); + printf("%s\n"," -r, --range=DOUBLE the sample range for the points in Angstroms (Ex: 10 = \n -10 to 10) (default=`10')"); } void @@ -75,23 +72,23 @@ cmdline_parser_init (struct gengetopt_args_info *args_ { clear_given (args_info); clear_args (args_info); + + args_info->inputs = NULL; + args_info->inputs_num = 0; } void cmdline_parser_free (struct gengetopt_args_info *args_info) { - if (args_info->shape_arg) - { - free (args_info->shape_arg); /* free previous argument */ - args_info->shape_arg = 0; - } - if (args_info->output_arg) - { - free (args_info->output_arg); /* free previous argument */ - args_info->output_arg = 0; - } + int i; + for (i = 0; i < args_info->inputs_num; ++i) + free (args_info->inputs [i]); + + if (args_info->inputs_num) + free (args_info->inputs); + clear_given (args_info); } @@ -159,14 +156,13 @@ cmdline_parser_internal (int argc, char * const *argv, static struct option long_options[] = { { "help", 0, NULL, 'h' }, { "version", 0, NULL, 'V' }, - { "shape", 1, NULL, 's' }, - { "output", 1, NULL, 'o' }, { "grid", 1, NULL, 'g' }, + { "range", 1, NULL, 'r' }, { NULL, 0, NULL, 0 } }; stop_char = 0; - c = getopt_long (argc, argv, "hVs:o:g:", long_options, &option_index); + c = getopt_long (argc, argv, "hVg:r:", long_options, &option_index); if (c == -1) break; /* Exit from `while (1)' loop. */ @@ -180,36 +176,6 @@ cmdline_parser_internal (int argc, char * const *argv, cmdline_parser_print_version (); exit (EXIT_SUCCESS); - case 's': /* shape file name. */ - if (local_args_info.shape_given) - { - fprintf (stderr, "%s: `--shape' (`-s') option given more than once%s\n", CMDLINE_PARSER_PACKAGE, (additional_error ? additional_error : "")); - goto failure; - } - if (args_info->shape_given && ! override) - continue; - local_args_info.shape_given = 1; - args_info->shape_given = 1; - if (args_info->shape_arg) - free (args_info->shape_arg); /* free previous string */ - args_info->shape_arg = gengetopt_strdup (optarg); - break; - - case 'o': /* output file name. */ - if (local_args_info.output_given) - { - fprintf (stderr, "%s: `--output' (`-o') option given more than once%s\n", CMDLINE_PARSER_PACKAGE, (additional_error ? additional_error : "")); - goto failure; - } - if (args_info->output_given && ! override) - continue; - local_args_info.output_given = 1; - args_info->output_given = 1; - if (args_info->output_arg) - free (args_info->output_arg); /* free previous string */ - args_info->output_arg = gengetopt_strdup (optarg); - break; - case 'g': /* number of grid points in each coordinate. */ if (local_args_info.grid_given) { @@ -223,7 +189,20 @@ cmdline_parser_internal (int argc, char * const *argv, args_info->grid_arg = strtol (optarg,&stop_char,0); break; + case 'r': /* the sample range for the points in Angstroms (Ex: 10 = -10 to 10). */ + if (local_args_info.range_given) + { + fprintf (stderr, "%s: `--range' (`-r') option given more than once%s\n", CMDLINE_PARSER_PACKAGE, (additional_error ? additional_error : "")); + goto failure; + } + if (args_info->range_given && ! override) + continue; + local_args_info.range_given = 1; + args_info->range_given = 1; + args_info->range_arg = strtod (optarg, NULL); + break; + case 0: /* Long option with no short option */ case '?': /* Invalid option. */ @@ -240,21 +219,22 @@ cmdline_parser_internal (int argc, char * const *argv, if (check_required) { - if (! args_info->shape_given) - { - fprintf (stderr, "%s: '--shape' ('-s') option required%s\n", CMDLINE_PARSER_PACKAGE, (additional_error ? additional_error : "")); - error = 1; - } - if (! args_info->output_given) - { - fprintf (stderr, "%s: '--output' ('-o') option required%s\n", CMDLINE_PARSER_PACKAGE, (additional_error ? additional_error : "")); - error = 1; - } } if ( error ) return (EXIT_FAILURE); + if (optind < argc) + { + int i = 0 ; + + args_info->inputs_num = argc - optind ; + args_info->inputs = + (char **)(malloc ((args_info->inputs_num)*sizeof(char *))) ; + while (optind < argc) + args_info->inputs[ i++ ] = gengetopt_strdup (argv[optind++]) ; + } + return 0; failure: