--- trunk/OOPSE-1.0/utils/sysbuilder/simpleBuilderCmd.c 2004/07/28 04:59:35 1424 +++ trunk/OOPSE-1.0/utils/sysbuilder/simpleBuilderCmd.c 2004/07/29 03:31:50 1432 @@ -37,17 +37,13 @@ cmdline_parser_print_help (void) printf("\n"); printf(" -h, --help Print help and exit\n"); printf(" -V, --version Print version and exit\n"); - printf(" -I, --include=STRING File name that should be included at the top of \n the output bass file.\n"); printf(" -o, --output=STRING Output file name\n"); - printf(" --latticetype=STRING Lattice type string. Valid types are fcc,hcp,bcc \n and hcp-water.\n"); + printf(" --latticetype=STRING Lattice type string. Valid types are fcc,hcp,bcc \n and hcp-water. (default=`fcc')\n"); printf(" --density=DOUBLE density g/cm^3\n"); printf(" --ndensity=DOUBLE number density\n"); printf(" --nx=INT number of unit cells in x\n"); printf(" --ny=INT number of unit cells in y\n"); printf(" --nz=INT number of unit cells in z\n"); - printf(" --a1=DOUBLE lattice spacing in Angstroms h - for cubic \n lattice, specify this parameter\n"); - printf(" --a2=DOUBLE lattice spacing in Angstroms k\n"); - printf(" --a3=DOUBLE lattice spacing in Angstroms l\n"); } @@ -69,19 +65,10 @@ cmdline_parser (int argc, char * const *argv, struct g cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_info) { int c; /* Character of the parsed option. */ - int i; /* Counter */ - struct include_list - { - char * include_arg; - struct include_list * next; - }; - struct include_list * include_list = NULL,* include_new = NULL; - int missing_required_options = 0; args_info->help_given = 0 ; args_info->version_given = 0 ; - args_info->include_given = 0 ; args_info->output_given = 0 ; args_info->latticetype_given = 0 ; args_info->density_given = 0 ; @@ -89,13 +76,9 @@ cmdline_parser (int argc, char * const *argv, struct g args_info->nx_given = 0 ; args_info->ny_given = 0 ; args_info->nz_given = 0 ; - args_info->a1_given = 0 ; - args_info->a2_given = 0 ; - args_info->a3_given = 0 ; #define clear_args() { \ - args_info->include_arg = NULL; \ args_info->output_arg = NULL; \ - args_info->latticetype_arg = NULL; \ + args_info->latticetype_arg = gengetopt_strdup("fcc") ;\ } clear_args(); @@ -116,7 +99,6 @@ cmdline_parser (int argc, char * const *argv, struct g static struct option long_options[] = { { "help", 0, NULL, 'h' }, { "version", 0, NULL, 'V' }, - { "include", 1, NULL, 'I' }, { "output", 1, NULL, 'o' }, { "latticetype", 1, NULL, 0 }, { "density", 1, NULL, 0 }, @@ -124,14 +106,11 @@ cmdline_parser (int argc, char * const *argv, struct g { "nx", 1, NULL, 0 }, { "ny", 1, NULL, 0 }, { "nz", 1, NULL, 0 }, - { "a1", 1, NULL, 0 }, - { "a2", 1, NULL, 0 }, - { "a3", 1, NULL, 0 }, { NULL, 0, NULL, 0 } }; stop_char = 0; - c = getopt_long (argc, argv, "hVI:o:", long_options, &option_index); + c = getopt_long (argc, argv, "hVo:", long_options, &option_index); if (c == -1) break; /* Exit from `while (1)' loop. */ @@ -147,14 +126,6 @@ cmdline_parser (int argc, char * const *argv, struct g cmdline_parser_print_version (); exit (EXIT_SUCCESS); - case 'I': /* File name that should be included at the top of the output bass file.. */ - args_info->include_given++; - include_new = (struct include_list *) malloc (sizeof (struct include_list)); - include_new->next = include_list; - include_list = include_new; - include_new->include_arg = gengetopt_strdup (optarg); - break; - case 'o': /* Output file name. */ if (args_info->output_given) { @@ -178,6 +149,8 @@ cmdline_parser (int argc, char * const *argv, struct g exit (EXIT_FAILURE); } args_info->latticetype_given = 1; + if (args_info->latticetype_arg) + free (args_info->latticetype_arg); /* free default string */ args_info->latticetype_arg = gengetopt_strdup (optarg); break; } @@ -249,51 +222,9 @@ cmdline_parser (int argc, char * const *argv, struct g } args_info->nz_given = 1; args_info->nz_arg = strtol (optarg,&stop_char,0); - break; - } - - /* lattice spacing in Angstroms h - for cubic lattice, specify this parameter. */ - else if (strcmp (long_options[option_index].name, "a1") == 0) - { - if (args_info->a1_given) - { - fprintf (stderr, "%s: `--a1' option given more than once\n", CMDLINE_PARSER_PACKAGE); - clear_args (); - exit (EXIT_FAILURE); - } - args_info->a1_given = 1; - args_info->a1_arg = strtod (optarg, NULL); break; } - /* lattice spacing in Angstroms k. */ - else if (strcmp (long_options[option_index].name, "a2") == 0) - { - if (args_info->a2_given) - { - fprintf (stderr, "%s: `--a2' option given more than once\n", CMDLINE_PARSER_PACKAGE); - clear_args (); - exit (EXIT_FAILURE); - } - args_info->a2_given = 1; - args_info->a2_arg = strtod (optarg, NULL); - break; - } - - /* lattice spacing in Angstroms l. */ - else if (strcmp (long_options[option_index].name, "a3") == 0) - { - if (args_info->a3_given) - { - fprintf (stderr, "%s: `--a3' option given more than once\n", CMDLINE_PARSER_PACKAGE); - clear_args (); - exit (EXIT_FAILURE); - } - args_info->a3_given = 1; - args_info->a3_arg = strtod (optarg, NULL); - break; - } - case '?': /* Invalid option. */ /* `getopt_long' already printed an error message. */ @@ -321,24 +252,9 @@ cmdline_parser (int argc, char * const *argv, struct g fprintf (stderr, "%s: '--nz' option required\n", CMDLINE_PARSER_PACKAGE); missing_required_options = 1; } - if (! args_info->a1_given) - { - fprintf (stderr, "%s: '--a1' option required\n", CMDLINE_PARSER_PACKAGE); - missing_required_options = 1; - } if ( missing_required_options ) exit (EXIT_FAILURE); - if (args_info->include_given) - { - args_info->include_arg = (char * *) malloc (args_info->include_given * sizeof (char *)); - for (i = 0; i < args_info->include_given; i++) - { - args_info->include_arg [i] = include_list->include_arg; - include_list = include_list->next; - } - } - if (optind < argc) { int i = 0 ;