| 1 |
|
/* |
| 2 |
< |
File autogenerated by gengetopt version 2.11 |
| 2 |
> |
File autogenerated by gengetopt version 2.22 |
| 3 |
|
generated with the following command: |
| 4 |
< |
/home/maul/gezelter/tim/bin/gengetopt -F staticPropsCmd |
| 4 |
> |
gengetopt -F StaticPropsCmd -u |
| 5 |
|
|
| 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 |
– |
|
| 12 |
– |
#include <stdio.h> |
| 13 |
– |
#include <stdlib.h> |
| 14 |
– |
#include <string.h> |
| 15 |
– |
|
| 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 "staticPropsCmd.h" |
| 22 |
> |
#include "StaticPropsCmd.h" |
| 23 |
|
|
| 24 |
+ |
const char *gengetopt_args_info_purpose = ""; |
| 25 |
+ |
|
| 26 |
+ |
const char *gengetopt_args_info_usage = "Usage: StaticProps [OPTIONS]... [FILES]..."; |
| 27 |
+ |
|
| 28 |
+ |
const char *gengetopt_args_info_description = ""; |
| 29 |
+ |
|
| 30 |
+ |
const char *gengetopt_args_info_help[] = { |
| 31 |
+ |
" -h, --help Print help and exit", |
| 32 |
+ |
" -V, --version Print version and exit", |
| 33 |
+ |
" -i, --input=filename input dump file", |
| 34 |
+ |
" -o, --output=filename output file name", |
| 35 |
+ |
" -n, --step=INT process every n frame (default=`1')", |
| 36 |
+ |
" -b, --nbins=INT number of bins (general purpose) \n (default=`100')", |
| 37 |
+ |
" -x, --nbins_x=INT number of bins in x axis (default=`100')", |
| 38 |
+ |
" -y, --nbins_y=INT number of bins in y axis (default=`100')", |
| 39 |
+ |
" --nbins_z=INT number of bins in z axis (default=`100')", |
| 40 |
+ |
" -a, --nanglebins=INT number of bins for cos(angle) (default=`50')", |
| 41 |
+ |
" -c, --rcut=DOUBLE cutoff radius (rcut)", |
| 42 |
+ |
" --dz=DOUBLE slab width (dz)", |
| 43 |
+ |
" --length=DOUBLE maximum length (Defaults to 1/2 smallest length \n of first frame)", |
| 44 |
+ |
" --zlength=DOUBLE maximum length (Defaults to 1/2 smallest length \n of first frame)", |
| 45 |
+ |
" -z, --zoffset=DOUBLE Where to set the zero for the slab_density \n calculation (default=`0')", |
| 46 |
+ |
" --sele1=selection script select the first stuntdouble set", |
| 47 |
+ |
" --sele2=selection script select the second stuntdouble set", |
| 48 |
+ |
" --sele3=selection script select the third stuntdouble set", |
| 49 |
+ |
" --refsele=selection script\n select reference (use and only use with --gxyz)", |
| 50 |
+ |
" --comsele=selection script\n select stunt doubles for center-of-mass \n reference point", |
| 51 |
+ |
" --molname=STRING molecule name", |
| 52 |
+ |
" --begin=INT begin internal index", |
| 53 |
+ |
" --end=INT end internal index", |
| 54 |
+ |
" --radius=DOUBLE nanoparticle radius", |
| 55 |
+ |
"\n Group: staticProps\n an option of this group is required", |
| 56 |
+ |
" --bo bond order parameter (--rcut must be specified)", |
| 57 |
+ |
" --bor bond order parameter as a function of radius \n (--rcut must be specified)", |
| 58 |
+ |
" --bad N(theta) bond angle density within (--rcut must \n be specified)", |
| 59 |
+ |
" --count count of molecules matching selection criteria \n (and associated statistics)", |
| 60 |
+ |
" -g, --gofr g(r)", |
| 61 |
+ |
" --gofz g(z)", |
| 62 |
+ |
" --r_theta g(r, cos(theta))", |
| 63 |
+ |
" --r_omega g(r, cos(omega))", |
| 64 |
+ |
" --r_z g(r, z)", |
| 65 |
+ |
" --theta_omega g(cos(theta), cos(omega))", |
| 66 |
+ |
" --gxyz g(x, y, z)", |
| 67 |
+ |
" --twodgofr 2D g(r) (Slab width --dz must be specified)", |
| 68 |
+ |
" -p, --p2 p2 order parameter (--sele1 and --sele2 must be \n specified)", |
| 69 |
+ |
" --rp2 rp2 order parameter (--sele1 and --sele2 must \n be specified)", |
| 70 |
+ |
" -s, --scd scd order parameter (either --sele1, --sele2, \n --sele3 are specified or --molname, --begin, \n --end are specified)", |
| 71 |
+ |
" -d, --density density plot", |
| 72 |
+ |
" --slab_density slab density", |
| 73 |
+ |
" --p_angle p(cos(theta))", |
| 74 |
+ |
" --hxy hxy", |
| 75 |
+ |
" --rho_r rho of R", |
| 76 |
+ |
" --hullvol hull volume of nanoparticle", |
| 77 |
+ |
0 |
| 78 |
+ |
}; |
| 79 |
+ |
|
| 80 |
+ |
typedef enum {ARG_NO |
| 81 |
+ |
, ARG_STRING |
| 82 |
+ |
, ARG_INT |
| 83 |
+ |
, ARG_DOUBLE |
| 84 |
+ |
} cmdline_parser_arg_type; |
| 85 |
+ |
|
| 86 |
+ |
static |
| 87 |
+ |
void clear_given (struct gengetopt_args_info *args_info); |
| 88 |
+ |
static |
| 89 |
+ |
void clear_args (struct gengetopt_args_info *args_info); |
| 90 |
+ |
|
| 91 |
+ |
static int |
| 92 |
+ |
cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_info *args_info, |
| 93 |
+ |
struct cmdline_parser_params *params, const char *additional_error); |
| 94 |
+ |
|
| 95 |
+ |
static int |
| 96 |
+ |
cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error); |
| 97 |
+ |
|
| 98 |
+ |
static char * |
| 99 |
+ |
gengetopt_strdup (const char *s); |
| 100 |
+ |
|
| 101 |
+ |
static |
| 102 |
+ |
void clear_given (struct gengetopt_args_info *args_info) |
| 103 |
+ |
{ |
| 104 |
+ |
args_info->help_given = 0 ; |
| 105 |
+ |
args_info->version_given = 0 ; |
| 106 |
+ |
args_info->input_given = 0 ; |
| 107 |
+ |
args_info->output_given = 0 ; |
| 108 |
+ |
args_info->step_given = 0 ; |
| 109 |
+ |
args_info->nbins_given = 0 ; |
| 110 |
+ |
args_info->nbins_x_given = 0 ; |
| 111 |
+ |
args_info->nbins_y_given = 0 ; |
| 112 |
+ |
args_info->nbins_z_given = 0 ; |
| 113 |
+ |
args_info->nanglebins_given = 0 ; |
| 114 |
+ |
args_info->rcut_given = 0 ; |
| 115 |
+ |
args_info->dz_given = 0 ; |
| 116 |
+ |
args_info->length_given = 0 ; |
| 117 |
+ |
args_info->zlength_given = 0 ; |
| 118 |
+ |
args_info->zoffset_given = 0 ; |
| 119 |
+ |
args_info->sele1_given = 0 ; |
| 120 |
+ |
args_info->sele2_given = 0 ; |
| 121 |
+ |
args_info->sele3_given = 0 ; |
| 122 |
+ |
args_info->refsele_given = 0 ; |
| 123 |
+ |
args_info->comsele_given = 0 ; |
| 124 |
+ |
args_info->molname_given = 0 ; |
| 125 |
+ |
args_info->begin_given = 0 ; |
| 126 |
+ |
args_info->end_given = 0 ; |
| 127 |
+ |
args_info->radius_given = 0 ; |
| 128 |
+ |
args_info->bo_given = 0 ; |
| 129 |
+ |
args_info->bor_given = 0 ; |
| 130 |
+ |
args_info->bad_given = 0 ; |
| 131 |
+ |
args_info->count_given = 0 ; |
| 132 |
+ |
args_info->gofr_given = 0 ; |
| 133 |
+ |
args_info->gofz_given = 0 ; |
| 134 |
+ |
args_info->r_theta_given = 0 ; |
| 135 |
+ |
args_info->r_omega_given = 0 ; |
| 136 |
+ |
args_info->r_z_given = 0 ; |
| 137 |
+ |
args_info->theta_omega_given = 0 ; |
| 138 |
+ |
args_info->gxyz_given = 0 ; |
| 139 |
+ |
args_info->twodgofr_given = 0 ; |
| 140 |
+ |
args_info->p2_given = 0 ; |
| 141 |
+ |
args_info->rp2_given = 0 ; |
| 142 |
+ |
args_info->scd_given = 0 ; |
| 143 |
+ |
args_info->density_given = 0 ; |
| 144 |
+ |
args_info->slab_density_given = 0 ; |
| 145 |
+ |
args_info->p_angle_given = 0 ; |
| 146 |
+ |
args_info->hxy_given = 0 ; |
| 147 |
+ |
args_info->rho_r_given = 0 ; |
| 148 |
+ |
args_info->hullvol_given = 0 ; |
| 149 |
+ |
args_info->staticProps_group_counter = 0 ; |
| 150 |
+ |
} |
| 151 |
+ |
|
| 152 |
+ |
static |
| 153 |
+ |
void clear_args (struct gengetopt_args_info *args_info) |
| 154 |
+ |
{ |
| 155 |
+ |
args_info->input_arg = NULL; |
| 156 |
+ |
args_info->input_orig = NULL; |
| 157 |
+ |
args_info->output_arg = NULL; |
| 158 |
+ |
args_info->output_orig = NULL; |
| 159 |
+ |
args_info->step_arg = 1; |
| 160 |
+ |
args_info->step_orig = NULL; |
| 161 |
+ |
args_info->nbins_arg = 100; |
| 162 |
+ |
args_info->nbins_orig = NULL; |
| 163 |
+ |
args_info->nbins_x_arg = 100; |
| 164 |
+ |
args_info->nbins_x_orig = NULL; |
| 165 |
+ |
args_info->nbins_y_arg = 100; |
| 166 |
+ |
args_info->nbins_y_orig = NULL; |
| 167 |
+ |
args_info->nbins_z_arg = 100; |
| 168 |
+ |
args_info->nbins_z_orig = NULL; |
| 169 |
+ |
args_info->nanglebins_arg = 50; |
| 170 |
+ |
args_info->nanglebins_orig = NULL; |
| 171 |
+ |
args_info->rcut_orig = NULL; |
| 172 |
+ |
args_info->dz_orig = NULL; |
| 173 |
+ |
args_info->length_orig = NULL; |
| 174 |
+ |
args_info->zlength_orig = NULL; |
| 175 |
+ |
args_info->zoffset_arg = 0; |
| 176 |
+ |
args_info->zoffset_orig = NULL; |
| 177 |
+ |
args_info->sele1_arg = NULL; |
| 178 |
+ |
args_info->sele1_orig = NULL; |
| 179 |
+ |
args_info->sele2_arg = NULL; |
| 180 |
+ |
args_info->sele2_orig = NULL; |
| 181 |
+ |
args_info->sele3_arg = NULL; |
| 182 |
+ |
args_info->sele3_orig = NULL; |
| 183 |
+ |
args_info->refsele_arg = NULL; |
| 184 |
+ |
args_info->refsele_orig = NULL; |
| 185 |
+ |
args_info->comsele_arg = NULL; |
| 186 |
+ |
args_info->comsele_orig = NULL; |
| 187 |
+ |
args_info->molname_arg = NULL; |
| 188 |
+ |
args_info->molname_orig = NULL; |
| 189 |
+ |
args_info->begin_orig = NULL; |
| 190 |
+ |
args_info->end_orig = NULL; |
| 191 |
+ |
args_info->radius_orig = NULL; |
| 192 |
+ |
|
| 193 |
+ |
} |
| 194 |
+ |
|
| 195 |
+ |
static |
| 196 |
+ |
void init_args_info(struct gengetopt_args_info *args_info) |
| 197 |
+ |
{ |
| 198 |
+ |
|
| 199 |
+ |
|
| 200 |
+ |
args_info->help_help = gengetopt_args_info_help[0] ; |
| 201 |
+ |
args_info->version_help = gengetopt_args_info_help[1] ; |
| 202 |
+ |
args_info->input_help = gengetopt_args_info_help[2] ; |
| 203 |
+ |
args_info->output_help = gengetopt_args_info_help[3] ; |
| 204 |
+ |
args_info->step_help = gengetopt_args_info_help[4] ; |
| 205 |
+ |
args_info->nbins_help = gengetopt_args_info_help[5] ; |
| 206 |
+ |
args_info->nbins_x_help = gengetopt_args_info_help[6] ; |
| 207 |
+ |
args_info->nbins_y_help = gengetopt_args_info_help[7] ; |
| 208 |
+ |
args_info->nbins_z_help = gengetopt_args_info_help[8] ; |
| 209 |
+ |
args_info->nanglebins_help = gengetopt_args_info_help[9] ; |
| 210 |
+ |
args_info->rcut_help = gengetopt_args_info_help[10] ; |
| 211 |
+ |
args_info->dz_help = gengetopt_args_info_help[11] ; |
| 212 |
+ |
args_info->length_help = gengetopt_args_info_help[12] ; |
| 213 |
+ |
args_info->zlength_help = gengetopt_args_info_help[13] ; |
| 214 |
+ |
args_info->zoffset_help = gengetopt_args_info_help[14] ; |
| 215 |
+ |
args_info->sele1_help = gengetopt_args_info_help[15] ; |
| 216 |
+ |
args_info->sele2_help = gengetopt_args_info_help[16] ; |
| 217 |
+ |
args_info->sele3_help = gengetopt_args_info_help[17] ; |
| 218 |
+ |
args_info->refsele_help = gengetopt_args_info_help[18] ; |
| 219 |
+ |
args_info->comsele_help = gengetopt_args_info_help[19] ; |
| 220 |
+ |
args_info->molname_help = gengetopt_args_info_help[20] ; |
| 221 |
+ |
args_info->begin_help = gengetopt_args_info_help[21] ; |
| 222 |
+ |
args_info->end_help = gengetopt_args_info_help[22] ; |
| 223 |
+ |
args_info->radius_help = gengetopt_args_info_help[23] ; |
| 224 |
+ |
args_info->bo_help = gengetopt_args_info_help[25] ; |
| 225 |
+ |
args_info->bor_help = gengetopt_args_info_help[26] ; |
| 226 |
+ |
args_info->bad_help = gengetopt_args_info_help[27] ; |
| 227 |
+ |
args_info->count_help = gengetopt_args_info_help[28] ; |
| 228 |
+ |
args_info->gofr_help = gengetopt_args_info_help[29] ; |
| 229 |
+ |
args_info->gofz_help = gengetopt_args_info_help[30] ; |
| 230 |
+ |
args_info->r_theta_help = gengetopt_args_info_help[31] ; |
| 231 |
+ |
args_info->r_omega_help = gengetopt_args_info_help[32] ; |
| 232 |
+ |
args_info->r_z_help = gengetopt_args_info_help[33] ; |
| 233 |
+ |
args_info->theta_omega_help = gengetopt_args_info_help[34] ; |
| 234 |
+ |
args_info->gxyz_help = gengetopt_args_info_help[35] ; |
| 235 |
+ |
args_info->twodgofr_help = gengetopt_args_info_help[36] ; |
| 236 |
+ |
args_info->p2_help = gengetopt_args_info_help[37] ; |
| 237 |
+ |
args_info->rp2_help = gengetopt_args_info_help[38] ; |
| 238 |
+ |
args_info->scd_help = gengetopt_args_info_help[39] ; |
| 239 |
+ |
args_info->density_help = gengetopt_args_info_help[40] ; |
| 240 |
+ |
args_info->slab_density_help = gengetopt_args_info_help[41] ; |
| 241 |
+ |
args_info->p_angle_help = gengetopt_args_info_help[42] ; |
| 242 |
+ |
args_info->hxy_help = gengetopt_args_info_help[43] ; |
| 243 |
+ |
args_info->rho_r_help = gengetopt_args_info_help[44] ; |
| 244 |
+ |
args_info->hullvol_help = gengetopt_args_info_help[45] ; |
| 245 |
+ |
|
| 246 |
+ |
} |
| 247 |
+ |
|
| 248 |
|
void |
| 249 |
|
cmdline_parser_print_version (void) |
| 250 |
|
{ |
| 251 |
|
printf ("%s %s\n", CMDLINE_PARSER_PACKAGE, CMDLINE_PARSER_VERSION); |
| 252 |
|
} |
| 253 |
|
|
| 254 |
+ |
static void print_help_common(void) { |
| 255 |
+ |
cmdline_parser_print_version (); |
| 256 |
+ |
|
| 257 |
+ |
if (strlen(gengetopt_args_info_purpose) > 0) |
| 258 |
+ |
printf("\n%s\n", gengetopt_args_info_purpose); |
| 259 |
+ |
|
| 260 |
+ |
if (strlen(gengetopt_args_info_usage) > 0) |
| 261 |
+ |
printf("\n%s\n", gengetopt_args_info_usage); |
| 262 |
+ |
|
| 263 |
+ |
printf("\n"); |
| 264 |
+ |
|
| 265 |
+ |
if (strlen(gengetopt_args_info_description) > 0) |
| 266 |
+ |
printf("%s\n", gengetopt_args_info_description); |
| 267 |
+ |
} |
| 268 |
+ |
|
| 269 |
|
void |
| 270 |
|
cmdline_parser_print_help (void) |
| 271 |
|
{ |
| 272 |
< |
cmdline_parser_print_version (); |
| 273 |
< |
printf("\n" |
| 274 |
< |
"Usage: %s [OPTIONS]...\n", CMDLINE_PARSER_PACKAGE); |
| 275 |
< |
printf("\n"); |
| 38 |
< |
printf(" -h, --help Print help and exit\n"); |
| 39 |
< |
printf(" -V, --version Print version and exit\n"); |
| 40 |
< |
printf(" -i, --input=filename input dump file\n"); |
| 41 |
< |
printf(" -o, --output=filename output file name\n"); |
| 42 |
< |
printf(" -n, --frame=INT print every n frame (default=`1')\n"); |
| 43 |
< |
printf(" -d, --ndistebins=INT number of bins for distance (default=`50')\n"); |
| 44 |
< |
printf(" -a, --nanglebins=INT number of bins for cos(angle) (default=`50')\n"); |
| 45 |
< |
printf(" -l, --length=DOUBLE maximum length\n"); |
| 46 |
< |
printf(" --sele1=selection script select first stuntdouble set\n"); |
| 47 |
< |
printf(" --sele2=selection script select second stuntdouble set\n"); |
| 48 |
< |
printf("\n"); |
| 49 |
< |
printf(" Group: staticProps an option of this group is required\n"); |
| 50 |
< |
printf(" --gofr g(r)\n"); |
| 51 |
< |
printf(" --r_theta g(r, cos(theta))\n"); |
| 52 |
< |
printf(" --r_omega g(r, cos(omega))\n"); |
| 53 |
< |
printf(" --theta_omega g(cos(theta), cos(omega))\n"); |
| 54 |
< |
printf(" --xyz g(x, y, z)\n"); |
| 272 |
> |
int i = 0; |
| 273 |
> |
print_help_common(); |
| 274 |
> |
while (gengetopt_args_info_help[i]) |
| 275 |
> |
printf("%s\n", gengetopt_args_info_help[i++]); |
| 276 |
|
} |
| 277 |
|
|
| 278 |
+ |
void |
| 279 |
+ |
cmdline_parser_init (struct gengetopt_args_info *args_info) |
| 280 |
+ |
{ |
| 281 |
+ |
clear_given (args_info); |
| 282 |
+ |
clear_args (args_info); |
| 283 |
+ |
init_args_info (args_info); |
| 284 |
|
|
| 285 |
< |
static char *gengetopt_strdup (const char *s); |
| 285 |
> |
args_info->inputs = NULL; |
| 286 |
> |
args_info->inputs_num = 0; |
| 287 |
> |
} |
| 288 |
|
|
| 289 |
< |
/* gengetopt_strdup() */ |
| 290 |
< |
/* strdup.c replacement of strdup, which is not standard */ |
| 289 |
> |
void |
| 290 |
> |
cmdline_parser_params_init(struct cmdline_parser_params *params) |
| 291 |
> |
{ |
| 292 |
> |
if (params) |
| 293 |
> |
{ |
| 294 |
> |
params->override = 0; |
| 295 |
> |
params->initialize = 1; |
| 296 |
> |
params->check_required = 1; |
| 297 |
> |
params->check_ambiguity = 0; |
| 298 |
> |
params->print_errors = 1; |
| 299 |
> |
} |
| 300 |
> |
} |
| 301 |
> |
|
| 302 |
> |
struct cmdline_parser_params * |
| 303 |
> |
cmdline_parser_params_create(void) |
| 304 |
> |
{ |
| 305 |
> |
struct cmdline_parser_params *params = |
| 306 |
> |
(struct cmdline_parser_params *)malloc(sizeof(struct cmdline_parser_params)); |
| 307 |
> |
cmdline_parser_params_init(params); |
| 308 |
> |
return params; |
| 309 |
> |
} |
| 310 |
> |
|
| 311 |
> |
static void |
| 312 |
> |
free_string_field (char **s) |
| 313 |
> |
{ |
| 314 |
> |
if (*s) |
| 315 |
> |
{ |
| 316 |
> |
free (*s); |
| 317 |
> |
*s = 0; |
| 318 |
> |
} |
| 319 |
> |
} |
| 320 |
> |
|
| 321 |
> |
|
| 322 |
> |
static void |
| 323 |
> |
cmdline_parser_release (struct gengetopt_args_info *args_info) |
| 324 |
> |
{ |
| 325 |
> |
unsigned int i; |
| 326 |
> |
free_string_field (&(args_info->input_arg)); |
| 327 |
> |
free_string_field (&(args_info->input_orig)); |
| 328 |
> |
free_string_field (&(args_info->output_arg)); |
| 329 |
> |
free_string_field (&(args_info->output_orig)); |
| 330 |
> |
free_string_field (&(args_info->step_orig)); |
| 331 |
> |
free_string_field (&(args_info->nbins_orig)); |
| 332 |
> |
free_string_field (&(args_info->nbins_x_orig)); |
| 333 |
> |
free_string_field (&(args_info->nbins_y_orig)); |
| 334 |
> |
free_string_field (&(args_info->nbins_z_orig)); |
| 335 |
> |
free_string_field (&(args_info->nanglebins_orig)); |
| 336 |
> |
free_string_field (&(args_info->rcut_orig)); |
| 337 |
> |
free_string_field (&(args_info->dz_orig)); |
| 338 |
> |
free_string_field (&(args_info->length_orig)); |
| 339 |
> |
free_string_field (&(args_info->zlength_orig)); |
| 340 |
> |
free_string_field (&(args_info->zoffset_orig)); |
| 341 |
> |
free_string_field (&(args_info->sele1_arg)); |
| 342 |
> |
free_string_field (&(args_info->sele1_orig)); |
| 343 |
> |
free_string_field (&(args_info->sele2_arg)); |
| 344 |
> |
free_string_field (&(args_info->sele2_orig)); |
| 345 |
> |
free_string_field (&(args_info->sele3_arg)); |
| 346 |
> |
free_string_field (&(args_info->sele3_orig)); |
| 347 |
> |
free_string_field (&(args_info->refsele_arg)); |
| 348 |
> |
free_string_field (&(args_info->refsele_orig)); |
| 349 |
> |
free_string_field (&(args_info->comsele_arg)); |
| 350 |
> |
free_string_field (&(args_info->comsele_orig)); |
| 351 |
> |
free_string_field (&(args_info->molname_arg)); |
| 352 |
> |
free_string_field (&(args_info->molname_orig)); |
| 353 |
> |
free_string_field (&(args_info->begin_orig)); |
| 354 |
> |
free_string_field (&(args_info->end_orig)); |
| 355 |
> |
free_string_field (&(args_info->radius_orig)); |
| 356 |
> |
|
| 357 |
> |
|
| 358 |
> |
for (i = 0; i < args_info->inputs_num; ++i) |
| 359 |
> |
free (args_info->inputs [i]); |
| 360 |
> |
|
| 361 |
> |
if (args_info->inputs_num) |
| 362 |
> |
free (args_info->inputs); |
| 363 |
> |
|
| 364 |
> |
clear_given (args_info); |
| 365 |
> |
} |
| 366 |
> |
|
| 367 |
> |
|
| 368 |
> |
static void |
| 369 |
> |
write_into_file(FILE *outfile, const char *opt, const char *arg, char *values[]) |
| 370 |
> |
{ |
| 371 |
> |
if (arg) { |
| 372 |
> |
fprintf(outfile, "%s=\"%s\"\n", opt, arg); |
| 373 |
> |
} else { |
| 374 |
> |
fprintf(outfile, "%s\n", opt); |
| 375 |
> |
} |
| 376 |
> |
} |
| 377 |
> |
|
| 378 |
> |
|
| 379 |
> |
int |
| 380 |
> |
cmdline_parser_dump(FILE *outfile, struct gengetopt_args_info *args_info) |
| 381 |
> |
{ |
| 382 |
> |
int i = 0; |
| 383 |
> |
|
| 384 |
> |
if (!outfile) |
| 385 |
> |
{ |
| 386 |
> |
fprintf (stderr, "%s: cannot dump options to stream\n", CMDLINE_PARSER_PACKAGE); |
| 387 |
> |
return EXIT_FAILURE; |
| 388 |
> |
} |
| 389 |
> |
|
| 390 |
> |
if (args_info->help_given) |
| 391 |
> |
write_into_file(outfile, "help", 0, 0 ); |
| 392 |
> |
if (args_info->version_given) |
| 393 |
> |
write_into_file(outfile, "version", 0, 0 ); |
| 394 |
> |
if (args_info->input_given) |
| 395 |
> |
write_into_file(outfile, "input", args_info->input_orig, 0); |
| 396 |
> |
if (args_info->output_given) |
| 397 |
> |
write_into_file(outfile, "output", args_info->output_orig, 0); |
| 398 |
> |
if (args_info->step_given) |
| 399 |
> |
write_into_file(outfile, "step", args_info->step_orig, 0); |
| 400 |
> |
if (args_info->nbins_given) |
| 401 |
> |
write_into_file(outfile, "nbins", args_info->nbins_orig, 0); |
| 402 |
> |
if (args_info->nbins_x_given) |
| 403 |
> |
write_into_file(outfile, "nbins_x", args_info->nbins_x_orig, 0); |
| 404 |
> |
if (args_info->nbins_y_given) |
| 405 |
> |
write_into_file(outfile, "nbins_y", args_info->nbins_y_orig, 0); |
| 406 |
> |
if (args_info->nbins_z_given) |
| 407 |
> |
write_into_file(outfile, "nbins_z", args_info->nbins_z_orig, 0); |
| 408 |
> |
if (args_info->nanglebins_given) |
| 409 |
> |
write_into_file(outfile, "nanglebins", args_info->nanglebins_orig, 0); |
| 410 |
> |
if (args_info->rcut_given) |
| 411 |
> |
write_into_file(outfile, "rcut", args_info->rcut_orig, 0); |
| 412 |
> |
if (args_info->dz_given) |
| 413 |
> |
write_into_file(outfile, "dz", args_info->dz_orig, 0); |
| 414 |
> |
if (args_info->length_given) |
| 415 |
> |
write_into_file(outfile, "length", args_info->length_orig, 0); |
| 416 |
> |
if (args_info->zlength_given) |
| 417 |
> |
write_into_file(outfile, "zlength", args_info->zlength_orig, 0); |
| 418 |
> |
if (args_info->zoffset_given) |
| 419 |
> |
write_into_file(outfile, "zoffset", args_info->zoffset_orig, 0); |
| 420 |
> |
if (args_info->sele1_given) |
| 421 |
> |
write_into_file(outfile, "sele1", args_info->sele1_orig, 0); |
| 422 |
> |
if (args_info->sele2_given) |
| 423 |
> |
write_into_file(outfile, "sele2", args_info->sele2_orig, 0); |
| 424 |
> |
if (args_info->sele3_given) |
| 425 |
> |
write_into_file(outfile, "sele3", args_info->sele3_orig, 0); |
| 426 |
> |
if (args_info->refsele_given) |
| 427 |
> |
write_into_file(outfile, "refsele", args_info->refsele_orig, 0); |
| 428 |
> |
if (args_info->comsele_given) |
| 429 |
> |
write_into_file(outfile, "comsele", args_info->comsele_orig, 0); |
| 430 |
> |
if (args_info->molname_given) |
| 431 |
> |
write_into_file(outfile, "molname", args_info->molname_orig, 0); |
| 432 |
> |
if (args_info->begin_given) |
| 433 |
> |
write_into_file(outfile, "begin", args_info->begin_orig, 0); |
| 434 |
> |
if (args_info->end_given) |
| 435 |
> |
write_into_file(outfile, "end", args_info->end_orig, 0); |
| 436 |
> |
if (args_info->radius_given) |
| 437 |
> |
write_into_file(outfile, "radius", args_info->radius_orig, 0); |
| 438 |
> |
if (args_info->bo_given) |
| 439 |
> |
write_into_file(outfile, "bo", 0, 0 ); |
| 440 |
> |
if (args_info->bor_given) |
| 441 |
> |
write_into_file(outfile, "bor", 0, 0 ); |
| 442 |
> |
if (args_info->bad_given) |
| 443 |
> |
write_into_file(outfile, "bad", 0, 0 ); |
| 444 |
> |
if (args_info->count_given) |
| 445 |
> |
write_into_file(outfile, "count", 0, 0 ); |
| 446 |
> |
if (args_info->gofr_given) |
| 447 |
> |
write_into_file(outfile, "gofr", 0, 0 ); |
| 448 |
> |
if (args_info->gofz_given) |
| 449 |
> |
write_into_file(outfile, "gofz", 0, 0 ); |
| 450 |
> |
if (args_info->r_theta_given) |
| 451 |
> |
write_into_file(outfile, "r_theta", 0, 0 ); |
| 452 |
> |
if (args_info->r_omega_given) |
| 453 |
> |
write_into_file(outfile, "r_omega", 0, 0 ); |
| 454 |
> |
if (args_info->r_z_given) |
| 455 |
> |
write_into_file(outfile, "r_z", 0, 0 ); |
| 456 |
> |
if (args_info->theta_omega_given) |
| 457 |
> |
write_into_file(outfile, "theta_omega", 0, 0 ); |
| 458 |
> |
if (args_info->gxyz_given) |
| 459 |
> |
write_into_file(outfile, "gxyz", 0, 0 ); |
| 460 |
> |
if (args_info->twodgofr_given) |
| 461 |
> |
write_into_file(outfile, "twodgofr", 0, 0 ); |
| 462 |
> |
if (args_info->p2_given) |
| 463 |
> |
write_into_file(outfile, "p2", 0, 0 ); |
| 464 |
> |
if (args_info->rp2_given) |
| 465 |
> |
write_into_file(outfile, "rp2", 0, 0 ); |
| 466 |
> |
if (args_info->scd_given) |
| 467 |
> |
write_into_file(outfile, "scd", 0, 0 ); |
| 468 |
> |
if (args_info->density_given) |
| 469 |
> |
write_into_file(outfile, "density", 0, 0 ); |
| 470 |
> |
if (args_info->slab_density_given) |
| 471 |
> |
write_into_file(outfile, "slab_density", 0, 0 ); |
| 472 |
> |
if (args_info->p_angle_given) |
| 473 |
> |
write_into_file(outfile, "p_angle", 0, 0 ); |
| 474 |
> |
if (args_info->hxy_given) |
| 475 |
> |
write_into_file(outfile, "hxy", 0, 0 ); |
| 476 |
> |
if (args_info->rho_r_given) |
| 477 |
> |
write_into_file(outfile, "rho_r", 0, 0 ); |
| 478 |
> |
if (args_info->hullvol_given) |
| 479 |
> |
write_into_file(outfile, "hullvol", 0, 0 ); |
| 480 |
> |
|
| 481 |
> |
|
| 482 |
> |
i = EXIT_SUCCESS; |
| 483 |
> |
return i; |
| 484 |
> |
} |
| 485 |
> |
|
| 486 |
> |
int |
| 487 |
> |
cmdline_parser_file_save(const char *filename, struct gengetopt_args_info *args_info) |
| 488 |
> |
{ |
| 489 |
> |
FILE *outfile; |
| 490 |
> |
int i = 0; |
| 491 |
> |
|
| 492 |
> |
outfile = fopen(filename, "w"); |
| 493 |
> |
|
| 494 |
> |
if (!outfile) |
| 495 |
> |
{ |
| 496 |
> |
fprintf (stderr, "%s: cannot open file for writing: %s\n", CMDLINE_PARSER_PACKAGE, filename); |
| 497 |
> |
return EXIT_FAILURE; |
| 498 |
> |
} |
| 499 |
> |
|
| 500 |
> |
i = cmdline_parser_dump(outfile, args_info); |
| 501 |
> |
fclose (outfile); |
| 502 |
> |
|
| 503 |
> |
return i; |
| 504 |
> |
} |
| 505 |
> |
|
| 506 |
> |
void |
| 507 |
> |
cmdline_parser_free (struct gengetopt_args_info *args_info) |
| 508 |
> |
{ |
| 509 |
> |
cmdline_parser_release (args_info); |
| 510 |
> |
} |
| 511 |
> |
|
| 512 |
> |
/** @brief replacement of strdup, which is not standard */ |
| 513 |
|
char * |
| 514 |
|
gengetopt_strdup (const char *s) |
| 515 |
|
{ |
| 516 |
< |
char *result = (char*)malloc(strlen(s) + 1); |
| 516 |
> |
char *result = NULL; |
| 517 |
> |
if (!s) |
| 518 |
> |
return result; |
| 519 |
> |
|
| 520 |
> |
result = (char*)malloc(strlen(s) + 1); |
| 521 |
|
if (result == (char*)0) |
| 522 |
|
return (char*)0; |
| 523 |
|
strcpy(result, s); |
| 524 |
|
return result; |
| 525 |
|
} |
| 526 |
|
|
| 527 |
< |
int |
| 528 |
< |
cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_info) |
| 527 |
> |
static void |
| 528 |
> |
reset_group_staticProps(struct gengetopt_args_info *args_info) |
| 529 |
|
{ |
| 530 |
< |
int c; /* Character of the parsed option. */ |
| 531 |
< |
int missing_required_options = 0; |
| 77 |
< |
int staticProps_group_counter = 0; |
| 530 |
> |
if (! args_info->staticProps_group_counter) |
| 531 |
> |
return; |
| 532 |
|
|
| 533 |
< |
|
| 534 |
< |
args_info->help_given = 0 ; |
| 535 |
< |
args_info->version_given = 0 ; |
| 536 |
< |
args_info->input_given = 0 ; |
| 83 |
< |
args_info->output_given = 0 ; |
| 84 |
< |
args_info->frame_given = 0 ; |
| 85 |
< |
args_info->ndistebins_given = 0 ; |
| 86 |
< |
args_info->nanglebins_given = 0 ; |
| 87 |
< |
args_info->length_given = 0 ; |
| 88 |
< |
args_info->sele1_given = 0 ; |
| 89 |
< |
args_info->sele2_given = 0 ; |
| 533 |
> |
args_info->bo_given = 0 ; |
| 534 |
> |
args_info->bor_given = 0 ; |
| 535 |
> |
args_info->bad_given = 0 ; |
| 536 |
> |
args_info->count_given = 0 ; |
| 537 |
|
args_info->gofr_given = 0 ; |
| 538 |
+ |
args_info->gofz_given = 0 ; |
| 539 |
|
args_info->r_theta_given = 0 ; |
| 540 |
|
args_info->r_omega_given = 0 ; |
| 541 |
+ |
args_info->r_z_given = 0 ; |
| 542 |
|
args_info->theta_omega_given = 0 ; |
| 543 |
< |
args_info->xyz_given = 0 ; |
| 544 |
< |
#define clear_args() { \ |
| 545 |
< |
args_info->input_arg = NULL; \ |
| 546 |
< |
args_info->output_arg = NULL; \ |
| 547 |
< |
args_info->frame_arg = 1 ;\ |
| 548 |
< |
args_info->ndistebins_arg = 50 ;\ |
| 549 |
< |
args_info->nanglebins_arg = 50 ;\ |
| 550 |
< |
args_info->sele1_arg = NULL; \ |
| 551 |
< |
args_info->sele2_arg = NULL; \ |
| 543 |
> |
args_info->gxyz_given = 0 ; |
| 544 |
> |
args_info->twodgofr_given = 0 ; |
| 545 |
> |
args_info->p2_given = 0 ; |
| 546 |
> |
args_info->rp2_given = 0 ; |
| 547 |
> |
args_info->scd_given = 0 ; |
| 548 |
> |
args_info->density_given = 0 ; |
| 549 |
> |
args_info->slab_density_given = 0 ; |
| 550 |
> |
args_info->p_angle_given = 0 ; |
| 551 |
> |
args_info->hxy_given = 0 ; |
| 552 |
> |
args_info->rho_r_given = 0 ; |
| 553 |
> |
args_info->hullvol_given = 0 ; |
| 554 |
> |
|
| 555 |
> |
args_info->staticProps_group_counter = 0; |
| 556 |
|
} |
| 557 |
|
|
| 558 |
< |
clear_args(); |
| 558 |
> |
int |
| 559 |
> |
cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_info) |
| 560 |
> |
{ |
| 561 |
> |
return cmdline_parser2 (argc, argv, args_info, 0, 1, 1); |
| 562 |
> |
} |
| 563 |
|
|
| 564 |
+ |
int |
| 565 |
+ |
cmdline_parser_ext (int argc, char * const *argv, struct gengetopt_args_info *args_info, |
| 566 |
+ |
struct cmdline_parser_params *params) |
| 567 |
+ |
{ |
| 568 |
+ |
int result; |
| 569 |
+ |
result = cmdline_parser_internal (argc, argv, args_info, params, NULL); |
| 570 |
+ |
|
| 571 |
+ |
if (result == EXIT_FAILURE) |
| 572 |
+ |
{ |
| 573 |
+ |
cmdline_parser_free (args_info); |
| 574 |
+ |
exit (EXIT_FAILURE); |
| 575 |
+ |
} |
| 576 |
+ |
|
| 577 |
+ |
return result; |
| 578 |
+ |
} |
| 579 |
+ |
|
| 580 |
+ |
int |
| 581 |
+ |
cmdline_parser2 (int argc, char * const *argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required) |
| 582 |
+ |
{ |
| 583 |
+ |
int result; |
| 584 |
+ |
struct cmdline_parser_params params; |
| 585 |
+ |
|
| 586 |
+ |
params.override = override; |
| 587 |
+ |
params.initialize = initialize; |
| 588 |
+ |
params.check_required = check_required; |
| 589 |
+ |
params.check_ambiguity = 0; |
| 590 |
+ |
params.print_errors = 1; |
| 591 |
+ |
|
| 592 |
+ |
result = cmdline_parser_internal (argc, argv, args_info, ¶ms, NULL); |
| 593 |
+ |
|
| 594 |
+ |
if (result == EXIT_FAILURE) |
| 595 |
+ |
{ |
| 596 |
+ |
cmdline_parser_free (args_info); |
| 597 |
+ |
exit (EXIT_FAILURE); |
| 598 |
+ |
} |
| 599 |
+ |
|
| 600 |
+ |
return result; |
| 601 |
+ |
} |
| 602 |
+ |
|
| 603 |
+ |
int |
| 604 |
+ |
cmdline_parser_required (struct gengetopt_args_info *args_info, const char *prog_name) |
| 605 |
+ |
{ |
| 606 |
+ |
int result = EXIT_SUCCESS; |
| 607 |
+ |
|
| 608 |
+ |
if (cmdline_parser_required2(args_info, prog_name, NULL) > 0) |
| 609 |
+ |
result = EXIT_FAILURE; |
| 610 |
+ |
|
| 611 |
+ |
if (result == EXIT_FAILURE) |
| 612 |
+ |
{ |
| 613 |
+ |
cmdline_parser_free (args_info); |
| 614 |
+ |
exit (EXIT_FAILURE); |
| 615 |
+ |
} |
| 616 |
+ |
|
| 617 |
+ |
return result; |
| 618 |
+ |
} |
| 619 |
+ |
|
| 620 |
+ |
int |
| 621 |
+ |
cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error) |
| 622 |
+ |
{ |
| 623 |
+ |
int error = 0; |
| 624 |
+ |
|
| 625 |
+ |
/* checks for required options */ |
| 626 |
+ |
if (! args_info->input_given) |
| 627 |
+ |
{ |
| 628 |
+ |
fprintf (stderr, "%s: '--input' ('-i') option required%s\n", prog_name, (additional_error ? additional_error : "")); |
| 629 |
+ |
error = 1; |
| 630 |
+ |
} |
| 631 |
+ |
|
| 632 |
+ |
if (args_info->staticProps_group_counter == 0) |
| 633 |
+ |
{ |
| 634 |
+ |
fprintf (stderr, "%s: %d options of group staticProps were given. One is required.%s\n", prog_name, args_info->staticProps_group_counter, (additional_error ? additional_error : "")); |
| 635 |
+ |
error = 1; |
| 636 |
+ |
} |
| 637 |
+ |
|
| 638 |
+ |
|
| 639 |
+ |
/* checks for dependences among options */ |
| 640 |
+ |
|
| 641 |
+ |
return error; |
| 642 |
+ |
} |
| 643 |
+ |
|
| 644 |
+ |
|
| 645 |
+ |
static char *package_name = 0; |
| 646 |
+ |
|
| 647 |
+ |
/** |
| 648 |
+ |
* @brief updates an option |
| 649 |
+ |
* @param field the generic pointer to the field to update |
| 650 |
+ |
* @param orig_field the pointer to the orig field |
| 651 |
+ |
* @param field_given the pointer to the number of occurrence of this option |
| 652 |
+ |
* @param prev_given the pointer to the number of occurrence already seen |
| 653 |
+ |
* @param value the argument for this option (if null no arg was specified) |
| 654 |
+ |
* @param possible_values the possible values for this option (if specified) |
| 655 |
+ |
* @param default_value the default value (in case the option only accepts fixed values) |
| 656 |
+ |
* @param arg_type the type of this option |
| 657 |
+ |
* @param check_ambiguity @see cmdline_parser_params.check_ambiguity |
| 658 |
+ |
* @param override @see cmdline_parser_params.override |
| 659 |
+ |
* @param no_free whether to free a possible previous value |
| 660 |
+ |
* @param multiple_option whether this is a multiple option |
| 661 |
+ |
* @param long_opt the corresponding long option |
| 662 |
+ |
* @param short_opt the corresponding short option (or '-' if none) |
| 663 |
+ |
* @param additional_error possible further error specification |
| 664 |
+ |
*/ |
| 665 |
+ |
static |
| 666 |
+ |
int update_arg(void *field, char **orig_field, |
| 667 |
+ |
unsigned int *field_given, unsigned int *prev_given, |
| 668 |
+ |
char *value, char *possible_values[], const char *default_value, |
| 669 |
+ |
cmdline_parser_arg_type arg_type, |
| 670 |
+ |
int check_ambiguity, int override, |
| 671 |
+ |
int no_free, int multiple_option, |
| 672 |
+ |
const char *long_opt, char short_opt, |
| 673 |
+ |
const char *additional_error) |
| 674 |
+ |
{ |
| 675 |
+ |
char *stop_char = 0; |
| 676 |
+ |
const char *val = value; |
| 677 |
+ |
int found; |
| 678 |
+ |
char **string_field; |
| 679 |
+ |
|
| 680 |
+ |
stop_char = 0; |
| 681 |
+ |
found = 0; |
| 682 |
+ |
|
| 683 |
+ |
if (!multiple_option && prev_given && (*prev_given || (check_ambiguity && *field_given))) |
| 684 |
+ |
{ |
| 685 |
+ |
if (short_opt != '-') |
| 686 |
+ |
fprintf (stderr, "%s: `--%s' (`-%c') option given more than once%s\n", |
| 687 |
+ |
package_name, long_opt, short_opt, |
| 688 |
+ |
(additional_error ? additional_error : "")); |
| 689 |
+ |
else |
| 690 |
+ |
fprintf (stderr, "%s: `--%s' option given more than once%s\n", |
| 691 |
+ |
package_name, long_opt, |
| 692 |
+ |
(additional_error ? additional_error : "")); |
| 693 |
+ |
return 1; /* failure */ |
| 694 |
+ |
} |
| 695 |
+ |
|
| 696 |
+ |
|
| 697 |
+ |
if (field_given && *field_given && ! override) |
| 698 |
+ |
return 0; |
| 699 |
+ |
if (prev_given) |
| 700 |
+ |
(*prev_given)++; |
| 701 |
+ |
if (field_given) |
| 702 |
+ |
(*field_given)++; |
| 703 |
+ |
if (possible_values) |
| 704 |
+ |
val = possible_values[found]; |
| 705 |
+ |
|
| 706 |
+ |
switch(arg_type) { |
| 707 |
+ |
case ARG_INT: |
| 708 |
+ |
if (val) *((int *)field) = strtol (val, &stop_char, 0); |
| 709 |
+ |
break; |
| 710 |
+ |
case ARG_DOUBLE: |
| 711 |
+ |
if (val) *((double *)field) = strtod (val, &stop_char); |
| 712 |
+ |
break; |
| 713 |
+ |
case ARG_STRING: |
| 714 |
+ |
if (val) { |
| 715 |
+ |
string_field = (char **)field; |
| 716 |
+ |
if (!no_free && *string_field) |
| 717 |
+ |
free (*string_field); /* free previous string */ |
| 718 |
+ |
*string_field = gengetopt_strdup (val); |
| 719 |
+ |
} |
| 720 |
+ |
break; |
| 721 |
+ |
default: |
| 722 |
+ |
break; |
| 723 |
+ |
}; |
| 724 |
+ |
|
| 725 |
+ |
/* check numeric conversion */ |
| 726 |
+ |
switch(arg_type) { |
| 727 |
+ |
case ARG_INT: |
| 728 |
+ |
case ARG_DOUBLE: |
| 729 |
+ |
if (val && !(stop_char && *stop_char == '\0')) { |
| 730 |
+ |
fprintf(stderr, "%s: invalid numeric value: %s\n", package_name, val); |
| 731 |
+ |
return 1; /* failure */ |
| 732 |
+ |
} |
| 733 |
+ |
break; |
| 734 |
+ |
default: |
| 735 |
+ |
; |
| 736 |
+ |
}; |
| 737 |
+ |
|
| 738 |
+ |
/* store the original value */ |
| 739 |
+ |
switch(arg_type) { |
| 740 |
+ |
case ARG_NO: |
| 741 |
+ |
break; |
| 742 |
+ |
default: |
| 743 |
+ |
if (value && orig_field) { |
| 744 |
+ |
if (no_free) { |
| 745 |
+ |
*orig_field = value; |
| 746 |
+ |
} else { |
| 747 |
+ |
if (*orig_field) |
| 748 |
+ |
free (*orig_field); /* free previous string */ |
| 749 |
+ |
*orig_field = gengetopt_strdup (value); |
| 750 |
+ |
} |
| 751 |
+ |
} |
| 752 |
+ |
}; |
| 753 |
+ |
|
| 754 |
+ |
return 0; /* OK */ |
| 755 |
+ |
} |
| 756 |
+ |
|
| 757 |
+ |
|
| 758 |
+ |
int |
| 759 |
+ |
cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_info *args_info, |
| 760 |
+ |
struct cmdline_parser_params *params, const char *additional_error) |
| 761 |
+ |
{ |
| 762 |
+ |
int c; /* Character of the parsed option. */ |
| 763 |
+ |
|
| 764 |
+ |
int error = 0; |
| 765 |
+ |
struct gengetopt_args_info local_args_info; |
| 766 |
+ |
|
| 767 |
+ |
int override; |
| 768 |
+ |
int initialize; |
| 769 |
+ |
int check_required; |
| 770 |
+ |
int check_ambiguity; |
| 771 |
+ |
|
| 772 |
+ |
package_name = argv[0]; |
| 773 |
+ |
|
| 774 |
+ |
override = params->override; |
| 775 |
+ |
initialize = params->initialize; |
| 776 |
+ |
check_required = params->check_required; |
| 777 |
+ |
check_ambiguity = params->check_ambiguity; |
| 778 |
+ |
|
| 779 |
+ |
if (initialize) |
| 780 |
+ |
cmdline_parser_init (args_info); |
| 781 |
+ |
|
| 782 |
+ |
cmdline_parser_init (&local_args_info); |
| 783 |
+ |
|
| 784 |
|
optarg = 0; |
| 785 |
< |
optind = 1; |
| 786 |
< |
opterr = 1; |
| 785 |
> |
optind = 0; |
| 786 |
> |
opterr = params->print_errors; |
| 787 |
|
optopt = '?'; |
| 788 |
|
|
| 789 |
|
while (1) |
| 790 |
|
{ |
| 791 |
|
int option_index = 0; |
| 115 |
– |
char *stop_char; |
| 792 |
|
|
| 793 |
|
static struct option long_options[] = { |
| 794 |
|
{ "help", 0, NULL, 'h' }, |
| 795 |
|
{ "version", 0, NULL, 'V' }, |
| 796 |
|
{ "input", 1, NULL, 'i' }, |
| 797 |
|
{ "output", 1, NULL, 'o' }, |
| 798 |
< |
{ "frame", 1, NULL, 'n' }, |
| 799 |
< |
{ "ndistebins", 1, NULL, 'd' }, |
| 798 |
> |
{ "step", 1, NULL, 'n' }, |
| 799 |
> |
{ "nbins", 1, NULL, 'b' }, |
| 800 |
> |
{ "nbins_x", 1, NULL, 'x' }, |
| 801 |
> |
{ "nbins_y", 1, NULL, 'y' }, |
| 802 |
> |
{ "nbins_z", 1, NULL, 0 }, |
| 803 |
|
{ "nanglebins", 1, NULL, 'a' }, |
| 804 |
< |
{ "length", 1, NULL, 'l' }, |
| 804 |
> |
{ "rcut", 1, NULL, 'c' }, |
| 805 |
> |
{ "dz", 1, NULL, 0 }, |
| 806 |
> |
{ "length", 1, NULL, 0 }, |
| 807 |
> |
{ "zlength", 1, NULL, 0 }, |
| 808 |
> |
{ "zoffset", 1, NULL, 'z' }, |
| 809 |
|
{ "sele1", 1, NULL, 0 }, |
| 810 |
|
{ "sele2", 1, NULL, 0 }, |
| 811 |
< |
{ "gofr", 0, NULL, 0 }, |
| 811 |
> |
{ "sele3", 1, NULL, 0 }, |
| 812 |
> |
{ "refsele", 1, NULL, 0 }, |
| 813 |
> |
{ "comsele", 1, NULL, 0 }, |
| 814 |
> |
{ "molname", 1, NULL, 0 }, |
| 815 |
> |
{ "begin", 1, NULL, 0 }, |
| 816 |
> |
{ "end", 1, NULL, 0 }, |
| 817 |
> |
{ "radius", 1, NULL, 0 }, |
| 818 |
> |
{ "bo", 0, NULL, 0 }, |
| 819 |
> |
{ "bor", 0, NULL, 0 }, |
| 820 |
> |
{ "bad", 0, NULL, 0 }, |
| 821 |
> |
{ "count", 0, NULL, 0 }, |
| 822 |
> |
{ "gofr", 0, NULL, 'g' }, |
| 823 |
> |
{ "gofz", 0, NULL, 0 }, |
| 824 |
|
{ "r_theta", 0, NULL, 0 }, |
| 825 |
|
{ "r_omega", 0, NULL, 0 }, |
| 826 |
+ |
{ "r_z", 0, NULL, 0 }, |
| 827 |
|
{ "theta_omega", 0, NULL, 0 }, |
| 828 |
< |
{ "xyz", 0, NULL, 0 }, |
| 828 |
> |
{ "gxyz", 0, NULL, 0 }, |
| 829 |
> |
{ "twodgofr", 0, NULL, 0 }, |
| 830 |
> |
{ "p2", 0, NULL, 'p' }, |
| 831 |
> |
{ "rp2", 0, NULL, 0 }, |
| 832 |
> |
{ "scd", 0, NULL, 's' }, |
| 833 |
> |
{ "density", 0, NULL, 'd' }, |
| 834 |
> |
{ "slab_density", 0, NULL, 0 }, |
| 835 |
> |
{ "p_angle", 0, NULL, 0 }, |
| 836 |
> |
{ "hxy", 0, NULL, 0 }, |
| 837 |
> |
{ "rho_r", 0, NULL, 0 }, |
| 838 |
> |
{ "hullvol", 0, NULL, 0 }, |
| 839 |
|
{ NULL, 0, NULL, 0 } |
| 840 |
|
}; |
| 841 |
|
|
| 842 |
< |
stop_char = 0; |
| 137 |
< |
c = getopt_long (argc, argv, "hVi:o:n:d:a:l:", long_options, &option_index); |
| 842 |
> |
c = getopt_long (argc, argv, "hVi:o:n:b:x:y:a:c:z:gpsd", long_options, &option_index); |
| 843 |
|
|
| 844 |
|
if (c == -1) break; /* Exit from `while (1)' loop. */ |
| 845 |
|
|
| 846 |
|
switch (c) |
| 847 |
|
{ |
| 848 |
|
case 'h': /* Print help and exit. */ |
| 144 |
– |
clear_args (); |
| 849 |
|
cmdline_parser_print_help (); |
| 850 |
+ |
cmdline_parser_free (&local_args_info); |
| 851 |
|
exit (EXIT_SUCCESS); |
| 852 |
|
|
| 853 |
|
case 'V': /* Print version and exit. */ |
| 149 |
– |
clear_args (); |
| 854 |
|
cmdline_parser_print_version (); |
| 855 |
+ |
cmdline_parser_free (&local_args_info); |
| 856 |
|
exit (EXIT_SUCCESS); |
| 857 |
|
|
| 858 |
|
case 'i': /* input dump file. */ |
| 859 |
< |
if (args_info->input_given) |
| 860 |
< |
{ |
| 861 |
< |
fprintf (stderr, "%s: `--input' (`-i') option given more than once\n", CMDLINE_PARSER_PACKAGE); |
| 862 |
< |
clear_args (); |
| 863 |
< |
exit (EXIT_FAILURE); |
| 864 |
< |
} |
| 865 |
< |
args_info->input_given = 1; |
| 866 |
< |
args_info->input_arg = gengetopt_strdup (optarg); |
| 859 |
> |
|
| 860 |
> |
|
| 861 |
> |
if (update_arg( (void *)&(args_info->input_arg), |
| 862 |
> |
&(args_info->input_orig), &(args_info->input_given), |
| 863 |
> |
&(local_args_info.input_given), optarg, 0, 0, ARG_STRING, |
| 864 |
> |
check_ambiguity, override, 0, 0, |
| 865 |
> |
"input", 'i', |
| 866 |
> |
additional_error)) |
| 867 |
> |
goto failure; |
| 868 |
> |
|
| 869 |
|
break; |
| 163 |
– |
|
| 870 |
|
case 'o': /* output file name. */ |
| 871 |
< |
if (args_info->output_given) |
| 872 |
< |
{ |
| 873 |
< |
fprintf (stderr, "%s: `--output' (`-o') option given more than once\n", CMDLINE_PARSER_PACKAGE); |
| 874 |
< |
clear_args (); |
| 875 |
< |
exit (EXIT_FAILURE); |
| 876 |
< |
} |
| 877 |
< |
args_info->output_given = 1; |
| 878 |
< |
args_info->output_arg = gengetopt_strdup (optarg); |
| 871 |
> |
|
| 872 |
> |
|
| 873 |
> |
if (update_arg( (void *)&(args_info->output_arg), |
| 874 |
> |
&(args_info->output_orig), &(args_info->output_given), |
| 875 |
> |
&(local_args_info.output_given), optarg, 0, 0, ARG_STRING, |
| 876 |
> |
check_ambiguity, override, 0, 0, |
| 877 |
> |
"output", 'o', |
| 878 |
> |
additional_error)) |
| 879 |
> |
goto failure; |
| 880 |
> |
|
| 881 |
|
break; |
| 882 |
< |
|
| 883 |
< |
case 'n': /* print every n frame. */ |
| 884 |
< |
if (args_info->frame_given) |
| 885 |
< |
{ |
| 886 |
< |
fprintf (stderr, "%s: `--frame' (`-n') option given more than once\n", CMDLINE_PARSER_PACKAGE); |
| 887 |
< |
clear_args (); |
| 888 |
< |
exit (EXIT_FAILURE); |
| 889 |
< |
} |
| 890 |
< |
args_info->frame_given = 1; |
| 891 |
< |
args_info->frame_arg = strtol (optarg,&stop_char,0); |
| 882 |
> |
case 'n': /* process every n frame. */ |
| 883 |
> |
|
| 884 |
> |
|
| 885 |
> |
if (update_arg( (void *)&(args_info->step_arg), |
| 886 |
> |
&(args_info->step_orig), &(args_info->step_given), |
| 887 |
> |
&(local_args_info.step_given), optarg, 0, "1", ARG_INT, |
| 888 |
> |
check_ambiguity, override, 0, 0, |
| 889 |
> |
"step", 'n', |
| 890 |
> |
additional_error)) |
| 891 |
> |
goto failure; |
| 892 |
> |
|
| 893 |
|
break; |
| 894 |
< |
|
| 895 |
< |
case 'd': /* number of bins for distance. */ |
| 896 |
< |
if (args_info->ndistebins_given) |
| 897 |
< |
{ |
| 898 |
< |
fprintf (stderr, "%s: `--ndistebins' (`-d') option given more than once\n", CMDLINE_PARSER_PACKAGE); |
| 899 |
< |
clear_args (); |
| 900 |
< |
exit (EXIT_FAILURE); |
| 901 |
< |
} |
| 902 |
< |
args_info->ndistebins_given = 1; |
| 903 |
< |
args_info->ndistebins_arg = strtol (optarg,&stop_char,0); |
| 894 |
> |
case 'b': /* number of bins (general purpose). */ |
| 895 |
> |
|
| 896 |
> |
|
| 897 |
> |
if (update_arg( (void *)&(args_info->nbins_arg), |
| 898 |
> |
&(args_info->nbins_orig), &(args_info->nbins_given), |
| 899 |
> |
&(local_args_info.nbins_given), optarg, 0, "100", ARG_INT, |
| 900 |
> |
check_ambiguity, override, 0, 0, |
| 901 |
> |
"nbins", 'b', |
| 902 |
> |
additional_error)) |
| 903 |
> |
goto failure; |
| 904 |
> |
|
| 905 |
|
break; |
| 906 |
< |
|
| 906 |
> |
case 'x': /* number of bins in x axis. */ |
| 907 |
> |
|
| 908 |
> |
|
| 909 |
> |
if (update_arg( (void *)&(args_info->nbins_x_arg), |
| 910 |
> |
&(args_info->nbins_x_orig), &(args_info->nbins_x_given), |
| 911 |
> |
&(local_args_info.nbins_x_given), optarg, 0, "100", ARG_INT, |
| 912 |
> |
check_ambiguity, override, 0, 0, |
| 913 |
> |
"nbins_x", 'x', |
| 914 |
> |
additional_error)) |
| 915 |
> |
goto failure; |
| 916 |
> |
|
| 917 |
> |
break; |
| 918 |
> |
case 'y': /* number of bins in y axis. */ |
| 919 |
> |
|
| 920 |
> |
|
| 921 |
> |
if (update_arg( (void *)&(args_info->nbins_y_arg), |
| 922 |
> |
&(args_info->nbins_y_orig), &(args_info->nbins_y_given), |
| 923 |
> |
&(local_args_info.nbins_y_given), optarg, 0, "100", ARG_INT, |
| 924 |
> |
check_ambiguity, override, 0, 0, |
| 925 |
> |
"nbins_y", 'y', |
| 926 |
> |
additional_error)) |
| 927 |
> |
goto failure; |
| 928 |
> |
|
| 929 |
> |
break; |
| 930 |
|
case 'a': /* number of bins for cos(angle). */ |
| 931 |
< |
if (args_info->nanglebins_given) |
| 932 |
< |
{ |
| 933 |
< |
fprintf (stderr, "%s: `--nanglebins' (`-a') option given more than once\n", CMDLINE_PARSER_PACKAGE); |
| 934 |
< |
clear_args (); |
| 935 |
< |
exit (EXIT_FAILURE); |
| 936 |
< |
} |
| 937 |
< |
args_info->nanglebins_given = 1; |
| 938 |
< |
args_info->nanglebins_arg = strtol (optarg,&stop_char,0); |
| 931 |
> |
|
| 932 |
> |
|
| 933 |
> |
if (update_arg( (void *)&(args_info->nanglebins_arg), |
| 934 |
> |
&(args_info->nanglebins_orig), &(args_info->nanglebins_given), |
| 935 |
> |
&(local_args_info.nanglebins_given), optarg, 0, "50", ARG_INT, |
| 936 |
> |
check_ambiguity, override, 0, 0, |
| 937 |
> |
"nanglebins", 'a', |
| 938 |
> |
additional_error)) |
| 939 |
> |
goto failure; |
| 940 |
> |
|
| 941 |
|
break; |
| 942 |
< |
|
| 943 |
< |
case 'l': /* maximum length. */ |
| 944 |
< |
if (args_info->length_given) |
| 945 |
< |
{ |
| 946 |
< |
fprintf (stderr, "%s: `--length' (`-l') option given more than once\n", CMDLINE_PARSER_PACKAGE); |
| 947 |
< |
clear_args (); |
| 948 |
< |
exit (EXIT_FAILURE); |
| 949 |
< |
} |
| 950 |
< |
args_info->length_given = 1; |
| 951 |
< |
args_info->length_arg = strtod (optarg, NULL); |
| 942 |
> |
case 'c': /* cutoff radius (rcut). */ |
| 943 |
> |
|
| 944 |
> |
|
| 945 |
> |
if (update_arg( (void *)&(args_info->rcut_arg), |
| 946 |
> |
&(args_info->rcut_orig), &(args_info->rcut_given), |
| 947 |
> |
&(local_args_info.rcut_given), optarg, 0, 0, ARG_DOUBLE, |
| 948 |
> |
check_ambiguity, override, 0, 0, |
| 949 |
> |
"rcut", 'c', |
| 950 |
> |
additional_error)) |
| 951 |
> |
goto failure; |
| 952 |
> |
|
| 953 |
|
break; |
| 954 |
+ |
case 'z': /* Where to set the zero for the slab_density calculation. */ |
| 955 |
+ |
|
| 956 |
+ |
|
| 957 |
+ |
if (update_arg( (void *)&(args_info->zoffset_arg), |
| 958 |
+ |
&(args_info->zoffset_orig), &(args_info->zoffset_given), |
| 959 |
+ |
&(local_args_info.zoffset_given), optarg, 0, "0", ARG_DOUBLE, |
| 960 |
+ |
check_ambiguity, override, 0, 0, |
| 961 |
+ |
"zoffset", 'z', |
| 962 |
+ |
additional_error)) |
| 963 |
+ |
goto failure; |
| 964 |
+ |
|
| 965 |
+ |
break; |
| 966 |
+ |
case 'g': /* g(r). */ |
| 967 |
+ |
|
| 968 |
+ |
if (args_info->staticProps_group_counter && override) |
| 969 |
+ |
reset_group_staticProps (args_info); |
| 970 |
+ |
args_info->staticProps_group_counter += 1; |
| 971 |
+ |
|
| 972 |
+ |
if (update_arg( 0 , |
| 973 |
+ |
0 , &(args_info->gofr_given), |
| 974 |
+ |
&(local_args_info.gofr_given), optarg, 0, 0, ARG_NO, |
| 975 |
+ |
check_ambiguity, override, 0, 0, |
| 976 |
+ |
"gofr", 'g', |
| 977 |
+ |
additional_error)) |
| 978 |
+ |
goto failure; |
| 979 |
+ |
|
| 980 |
+ |
break; |
| 981 |
+ |
case 'p': /* p2 order parameter (--sele1 and --sele2 must be specified). */ |
| 982 |
+ |
|
| 983 |
+ |
if (args_info->staticProps_group_counter && override) |
| 984 |
+ |
reset_group_staticProps (args_info); |
| 985 |
+ |
args_info->staticProps_group_counter += 1; |
| 986 |
+ |
|
| 987 |
+ |
if (update_arg( 0 , |
| 988 |
+ |
0 , &(args_info->p2_given), |
| 989 |
+ |
&(local_args_info.p2_given), optarg, 0, 0, ARG_NO, |
| 990 |
+ |
check_ambiguity, override, 0, 0, |
| 991 |
+ |
"p2", 'p', |
| 992 |
+ |
additional_error)) |
| 993 |
+ |
goto failure; |
| 994 |
+ |
|
| 995 |
+ |
break; |
| 996 |
+ |
case 's': /* scd order parameter (either --sele1, --sele2, --sele3 are specified or --molname, --begin, --end are specified). */ |
| 997 |
+ |
|
| 998 |
+ |
if (args_info->staticProps_group_counter && override) |
| 999 |
+ |
reset_group_staticProps (args_info); |
| 1000 |
+ |
args_info->staticProps_group_counter += 1; |
| 1001 |
+ |
|
| 1002 |
+ |
if (update_arg( 0 , |
| 1003 |
+ |
0 , &(args_info->scd_given), |
| 1004 |
+ |
&(local_args_info.scd_given), optarg, 0, 0, ARG_NO, |
| 1005 |
+ |
check_ambiguity, override, 0, 0, |
| 1006 |
+ |
"scd", 's', |
| 1007 |
+ |
additional_error)) |
| 1008 |
+ |
goto failure; |
| 1009 |
+ |
|
| 1010 |
+ |
break; |
| 1011 |
+ |
case 'd': /* density plot. */ |
| 1012 |
+ |
|
| 1013 |
+ |
if (args_info->staticProps_group_counter && override) |
| 1014 |
+ |
reset_group_staticProps (args_info); |
| 1015 |
+ |
args_info->staticProps_group_counter += 1; |
| 1016 |
+ |
|
| 1017 |
+ |
if (update_arg( 0 , |
| 1018 |
+ |
0 , &(args_info->density_given), |
| 1019 |
+ |
&(local_args_info.density_given), optarg, 0, 0, ARG_NO, |
| 1020 |
+ |
check_ambiguity, override, 0, 0, |
| 1021 |
+ |
"density", 'd', |
| 1022 |
+ |
additional_error)) |
| 1023 |
+ |
goto failure; |
| 1024 |
+ |
|
| 1025 |
+ |
break; |
| 1026 |
|
|
| 219 |
– |
|
| 1027 |
|
case 0: /* Long option with no short option */ |
| 1028 |
< |
/* select first stuntdouble set. */ |
| 1029 |
< |
if (strcmp (long_options[option_index].name, "sele1") == 0) |
| 1028 |
> |
/* number of bins in z axis. */ |
| 1029 |
> |
if (strcmp (long_options[option_index].name, "nbins_z") == 0) |
| 1030 |
|
{ |
| 1031 |
< |
if (args_info->sele1_given) |
| 1032 |
< |
{ |
| 1033 |
< |
fprintf (stderr, "%s: `--sele1' option given more than once\n", CMDLINE_PARSER_PACKAGE); |
| 1034 |
< |
clear_args (); |
| 1035 |
< |
exit (EXIT_FAILURE); |
| 1036 |
< |
} |
| 1037 |
< |
args_info->sele1_given = 1; |
| 1038 |
< |
args_info->sele1_arg = gengetopt_strdup (optarg); |
| 1039 |
< |
break; |
| 1031 |
> |
|
| 1032 |
> |
|
| 1033 |
> |
if (update_arg( (void *)&(args_info->nbins_z_arg), |
| 1034 |
> |
&(args_info->nbins_z_orig), &(args_info->nbins_z_given), |
| 1035 |
> |
&(local_args_info.nbins_z_given), optarg, 0, "100", ARG_INT, |
| 1036 |
> |
check_ambiguity, override, 0, 0, |
| 1037 |
> |
"nbins_z", '-', |
| 1038 |
> |
additional_error)) |
| 1039 |
> |
goto failure; |
| 1040 |
> |
|
| 1041 |
|
} |
| 1042 |
+ |
/* slab width (dz). */ |
| 1043 |
+ |
else if (strcmp (long_options[option_index].name, "dz") == 0) |
| 1044 |
+ |
{ |
| 1045 |
|
|
| 1046 |
< |
/* select second stuntdouble set. */ |
| 1046 |
> |
|
| 1047 |
> |
if (update_arg( (void *)&(args_info->dz_arg), |
| 1048 |
> |
&(args_info->dz_orig), &(args_info->dz_given), |
| 1049 |
> |
&(local_args_info.dz_given), optarg, 0, 0, ARG_DOUBLE, |
| 1050 |
> |
check_ambiguity, override, 0, 0, |
| 1051 |
> |
"dz", '-', |
| 1052 |
> |
additional_error)) |
| 1053 |
> |
goto failure; |
| 1054 |
> |
|
| 1055 |
> |
} |
| 1056 |
> |
/* maximum length (Defaults to 1/2 smallest length of first frame). */ |
| 1057 |
> |
else if (strcmp (long_options[option_index].name, "length") == 0) |
| 1058 |
> |
{ |
| 1059 |
> |
|
| 1060 |
> |
|
| 1061 |
> |
if (update_arg( (void *)&(args_info->length_arg), |
| 1062 |
> |
&(args_info->length_orig), &(args_info->length_given), |
| 1063 |
> |
&(local_args_info.length_given), optarg, 0, 0, ARG_DOUBLE, |
| 1064 |
> |
check_ambiguity, override, 0, 0, |
| 1065 |
> |
"length", '-', |
| 1066 |
> |
additional_error)) |
| 1067 |
> |
goto failure; |
| 1068 |
> |
|
| 1069 |
> |
} |
| 1070 |
> |
/* maximum length (Defaults to 1/2 smallest length of first frame). */ |
| 1071 |
> |
else if (strcmp (long_options[option_index].name, "zlength") == 0) |
| 1072 |
> |
{ |
| 1073 |
> |
|
| 1074 |
> |
|
| 1075 |
> |
if (update_arg( (void *)&(args_info->zlength_arg), |
| 1076 |
> |
&(args_info->zlength_orig), &(args_info->zlength_given), |
| 1077 |
> |
&(local_args_info.zlength_given), optarg, 0, 0, ARG_DOUBLE, |
| 1078 |
> |
check_ambiguity, override, 0, 0, |
| 1079 |
> |
"zlength", '-', |
| 1080 |
> |
additional_error)) |
| 1081 |
> |
goto failure; |
| 1082 |
> |
|
| 1083 |
> |
} |
| 1084 |
> |
/* select the first stuntdouble set. */ |
| 1085 |
> |
else if (strcmp (long_options[option_index].name, "sele1") == 0) |
| 1086 |
> |
{ |
| 1087 |
> |
|
| 1088 |
> |
|
| 1089 |
> |
if (update_arg( (void *)&(args_info->sele1_arg), |
| 1090 |
> |
&(args_info->sele1_orig), &(args_info->sele1_given), |
| 1091 |
> |
&(local_args_info.sele1_given), optarg, 0, 0, ARG_STRING, |
| 1092 |
> |
check_ambiguity, override, 0, 0, |
| 1093 |
> |
"sele1", '-', |
| 1094 |
> |
additional_error)) |
| 1095 |
> |
goto failure; |
| 1096 |
> |
|
| 1097 |
> |
} |
| 1098 |
> |
/* select the second stuntdouble set. */ |
| 1099 |
|
else if (strcmp (long_options[option_index].name, "sele2") == 0) |
| 1100 |
|
{ |
| 1101 |
< |
if (args_info->sele2_given) |
| 1102 |
< |
{ |
| 1103 |
< |
fprintf (stderr, "%s: `--sele2' option given more than once\n", CMDLINE_PARSER_PACKAGE); |
| 1104 |
< |
clear_args (); |
| 1105 |
< |
exit (EXIT_FAILURE); |
| 1106 |
< |
} |
| 1107 |
< |
args_info->sele2_given = 1; |
| 1108 |
< |
args_info->sele2_arg = gengetopt_strdup (optarg); |
| 1109 |
< |
break; |
| 1101 |
> |
|
| 1102 |
> |
|
| 1103 |
> |
if (update_arg( (void *)&(args_info->sele2_arg), |
| 1104 |
> |
&(args_info->sele2_orig), &(args_info->sele2_given), |
| 1105 |
> |
&(local_args_info.sele2_given), optarg, 0, 0, ARG_STRING, |
| 1106 |
> |
check_ambiguity, override, 0, 0, |
| 1107 |
> |
"sele2", '-', |
| 1108 |
> |
additional_error)) |
| 1109 |
> |
goto failure; |
| 1110 |
> |
|
| 1111 |
|
} |
| 1112 |
+ |
/* select the third stuntdouble set. */ |
| 1113 |
+ |
else if (strcmp (long_options[option_index].name, "sele3") == 0) |
| 1114 |
+ |
{ |
| 1115 |
|
|
| 1116 |
< |
/* g(r). */ |
| 1117 |
< |
else if (strcmp (long_options[option_index].name, "gofr") == 0) |
| 1116 |
> |
|
| 1117 |
> |
if (update_arg( (void *)&(args_info->sele3_arg), |
| 1118 |
> |
&(args_info->sele3_orig), &(args_info->sele3_given), |
| 1119 |
> |
&(local_args_info.sele3_given), optarg, 0, 0, ARG_STRING, |
| 1120 |
> |
check_ambiguity, override, 0, 0, |
| 1121 |
> |
"sele3", '-', |
| 1122 |
> |
additional_error)) |
| 1123 |
> |
goto failure; |
| 1124 |
> |
|
| 1125 |
> |
} |
| 1126 |
> |
/* select reference (use and only use with --gxyz). */ |
| 1127 |
> |
else if (strcmp (long_options[option_index].name, "refsele") == 0) |
| 1128 |
|
{ |
| 252 |
– |
if (args_info->gofr_given) |
| 253 |
– |
{ |
| 254 |
– |
fprintf (stderr, "%s: `--gofr' option given more than once\n", CMDLINE_PARSER_PACKAGE); |
| 255 |
– |
clear_args (); |
| 256 |
– |
exit (EXIT_FAILURE); |
| 257 |
– |
} |
| 258 |
– |
args_info->gofr_given = 1; staticProps_group_counter += 1; |
| 1129 |
|
|
| 1130 |
< |
break; |
| 1130 |
> |
|
| 1131 |
> |
if (update_arg( (void *)&(args_info->refsele_arg), |
| 1132 |
> |
&(args_info->refsele_orig), &(args_info->refsele_given), |
| 1133 |
> |
&(local_args_info.refsele_given), optarg, 0, 0, ARG_STRING, |
| 1134 |
> |
check_ambiguity, override, 0, 0, |
| 1135 |
> |
"refsele", '-', |
| 1136 |
> |
additional_error)) |
| 1137 |
> |
goto failure; |
| 1138 |
> |
|
| 1139 |
> |
} |
| 1140 |
> |
/* select stunt doubles for center-of-mass reference point. */ |
| 1141 |
> |
else if (strcmp (long_options[option_index].name, "comsele") == 0) |
| 1142 |
> |
{ |
| 1143 |
> |
|
| 1144 |
> |
|
| 1145 |
> |
if (update_arg( (void *)&(args_info->comsele_arg), |
| 1146 |
> |
&(args_info->comsele_orig), &(args_info->comsele_given), |
| 1147 |
> |
&(local_args_info.comsele_given), optarg, 0, 0, ARG_STRING, |
| 1148 |
> |
check_ambiguity, override, 0, 0, |
| 1149 |
> |
"comsele", '-', |
| 1150 |
> |
additional_error)) |
| 1151 |
> |
goto failure; |
| 1152 |
> |
|
| 1153 |
> |
} |
| 1154 |
> |
/* molecule name. */ |
| 1155 |
> |
else if (strcmp (long_options[option_index].name, "molname") == 0) |
| 1156 |
> |
{ |
| 1157 |
> |
|
| 1158 |
> |
|
| 1159 |
> |
if (update_arg( (void *)&(args_info->molname_arg), |
| 1160 |
> |
&(args_info->molname_orig), &(args_info->molname_given), |
| 1161 |
> |
&(local_args_info.molname_given), optarg, 0, 0, ARG_STRING, |
| 1162 |
> |
check_ambiguity, override, 0, 0, |
| 1163 |
> |
"molname", '-', |
| 1164 |
> |
additional_error)) |
| 1165 |
> |
goto failure; |
| 1166 |
> |
|
| 1167 |
> |
} |
| 1168 |
> |
/* begin internal index. */ |
| 1169 |
> |
else if (strcmp (long_options[option_index].name, "begin") == 0) |
| 1170 |
> |
{ |
| 1171 |
> |
|
| 1172 |
> |
|
| 1173 |
> |
if (update_arg( (void *)&(args_info->begin_arg), |
| 1174 |
> |
&(args_info->begin_orig), &(args_info->begin_given), |
| 1175 |
> |
&(local_args_info.begin_given), optarg, 0, 0, ARG_INT, |
| 1176 |
> |
check_ambiguity, override, 0, 0, |
| 1177 |
> |
"begin", '-', |
| 1178 |
> |
additional_error)) |
| 1179 |
> |
goto failure; |
| 1180 |
> |
|
| 1181 |
> |
} |
| 1182 |
> |
/* end internal index. */ |
| 1183 |
> |
else if (strcmp (long_options[option_index].name, "end") == 0) |
| 1184 |
> |
{ |
| 1185 |
> |
|
| 1186 |
> |
|
| 1187 |
> |
if (update_arg( (void *)&(args_info->end_arg), |
| 1188 |
> |
&(args_info->end_orig), &(args_info->end_given), |
| 1189 |
> |
&(local_args_info.end_given), optarg, 0, 0, ARG_INT, |
| 1190 |
> |
check_ambiguity, override, 0, 0, |
| 1191 |
> |
"end", '-', |
| 1192 |
> |
additional_error)) |
| 1193 |
> |
goto failure; |
| 1194 |
> |
|
| 1195 |
|
} |
| 1196 |
+ |
/* nanoparticle radius. */ |
| 1197 |
+ |
else if (strcmp (long_options[option_index].name, "radius") == 0) |
| 1198 |
+ |
{ |
| 1199 |
|
|
| 1200 |
+ |
|
| 1201 |
+ |
if (update_arg( (void *)&(args_info->radius_arg), |
| 1202 |
+ |
&(args_info->radius_orig), &(args_info->radius_given), |
| 1203 |
+ |
&(local_args_info.radius_given), optarg, 0, 0, ARG_DOUBLE, |
| 1204 |
+ |
check_ambiguity, override, 0, 0, |
| 1205 |
+ |
"radius", '-', |
| 1206 |
+ |
additional_error)) |
| 1207 |
+ |
goto failure; |
| 1208 |
+ |
|
| 1209 |
+ |
} |
| 1210 |
+ |
/* bond order parameter (--rcut must be specified). */ |
| 1211 |
+ |
else if (strcmp (long_options[option_index].name, "bo") == 0) |
| 1212 |
+ |
{ |
| 1213 |
+ |
|
| 1214 |
+ |
if (args_info->staticProps_group_counter && override) |
| 1215 |
+ |
reset_group_staticProps (args_info); |
| 1216 |
+ |
args_info->staticProps_group_counter += 1; |
| 1217 |
+ |
|
| 1218 |
+ |
if (update_arg( 0 , |
| 1219 |
+ |
0 , &(args_info->bo_given), |
| 1220 |
+ |
&(local_args_info.bo_given), optarg, 0, 0, ARG_NO, |
| 1221 |
+ |
check_ambiguity, override, 0, 0, |
| 1222 |
+ |
"bo", '-', |
| 1223 |
+ |
additional_error)) |
| 1224 |
+ |
goto failure; |
| 1225 |
+ |
|
| 1226 |
+ |
} |
| 1227 |
+ |
/* bond order parameter as a function of radius (--rcut must be specified). */ |
| 1228 |
+ |
else if (strcmp (long_options[option_index].name, "bor") == 0) |
| 1229 |
+ |
{ |
| 1230 |
+ |
|
| 1231 |
+ |
if (args_info->staticProps_group_counter && override) |
| 1232 |
+ |
reset_group_staticProps (args_info); |
| 1233 |
+ |
args_info->staticProps_group_counter += 1; |
| 1234 |
+ |
|
| 1235 |
+ |
if (update_arg( 0 , |
| 1236 |
+ |
0 , &(args_info->bor_given), |
| 1237 |
+ |
&(local_args_info.bor_given), optarg, 0, 0, ARG_NO, |
| 1238 |
+ |
check_ambiguity, override, 0, 0, |
| 1239 |
+ |
"bor", '-', |
| 1240 |
+ |
additional_error)) |
| 1241 |
+ |
goto failure; |
| 1242 |
+ |
|
| 1243 |
+ |
} |
| 1244 |
+ |
/* N(theta) bond angle density within (--rcut must be specified). */ |
| 1245 |
+ |
else if (strcmp (long_options[option_index].name, "bad") == 0) |
| 1246 |
+ |
{ |
| 1247 |
+ |
|
| 1248 |
+ |
if (args_info->staticProps_group_counter && override) |
| 1249 |
+ |
reset_group_staticProps (args_info); |
| 1250 |
+ |
args_info->staticProps_group_counter += 1; |
| 1251 |
+ |
|
| 1252 |
+ |
if (update_arg( 0 , |
| 1253 |
+ |
0 , &(args_info->bad_given), |
| 1254 |
+ |
&(local_args_info.bad_given), optarg, 0, 0, ARG_NO, |
| 1255 |
+ |
check_ambiguity, override, 0, 0, |
| 1256 |
+ |
"bad", '-', |
| 1257 |
+ |
additional_error)) |
| 1258 |
+ |
goto failure; |
| 1259 |
+ |
|
| 1260 |
+ |
} |
| 1261 |
+ |
/* count of molecules matching selection criteria (and associated statistics). */ |
| 1262 |
+ |
else if (strcmp (long_options[option_index].name, "count") == 0) |
| 1263 |
+ |
{ |
| 1264 |
+ |
|
| 1265 |
+ |
if (args_info->staticProps_group_counter && override) |
| 1266 |
+ |
reset_group_staticProps (args_info); |
| 1267 |
+ |
args_info->staticProps_group_counter += 1; |
| 1268 |
+ |
|
| 1269 |
+ |
if (update_arg( 0 , |
| 1270 |
+ |
0 , &(args_info->count_given), |
| 1271 |
+ |
&(local_args_info.count_given), optarg, 0, 0, ARG_NO, |
| 1272 |
+ |
check_ambiguity, override, 0, 0, |
| 1273 |
+ |
"count", '-', |
| 1274 |
+ |
additional_error)) |
| 1275 |
+ |
goto failure; |
| 1276 |
+ |
|
| 1277 |
+ |
} |
| 1278 |
+ |
/* g(z). */ |
| 1279 |
+ |
else if (strcmp (long_options[option_index].name, "gofz") == 0) |
| 1280 |
+ |
{ |
| 1281 |
+ |
|
| 1282 |
+ |
if (args_info->staticProps_group_counter && override) |
| 1283 |
+ |
reset_group_staticProps (args_info); |
| 1284 |
+ |
args_info->staticProps_group_counter += 1; |
| 1285 |
+ |
|
| 1286 |
+ |
if (update_arg( 0 , |
| 1287 |
+ |
0 , &(args_info->gofz_given), |
| 1288 |
+ |
&(local_args_info.gofz_given), optarg, 0, 0, ARG_NO, |
| 1289 |
+ |
check_ambiguity, override, 0, 0, |
| 1290 |
+ |
"gofz", '-', |
| 1291 |
+ |
additional_error)) |
| 1292 |
+ |
goto failure; |
| 1293 |
+ |
|
| 1294 |
+ |
} |
| 1295 |
|
/* g(r, cos(theta)). */ |
| 1296 |
|
else if (strcmp (long_options[option_index].name, "r_theta") == 0) |
| 1297 |
|
{ |
| 266 |
– |
if (args_info->r_theta_given) |
| 267 |
– |
{ |
| 268 |
– |
fprintf (stderr, "%s: `--r_theta' option given more than once\n", CMDLINE_PARSER_PACKAGE); |
| 269 |
– |
clear_args (); |
| 270 |
– |
exit (EXIT_FAILURE); |
| 271 |
– |
} |
| 272 |
– |
args_info->r_theta_given = 1; staticProps_group_counter += 1; |
| 1298 |
|
|
| 1299 |
< |
break; |
| 1300 |
< |
} |
| 1299 |
> |
if (args_info->staticProps_group_counter && override) |
| 1300 |
> |
reset_group_staticProps (args_info); |
| 1301 |
> |
args_info->staticProps_group_counter += 1; |
| 1302 |
|
|
| 1303 |
+ |
if (update_arg( 0 , |
| 1304 |
+ |
0 , &(args_info->r_theta_given), |
| 1305 |
+ |
&(local_args_info.r_theta_given), optarg, 0, 0, ARG_NO, |
| 1306 |
+ |
check_ambiguity, override, 0, 0, |
| 1307 |
+ |
"r_theta", '-', |
| 1308 |
+ |
additional_error)) |
| 1309 |
+ |
goto failure; |
| 1310 |
+ |
|
| 1311 |
+ |
} |
| 1312 |
|
/* g(r, cos(omega)). */ |
| 1313 |
|
else if (strcmp (long_options[option_index].name, "r_omega") == 0) |
| 1314 |
|
{ |
| 280 |
– |
if (args_info->r_omega_given) |
| 281 |
– |
{ |
| 282 |
– |
fprintf (stderr, "%s: `--r_omega' option given more than once\n", CMDLINE_PARSER_PACKAGE); |
| 283 |
– |
clear_args (); |
| 284 |
– |
exit (EXIT_FAILURE); |
| 285 |
– |
} |
| 286 |
– |
args_info->r_omega_given = 1; staticProps_group_counter += 1; |
| 1315 |
|
|
| 1316 |
< |
break; |
| 1316 |
> |
if (args_info->staticProps_group_counter && override) |
| 1317 |
> |
reset_group_staticProps (args_info); |
| 1318 |
> |
args_info->staticProps_group_counter += 1; |
| 1319 |
> |
|
| 1320 |
> |
if (update_arg( 0 , |
| 1321 |
> |
0 , &(args_info->r_omega_given), |
| 1322 |
> |
&(local_args_info.r_omega_given), optarg, 0, 0, ARG_NO, |
| 1323 |
> |
check_ambiguity, override, 0, 0, |
| 1324 |
> |
"r_omega", '-', |
| 1325 |
> |
additional_error)) |
| 1326 |
> |
goto failure; |
| 1327 |
> |
|
| 1328 |
|
} |
| 1329 |
+ |
/* g(r, z). */ |
| 1330 |
+ |
else if (strcmp (long_options[option_index].name, "r_z") == 0) |
| 1331 |
+ |
{ |
| 1332 |
|
|
| 1333 |
+ |
if (args_info->staticProps_group_counter && override) |
| 1334 |
+ |
reset_group_staticProps (args_info); |
| 1335 |
+ |
args_info->staticProps_group_counter += 1; |
| 1336 |
+ |
|
| 1337 |
+ |
if (update_arg( 0 , |
| 1338 |
+ |
0 , &(args_info->r_z_given), |
| 1339 |
+ |
&(local_args_info.r_z_given), optarg, 0, 0, ARG_NO, |
| 1340 |
+ |
check_ambiguity, override, 0, 0, |
| 1341 |
+ |
"r_z", '-', |
| 1342 |
+ |
additional_error)) |
| 1343 |
+ |
goto failure; |
| 1344 |
+ |
|
| 1345 |
+ |
} |
| 1346 |
|
/* g(cos(theta), cos(omega)). */ |
| 1347 |
|
else if (strcmp (long_options[option_index].name, "theta_omega") == 0) |
| 1348 |
|
{ |
| 294 |
– |
if (args_info->theta_omega_given) |
| 295 |
– |
{ |
| 296 |
– |
fprintf (stderr, "%s: `--theta_omega' option given more than once\n", CMDLINE_PARSER_PACKAGE); |
| 297 |
– |
clear_args (); |
| 298 |
– |
exit (EXIT_FAILURE); |
| 299 |
– |
} |
| 300 |
– |
args_info->theta_omega_given = 1; staticProps_group_counter += 1; |
| 1349 |
|
|
| 1350 |
< |
break; |
| 1351 |
< |
} |
| 1350 |
> |
if (args_info->staticProps_group_counter && override) |
| 1351 |
> |
reset_group_staticProps (args_info); |
| 1352 |
> |
args_info->staticProps_group_counter += 1; |
| 1353 |
|
|
| 1354 |
+ |
if (update_arg( 0 , |
| 1355 |
+ |
0 , &(args_info->theta_omega_given), |
| 1356 |
+ |
&(local_args_info.theta_omega_given), optarg, 0, 0, ARG_NO, |
| 1357 |
+ |
check_ambiguity, override, 0, 0, |
| 1358 |
+ |
"theta_omega", '-', |
| 1359 |
+ |
additional_error)) |
| 1360 |
+ |
goto failure; |
| 1361 |
+ |
|
| 1362 |
+ |
} |
| 1363 |
|
/* g(x, y, z). */ |
| 1364 |
< |
else if (strcmp (long_options[option_index].name, "xyz") == 0) |
| 1364 |
> |
else if (strcmp (long_options[option_index].name, "gxyz") == 0) |
| 1365 |
|
{ |
| 308 |
– |
if (args_info->xyz_given) |
| 309 |
– |
{ |
| 310 |
– |
fprintf (stderr, "%s: `--xyz' option given more than once\n", CMDLINE_PARSER_PACKAGE); |
| 311 |
– |
clear_args (); |
| 312 |
– |
exit (EXIT_FAILURE); |
| 313 |
– |
} |
| 314 |
– |
args_info->xyz_given = 1; staticProps_group_counter += 1; |
| 1366 |
|
|
| 1367 |
< |
break; |
| 1367 |
> |
if (args_info->staticProps_group_counter && override) |
| 1368 |
> |
reset_group_staticProps (args_info); |
| 1369 |
> |
args_info->staticProps_group_counter += 1; |
| 1370 |
> |
|
| 1371 |
> |
if (update_arg( 0 , |
| 1372 |
> |
0 , &(args_info->gxyz_given), |
| 1373 |
> |
&(local_args_info.gxyz_given), optarg, 0, 0, ARG_NO, |
| 1374 |
> |
check_ambiguity, override, 0, 0, |
| 1375 |
> |
"gxyz", '-', |
| 1376 |
> |
additional_error)) |
| 1377 |
> |
goto failure; |
| 1378 |
> |
|
| 1379 |
|
} |
| 1380 |
+ |
/* 2D g(r) (Slab width --dz must be specified). */ |
| 1381 |
+ |
else if (strcmp (long_options[option_index].name, "twodgofr") == 0) |
| 1382 |
+ |
{ |
| 1383 |
|
|
| 1384 |
< |
|
| 1384 |
> |
if (args_info->staticProps_group_counter && override) |
| 1385 |
> |
reset_group_staticProps (args_info); |
| 1386 |
> |
args_info->staticProps_group_counter += 1; |
| 1387 |
> |
|
| 1388 |
> |
if (update_arg( 0 , |
| 1389 |
> |
0 , &(args_info->twodgofr_given), |
| 1390 |
> |
&(local_args_info.twodgofr_given), optarg, 0, 0, ARG_NO, |
| 1391 |
> |
check_ambiguity, override, 0, 0, |
| 1392 |
> |
"twodgofr", '-', |
| 1393 |
> |
additional_error)) |
| 1394 |
> |
goto failure; |
| 1395 |
> |
|
| 1396 |
> |
} |
| 1397 |
> |
/* rp2 order parameter (--sele1 and --sele2 must be specified). */ |
| 1398 |
> |
else if (strcmp (long_options[option_index].name, "rp2") == 0) |
| 1399 |
> |
{ |
| 1400 |
> |
|
| 1401 |
> |
if (args_info->staticProps_group_counter && override) |
| 1402 |
> |
reset_group_staticProps (args_info); |
| 1403 |
> |
args_info->staticProps_group_counter += 1; |
| 1404 |
> |
|
| 1405 |
> |
if (update_arg( 0 , |
| 1406 |
> |
0 , &(args_info->rp2_given), |
| 1407 |
> |
&(local_args_info.rp2_given), optarg, 0, 0, ARG_NO, |
| 1408 |
> |
check_ambiguity, override, 0, 0, |
| 1409 |
> |
"rp2", '-', |
| 1410 |
> |
additional_error)) |
| 1411 |
> |
goto failure; |
| 1412 |
> |
|
| 1413 |
> |
} |
| 1414 |
> |
/* slab density. */ |
| 1415 |
> |
else if (strcmp (long_options[option_index].name, "slab_density") == 0) |
| 1416 |
> |
{ |
| 1417 |
> |
|
| 1418 |
> |
if (args_info->staticProps_group_counter && override) |
| 1419 |
> |
reset_group_staticProps (args_info); |
| 1420 |
> |
args_info->staticProps_group_counter += 1; |
| 1421 |
> |
|
| 1422 |
> |
if (update_arg( 0 , |
| 1423 |
> |
0 , &(args_info->slab_density_given), |
| 1424 |
> |
&(local_args_info.slab_density_given), optarg, 0, 0, ARG_NO, |
| 1425 |
> |
check_ambiguity, override, 0, 0, |
| 1426 |
> |
"slab_density", '-', |
| 1427 |
> |
additional_error)) |
| 1428 |
> |
goto failure; |
| 1429 |
> |
|
| 1430 |
> |
} |
| 1431 |
> |
/* p(cos(theta)). */ |
| 1432 |
> |
else if (strcmp (long_options[option_index].name, "p_angle") == 0) |
| 1433 |
> |
{ |
| 1434 |
> |
|
| 1435 |
> |
if (args_info->staticProps_group_counter && override) |
| 1436 |
> |
reset_group_staticProps (args_info); |
| 1437 |
> |
args_info->staticProps_group_counter += 1; |
| 1438 |
> |
|
| 1439 |
> |
if (update_arg( 0 , |
| 1440 |
> |
0 , &(args_info->p_angle_given), |
| 1441 |
> |
&(local_args_info.p_angle_given), optarg, 0, 0, ARG_NO, |
| 1442 |
> |
check_ambiguity, override, 0, 0, |
| 1443 |
> |
"p_angle", '-', |
| 1444 |
> |
additional_error)) |
| 1445 |
> |
goto failure; |
| 1446 |
> |
|
| 1447 |
> |
} |
| 1448 |
> |
/* hxy. */ |
| 1449 |
> |
else if (strcmp (long_options[option_index].name, "hxy") == 0) |
| 1450 |
> |
{ |
| 1451 |
> |
|
| 1452 |
> |
if (args_info->staticProps_group_counter && override) |
| 1453 |
> |
reset_group_staticProps (args_info); |
| 1454 |
> |
args_info->staticProps_group_counter += 1; |
| 1455 |
> |
|
| 1456 |
> |
if (update_arg( 0 , |
| 1457 |
> |
0 , &(args_info->hxy_given), |
| 1458 |
> |
&(local_args_info.hxy_given), optarg, 0, 0, ARG_NO, |
| 1459 |
> |
check_ambiguity, override, 0, 0, |
| 1460 |
> |
"hxy", '-', |
| 1461 |
> |
additional_error)) |
| 1462 |
> |
goto failure; |
| 1463 |
> |
|
| 1464 |
> |
} |
| 1465 |
> |
/* rho of R. */ |
| 1466 |
> |
else if (strcmp (long_options[option_index].name, "rho_r") == 0) |
| 1467 |
> |
{ |
| 1468 |
> |
|
| 1469 |
> |
if (args_info->staticProps_group_counter && override) |
| 1470 |
> |
reset_group_staticProps (args_info); |
| 1471 |
> |
args_info->staticProps_group_counter += 1; |
| 1472 |
> |
|
| 1473 |
> |
if (update_arg( 0 , |
| 1474 |
> |
0 , &(args_info->rho_r_given), |
| 1475 |
> |
&(local_args_info.rho_r_given), optarg, 0, 0, ARG_NO, |
| 1476 |
> |
check_ambiguity, override, 0, 0, |
| 1477 |
> |
"rho_r", '-', |
| 1478 |
> |
additional_error)) |
| 1479 |
> |
goto failure; |
| 1480 |
> |
|
| 1481 |
> |
} |
| 1482 |
> |
/* hull volume of nanoparticle. */ |
| 1483 |
> |
else if (strcmp (long_options[option_index].name, "hullvol") == 0) |
| 1484 |
> |
{ |
| 1485 |
> |
|
| 1486 |
> |
if (args_info->staticProps_group_counter && override) |
| 1487 |
> |
reset_group_staticProps (args_info); |
| 1488 |
> |
args_info->staticProps_group_counter += 1; |
| 1489 |
> |
|
| 1490 |
> |
if (update_arg( 0 , |
| 1491 |
> |
0 , &(args_info->hullvol_given), |
| 1492 |
> |
&(local_args_info.hullvol_given), optarg, 0, 0, ARG_NO, |
| 1493 |
> |
check_ambiguity, override, 0, 0, |
| 1494 |
> |
"hullvol", '-', |
| 1495 |
> |
additional_error)) |
| 1496 |
> |
goto failure; |
| 1497 |
> |
|
| 1498 |
> |
} |
| 1499 |
> |
|
| 1500 |
> |
break; |
| 1501 |
|
case '?': /* Invalid option. */ |
| 1502 |
|
/* `getopt_long' already printed an error message. */ |
| 1503 |
< |
exit (EXIT_FAILURE); |
| 1503 |
> |
goto failure; |
| 1504 |
|
|
| 1505 |
|
default: /* bug: option not considered. */ |
| 1506 |
< |
fprintf (stderr, "%s: option unknown: %c\n", CMDLINE_PARSER_PACKAGE, c); |
| 1506 |
> |
fprintf (stderr, "%s: option unknown: %c%s\n", CMDLINE_PARSER_PACKAGE, c, (additional_error ? additional_error : "")); |
| 1507 |
|
abort (); |
| 1508 |
|
} /* switch */ |
| 1509 |
|
} /* while */ |
| 1510 |
|
|
| 1511 |
< |
if ( staticProps_group_counter != 1) |
| 1511 |
> |
if (args_info->staticProps_group_counter > 1) |
| 1512 |
|
{ |
| 1513 |
< |
fprintf (stderr, "%s: %d options of group staticProps were given. One is required\n", CMDLINE_PARSER_PACKAGE, staticProps_group_counter); |
| 1514 |
< |
missing_required_options = 1; |
| 1513 |
> |
fprintf (stderr, "%s: %d options of group staticProps were given. One is required.%s\n", argv[0], args_info->staticProps_group_counter, (additional_error ? additional_error : "")); |
| 1514 |
> |
error = 1; |
| 1515 |
|
} |
| 1516 |
|
|
| 1517 |
|
|
| 1518 |
< |
if (! args_info->input_given) |
| 1518 |
> |
|
| 1519 |
> |
if (check_required) |
| 1520 |
|
{ |
| 1521 |
< |
fprintf (stderr, "%s: '--input' ('-i') option required\n", CMDLINE_PARSER_PACKAGE); |
| 340 |
< |
missing_required_options = 1; |
| 1521 |
> |
error += cmdline_parser_required2 (args_info, argv[0], additional_error); |
| 1522 |
|
} |
| 1523 |
< |
if (! args_info->length_given) |
| 1523 |
> |
|
| 1524 |
> |
cmdline_parser_release (&local_args_info); |
| 1525 |
> |
|
| 1526 |
> |
if ( error ) |
| 1527 |
> |
return (EXIT_FAILURE); |
| 1528 |
> |
|
| 1529 |
> |
if (optind < argc) |
| 1530 |
|
{ |
| 1531 |
< |
fprintf (stderr, "%s: '--length' ('-l') option required\n", CMDLINE_PARSER_PACKAGE); |
| 1532 |
< |
missing_required_options = 1; |
| 1531 |
> |
int i = 0 ; |
| 1532 |
> |
int found_prog_name = 0; |
| 1533 |
> |
/* whether program name, i.e., argv[0], is in the remaining args |
| 1534 |
> |
(this may happen with some implementations of getopt, |
| 1535 |
> |
but surely not with the one included by gengetopt) */ |
| 1536 |
> |
|
| 1537 |
> |
i = optind; |
| 1538 |
> |
while (i < argc) |
| 1539 |
> |
if (argv[i++] == argv[0]) { |
| 1540 |
> |
found_prog_name = 1; |
| 1541 |
> |
break; |
| 1542 |
> |
} |
| 1543 |
> |
i = 0; |
| 1544 |
> |
|
| 1545 |
> |
args_info->inputs_num = argc - optind - found_prog_name; |
| 1546 |
> |
args_info->inputs = |
| 1547 |
> |
(char **)(malloc ((args_info->inputs_num)*sizeof(char *))) ; |
| 1548 |
> |
while (optind < argc) |
| 1549 |
> |
if (argv[optind++] != argv[0]) |
| 1550 |
> |
args_info->inputs[ i++ ] = gengetopt_strdup (argv[optind-1]) ; |
| 1551 |
|
} |
| 347 |
– |
if ( missing_required_options ) |
| 348 |
– |
exit (EXIT_FAILURE); |
| 1552 |
|
|
| 1553 |
|
return 0; |
| 1554 |
+ |
|
| 1555 |
+ |
failure: |
| 1556 |
+ |
|
| 1557 |
+ |
cmdline_parser_release (&local_args_info); |
| 1558 |
+ |
return (EXIT_FAILURE); |
| 1559 |
|
} |