| 1 | gezelter | 1295 | /* | 
| 2 |  |  | File autogenerated by gengetopt version 2.12.1 | 
| 3 |  |  | generated with the following command: | 
| 4 | gezelter | 1360 | gengetopt --file-name=shaperCmd --unamed-opts=PDBFILE | 
| 5 | gezelter | 1295 |  | 
| 6 |  |  | The developers of gengetopt consider the fixed text that goes in all | 
| 7 |  |  | gengetopt output files to be in the public domain: | 
| 8 |  |  | we make no copyright claims on it. | 
| 9 |  |  | */ | 
| 10 |  |  |  | 
| 11 |  |  | /* If we use autoconf.  */ | 
| 12 |  |  | #ifdef HAVE_CONFIG_H | 
| 13 |  |  | #include "config.h" | 
| 14 |  |  | #endif | 
| 15 |  |  |  | 
| 16 |  |  | #include <stdio.h> | 
| 17 |  |  | #include <stdlib.h> | 
| 18 |  |  | #include <string.h> | 
| 19 |  |  |  | 
| 20 |  |  | #include "getopt.h" | 
| 21 |  |  |  | 
| 22 |  |  | #include "shaperCmd.h" | 
| 23 |  |  |  | 
| 24 |  |  | static | 
| 25 |  |  | void clear_given (struct gengetopt_args_info *args_info); | 
| 26 |  |  | static | 
| 27 |  |  | void clear_args (struct gengetopt_args_info *args_info); | 
| 28 |  |  |  | 
| 29 |  |  | static int | 
| 30 |  |  | cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required, const char *additional_error); | 
| 31 |  |  |  | 
| 32 |  |  | static char * | 
| 33 |  |  | gengetopt_strdup (const char *s); | 
| 34 |  |  |  | 
| 35 |  |  | static | 
| 36 |  |  | void clear_given (struct gengetopt_args_info *args_info) | 
| 37 |  |  | { | 
| 38 |  |  | args_info->help_given = 0 ; | 
| 39 |  |  | args_info->version_given = 0 ; | 
| 40 |  |  | args_info->bandwidth_given = 0 ; | 
| 41 | chrisfen | 1312 | args_info->tolerance_given = 0 ; | 
| 42 | gezelter | 1295 | args_info->charmm_given = 0 ; | 
| 43 |  |  | args_info->amber_given = 0 ; | 
| 44 |  |  | args_info->lj_given = 0 ; | 
| 45 |  |  | args_info->gaff_given = 0 ; | 
| 46 |  |  | args_info->opls_given = 0 ; | 
| 47 |  |  | args_info->ForceField_group_counter = 0 ; | 
| 48 |  |  | } | 
| 49 |  |  |  | 
| 50 |  |  | static | 
| 51 |  |  | void clear_args (struct gengetopt_args_info *args_info) | 
| 52 |  |  | { | 
| 53 |  |  | args_info->bandwidth_arg = 8 ; | 
| 54 | chrisfen | 1312 | args_info->tolerance_arg = 0.01 ; | 
| 55 | gezelter | 1295 | } | 
| 56 |  |  |  | 
| 57 |  |  | void | 
| 58 |  |  | cmdline_parser_print_version (void) | 
| 59 |  |  | { | 
| 60 |  |  | printf ("%s %s\n", CMDLINE_PARSER_PACKAGE, CMDLINE_PARSER_VERSION); | 
| 61 |  |  | } | 
| 62 |  |  |  | 
| 63 |  |  | void | 
| 64 |  |  | cmdline_parser_print_help (void) | 
| 65 |  |  | { | 
| 66 |  |  | cmdline_parser_print_version (); | 
| 67 |  |  | printf("\n" | 
| 68 | gezelter | 1360 | "Usage: %s [OPTIONS]... [PDBFILE]...\n", CMDLINE_PARSER_PACKAGE); | 
| 69 | gezelter | 1295 | printf("\n"); | 
| 70 | chrisfen | 1312 | printf("%s\n","  -h, --help              Print help and exit"); | 
| 71 |  |  | printf("%s\n","  -V, --version           Print version and exit"); | 
| 72 |  |  | printf("%s\n","  -b, --bandwidth=INT     The step detail for the potential grids - typically \n                            a power of 2  (default=`8')"); | 
| 73 |  |  | printf("%s\n","  -t, --tolerance=DOUBLE  The tolerance for recognition of spherical harmonic \n                            terms  (default=`0.01')"); | 
| 74 | gezelter | 1295 | printf("\n"); | 
| 75 |  |  | printf(" Group: ForceField A Force Field must be specified\n"); | 
| 76 | chrisfen | 1312 | printf("%s\n","  -c, --charmm            Use CHARMM 27 parameters"); | 
| 77 |  |  | printf("%s\n","  -a, --amber             Use Amber99 parameters"); | 
| 78 |  |  | printf("%s\n","  -l, --lj                Use Lennard-Jones parameters"); | 
| 79 |  |  | printf("%s\n","  -g, --gaff              Use GAFF parameters"); | 
| 80 |  |  | printf("%s\n","  -o, --opls              Use OPLS/AA parameters"); | 
| 81 | gezelter | 1295 | } | 
| 82 |  |  |  | 
| 83 |  |  | void | 
| 84 |  |  | cmdline_parser_init (struct gengetopt_args_info *args_info) | 
| 85 |  |  | { | 
| 86 |  |  | clear_given (args_info); | 
| 87 |  |  | clear_args (args_info); | 
| 88 | gezelter | 1360 |  | 
| 89 |  |  | args_info->inputs = NULL; | 
| 90 |  |  | args_info->inputs_num = 0; | 
| 91 | gezelter | 1295 | } | 
| 92 |  |  |  | 
| 93 |  |  | void | 
| 94 |  |  | cmdline_parser_free (struct gengetopt_args_info *args_info) | 
| 95 |  |  | { | 
| 96 |  |  |  | 
| 97 | gezelter | 1360 | int i; | 
| 98 | gezelter | 1295 |  | 
| 99 | gezelter | 1360 | for (i = 0; i < args_info->inputs_num; ++i) | 
| 100 |  |  | free (args_info->inputs [i]); | 
| 101 |  |  |  | 
| 102 |  |  | if (args_info->inputs_num) | 
| 103 |  |  | free (args_info->inputs); | 
| 104 |  |  |  | 
| 105 | gezelter | 1295 | clear_given (args_info); | 
| 106 |  |  | } | 
| 107 |  |  |  | 
| 108 |  |  |  | 
| 109 |  |  | /* gengetopt_strdup() */ | 
| 110 |  |  | /* strdup.c replacement of strdup, which is not standard */ | 
| 111 |  |  | char * | 
| 112 |  |  | gengetopt_strdup (const char *s) | 
| 113 |  |  | { | 
| 114 |  |  | char *result = NULL; | 
| 115 |  |  | if (!s) | 
| 116 |  |  | return result; | 
| 117 |  |  |  | 
| 118 |  |  | result = (char*)malloc(strlen(s) + 1); | 
| 119 |  |  | if (result == (char*)0) | 
| 120 |  |  | return (char*)0; | 
| 121 |  |  | strcpy(result, s); | 
| 122 |  |  | return result; | 
| 123 |  |  | } | 
| 124 |  |  |  | 
| 125 |  |  | static void | 
| 126 |  |  | reset_group_ForceField(struct gengetopt_args_info *args_info); | 
| 127 |  |  |  | 
| 128 |  |  | static void | 
| 129 |  |  | reset_group_ForceField(struct gengetopt_args_info *args_info) | 
| 130 |  |  | { | 
| 131 |  |  | if (! args_info->ForceField_group_counter) | 
| 132 |  |  | return; | 
| 133 |  |  |  | 
| 134 |  |  | args_info->charmm_given = 0 ; | 
| 135 |  |  | args_info->amber_given = 0 ; | 
| 136 |  |  | args_info->lj_given = 0 ; | 
| 137 |  |  | args_info->gaff_given = 0 ; | 
| 138 |  |  | args_info->opls_given = 0 ; | 
| 139 |  |  |  | 
| 140 |  |  | args_info->ForceField_group_counter = 0; | 
| 141 |  |  | } | 
| 142 |  |  |  | 
| 143 |  |  | int | 
| 144 |  |  | cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_info) | 
| 145 |  |  | { | 
| 146 |  |  | return cmdline_parser2 (argc, argv, args_info, 0, 1, 1); | 
| 147 |  |  | } | 
| 148 |  |  |  | 
| 149 |  |  | int | 
| 150 |  |  | cmdline_parser2 (int argc, char * const *argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required) | 
| 151 |  |  | { | 
| 152 |  |  | int result; | 
| 153 |  |  |  | 
| 154 |  |  | result = cmdline_parser_internal (argc, argv, args_info, override, initialize, check_required, NULL); | 
| 155 |  |  |  | 
| 156 |  |  | if (result == EXIT_FAILURE) | 
| 157 |  |  | { | 
| 158 |  |  | cmdline_parser_free (args_info); | 
| 159 |  |  | exit (EXIT_FAILURE); | 
| 160 |  |  | } | 
| 161 |  |  |  | 
| 162 |  |  | return result; | 
| 163 |  |  | } | 
| 164 |  |  |  | 
| 165 |  |  | int | 
| 166 |  |  | cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required, const char *additional_error) | 
| 167 |  |  | { | 
| 168 |  |  | int c;        /* Character of the parsed option.  */ | 
| 169 |  |  | int error = 0; | 
| 170 |  |  | struct gengetopt_args_info local_args_info; | 
| 171 |  |  |  | 
| 172 |  |  | if (initialize) | 
| 173 |  |  | cmdline_parser_init (args_info); | 
| 174 |  |  |  | 
| 175 |  |  | cmdline_parser_init (&local_args_info); | 
| 176 |  |  |  | 
| 177 |  |  | optarg = 0; | 
| 178 |  |  | optind = 1; | 
| 179 |  |  | opterr = 1; | 
| 180 |  |  | optopt = '?'; | 
| 181 |  |  |  | 
| 182 |  |  | while (1) | 
| 183 |  |  | { | 
| 184 |  |  | int option_index = 0; | 
| 185 |  |  | char *stop_char; | 
| 186 |  |  |  | 
| 187 |  |  | static struct option long_options[] = { | 
| 188 |  |  | { "help",       0, NULL, 'h' }, | 
| 189 |  |  | { "version",    0, NULL, 'V' }, | 
| 190 |  |  | { "bandwidth",  1, NULL, 'b' }, | 
| 191 | chrisfen | 1312 | { "tolerance",  1, NULL, 't' }, | 
| 192 | gezelter | 1295 | { "charmm",     0, NULL, 'c' }, | 
| 193 |  |  | { "amber",      0, NULL, 'a' }, | 
| 194 |  |  | { "lj", 0, NULL, 'l' }, | 
| 195 |  |  | { "gaff",       0, NULL, 'g' }, | 
| 196 |  |  | { "opls",       0, NULL, 'o' }, | 
| 197 |  |  | { NULL, 0, NULL, 0 } | 
| 198 |  |  | }; | 
| 199 |  |  |  | 
| 200 |  |  | stop_char = 0; | 
| 201 | gezelter | 1360 | c = getopt_long (argc, argv, "hVb:t:calgo", long_options, &option_index); | 
| 202 | gezelter | 1295 |  | 
| 203 |  |  | if (c == -1) break;       /* Exit from `while (1)' loop.  */ | 
| 204 |  |  |  | 
| 205 |  |  | switch (c) | 
| 206 |  |  | { | 
| 207 |  |  | case 'h':       /* Print help and exit.  */ | 
| 208 |  |  | cmdline_parser_print_help (); | 
| 209 |  |  | exit (EXIT_SUCCESS); | 
| 210 |  |  |  | 
| 211 |  |  | case 'V':       /* Print version and exit.  */ | 
| 212 |  |  | cmdline_parser_print_version (); | 
| 213 |  |  | exit (EXIT_SUCCESS); | 
| 214 |  |  |  | 
| 215 |  |  | case 'b':       /* The step detail for the potential grids - typically a power of 2.  */ | 
| 216 |  |  | if (local_args_info.bandwidth_given) | 
| 217 |  |  | { | 
| 218 |  |  | fprintf (stderr, "%s: `--bandwidth' (`-b') option given more than once%s\n", CMDLINE_PARSER_PACKAGE, (additional_error ? additional_error : "")); | 
| 219 |  |  | goto failure; | 
| 220 |  |  | } | 
| 221 |  |  | if (args_info->bandwidth_given && ! override) | 
| 222 |  |  | continue; | 
| 223 |  |  | local_args_info.bandwidth_given = 1; | 
| 224 |  |  | args_info->bandwidth_given = 1; | 
| 225 |  |  | args_info->bandwidth_arg = strtol (optarg,&stop_char,0); | 
| 226 |  |  | break; | 
| 227 |  |  |  | 
| 228 | chrisfen | 1312 | case 't':       /* The tolerance for recognition of spherical harmonic terms.  */ | 
| 229 |  |  | if (local_args_info.tolerance_given) | 
| 230 |  |  | { | 
| 231 |  |  | fprintf (stderr, "%s: `--tolerance' (`-t') option given more than once%s\n", CMDLINE_PARSER_PACKAGE, (additional_error ? additional_error : "")); | 
| 232 |  |  | goto failure; | 
| 233 |  |  | } | 
| 234 |  |  | if (args_info->tolerance_given && ! override) | 
| 235 |  |  | continue; | 
| 236 |  |  | local_args_info.tolerance_given = 1; | 
| 237 |  |  | args_info->tolerance_given = 1; | 
| 238 |  |  | args_info->tolerance_arg = strtod (optarg, NULL); | 
| 239 |  |  | break; | 
| 240 |  |  |  | 
| 241 | gezelter | 1295 | case 'c':       /* Use CHARMM 27 parameters.  */ | 
| 242 |  |  | if (local_args_info.charmm_given) | 
| 243 |  |  | { | 
| 244 |  |  | fprintf (stderr, "%s: `--charmm' (`-c') option given more than once%s\n", CMDLINE_PARSER_PACKAGE, (additional_error ? additional_error : "")); | 
| 245 |  |  | goto failure; | 
| 246 |  |  | } | 
| 247 |  |  | if (args_info->charmm_given && ! override) | 
| 248 |  |  | continue; | 
| 249 |  |  | local_args_info.charmm_given = 1; | 
| 250 |  |  | args_info->charmm_given = 1; | 
| 251 |  |  | if (args_info->ForceField_group_counter && override) | 
| 252 |  |  | reset_group_ForceField (args_info); | 
| 253 |  |  | args_info->ForceField_group_counter += 1; | 
| 254 |  |  | break; | 
| 255 |  |  |  | 
| 256 |  |  | case 'a':       /* Use Amber99 parameters.  */ | 
| 257 |  |  | if (local_args_info.amber_given) | 
| 258 |  |  | { | 
| 259 |  |  | fprintf (stderr, "%s: `--amber' (`-a') option given more than once%s\n", CMDLINE_PARSER_PACKAGE, (additional_error ? additional_error : "")); | 
| 260 |  |  | goto failure; | 
| 261 |  |  | } | 
| 262 |  |  | if (args_info->amber_given && ! override) | 
| 263 |  |  | continue; | 
| 264 |  |  | local_args_info.amber_given = 1; | 
| 265 |  |  | args_info->amber_given = 1; | 
| 266 |  |  | if (args_info->ForceField_group_counter && override) | 
| 267 |  |  | reset_group_ForceField (args_info); | 
| 268 |  |  | args_info->ForceField_group_counter += 1; | 
| 269 |  |  | break; | 
| 270 |  |  |  | 
| 271 |  |  | case 'l':       /* Use Lennard-Jones parameters.  */ | 
| 272 |  |  | if (local_args_info.lj_given) | 
| 273 |  |  | { | 
| 274 |  |  | fprintf (stderr, "%s: `--lj' (`-l') option given more than once%s\n", CMDLINE_PARSER_PACKAGE, (additional_error ? additional_error : "")); | 
| 275 |  |  | goto failure; | 
| 276 |  |  | } | 
| 277 |  |  | if (args_info->lj_given && ! override) | 
| 278 |  |  | continue; | 
| 279 |  |  | local_args_info.lj_given = 1; | 
| 280 |  |  | args_info->lj_given = 1; | 
| 281 |  |  | if (args_info->ForceField_group_counter && override) | 
| 282 |  |  | reset_group_ForceField (args_info); | 
| 283 |  |  | args_info->ForceField_group_counter += 1; | 
| 284 |  |  | break; | 
| 285 |  |  |  | 
| 286 |  |  | case 'g':       /* Use GAFF parameters.  */ | 
| 287 |  |  | if (local_args_info.gaff_given) | 
| 288 |  |  | { | 
| 289 |  |  | fprintf (stderr, "%s: `--gaff' (`-g') option given more than once%s\n", CMDLINE_PARSER_PACKAGE, (additional_error ? additional_error : "")); | 
| 290 |  |  | goto failure; | 
| 291 |  |  | } | 
| 292 |  |  | if (args_info->gaff_given && ! override) | 
| 293 |  |  | continue; | 
| 294 |  |  | local_args_info.gaff_given = 1; | 
| 295 |  |  | args_info->gaff_given = 1; | 
| 296 |  |  | if (args_info->ForceField_group_counter && override) | 
| 297 |  |  | reset_group_ForceField (args_info); | 
| 298 |  |  | args_info->ForceField_group_counter += 1; | 
| 299 |  |  | break; | 
| 300 |  |  |  | 
| 301 |  |  | case 'o':       /* Use OPLS/AA parameters.  */ | 
| 302 |  |  | if (local_args_info.opls_given) | 
| 303 |  |  | { | 
| 304 |  |  | fprintf (stderr, "%s: `--opls' (`-o') option given more than once%s\n", CMDLINE_PARSER_PACKAGE, (additional_error ? additional_error : "")); | 
| 305 |  |  | goto failure; | 
| 306 |  |  | } | 
| 307 |  |  | if (args_info->opls_given && ! override) | 
| 308 |  |  | continue; | 
| 309 |  |  | local_args_info.opls_given = 1; | 
| 310 |  |  | args_info->opls_given = 1; | 
| 311 |  |  | if (args_info->ForceField_group_counter && override) | 
| 312 |  |  | reset_group_ForceField (args_info); | 
| 313 |  |  | args_info->ForceField_group_counter += 1; | 
| 314 |  |  | break; | 
| 315 |  |  |  | 
| 316 |  |  |  | 
| 317 |  |  | case 0: /* Long option with no short option */ | 
| 318 |  |  |  | 
| 319 |  |  | case '?':       /* Invalid option.  */ | 
| 320 |  |  | /* `getopt_long' already printed an error message.  */ | 
| 321 |  |  | goto failure; | 
| 322 |  |  |  | 
| 323 |  |  | default:        /* bug: option not considered.  */ | 
| 324 |  |  | fprintf (stderr, "%s: option unknown: %c%s\n", CMDLINE_PARSER_PACKAGE, c, (additional_error ? additional_error : "")); | 
| 325 |  |  | abort (); | 
| 326 |  |  | } /* switch */ | 
| 327 |  |  | } /* while */ | 
| 328 |  |  |  | 
| 329 |  |  | if ( args_info->ForceField_group_counter != 1) | 
| 330 |  |  | { | 
| 331 |  |  | fprintf (stderr, "%s: %d options of group ForceField were given. One is required.%s\n", CMDLINE_PARSER_PACKAGE, args_info->ForceField_group_counter, (additional_error ? additional_error : "")); | 
| 332 |  |  | error = 1; | 
| 333 |  |  | } | 
| 334 |  |  |  | 
| 335 |  |  |  | 
| 336 |  |  |  | 
| 337 |  |  | if (check_required) | 
| 338 |  |  | { | 
| 339 |  |  | } | 
| 340 |  |  |  | 
| 341 |  |  | if ( error ) | 
| 342 |  |  | return (EXIT_FAILURE); | 
| 343 |  |  |  | 
| 344 | gezelter | 1360 | if (optind < argc) | 
| 345 |  |  | { | 
| 346 |  |  | int i = 0 ; | 
| 347 |  |  |  | 
| 348 |  |  | args_info->inputs_num = argc - optind ; | 
| 349 |  |  | args_info->inputs = | 
| 350 |  |  | (char **)(malloc ((args_info->inputs_num)*sizeof(char *))) ; | 
| 351 |  |  | while (optind < argc) | 
| 352 |  |  | args_info->inputs[ i++ ] = gengetopt_strdup (argv[optind++]) ; | 
| 353 |  |  | } | 
| 354 |  |  |  | 
| 355 | gezelter | 1295 | return 0; | 
| 356 |  |  |  | 
| 357 |  |  | failure: | 
| 358 |  |  | cmdline_parser_free (&local_args_info); | 
| 359 |  |  | return (EXIT_FAILURE); | 
| 360 |  |  | } |