ggo: Specify types of all arguments

Former-commit-id: 5300dc50051822adf69eb1c4aa6516ed4e705882
This commit is contained in:
Marek Nečada 2019-06-18 14:48:39 +03:00
parent 96832355c7
commit 227101d9e8
3 changed files with 433 additions and 43 deletions

View File

@ -32,7 +32,7 @@ option "Ewald-parameter" e "The value of Ewald parameter η"
optional optional
option "frequency-unit" u "Specifies the frequency unit is used for inputs." option "frequency-unit" u "Specifies the frequency unit is used for inputs."
values="eV","scuff" values="eV","scuff" enum
default="scuff" default="scuff"
option "lMax" L "Maximum spherical multipole order to which the translation operator elements are calculated" option "lMax" L "Maximum spherical multipole order to which the translation operator elements are calculated"
@ -44,32 +44,44 @@ option "eta" n "Medium refractive index"
required required
option "particle" p "Specify the x and y coordinates of a single particle; If not specified, one particle per unit cell is assumed." option "particle" p "Specify the x and y coordinates of a single particle; If not specified, one particle per unit cell is assumed."
optional string
multiple multiple optional
defmode "k_omega_points" modedesc="Specifying each (ω, k) pair separately." defmode "k_omega_points" modedesc="Specifying each (ω, k) pair separately."
defmode "k_omega_meshgrid" modedesc="Specifying lists of ω and k, from which all possible pairs are generated." defmode "k_omega_meshgrid" modedesc="Specifying lists of ω and k, from which all possible pairs are generated."
modeoption "pointfile" T "Path to a file containing frequency, k_x, k_y triples\ modeoption "pointfile" T "Path to a file containing frequency, k_x, k_y triples\
(separated by white spaces). If not specified, read them from stdin." (separated by white spaces). If not specified, read them from stdin."
mode="k_omega_points" multiple default="-" mode="k_omega_points"
string
multiple default="-"
modeoption "point" t "Specifies a frequency, k_x, k_y triple, separated by commas." modeoption "point" t "Specifies a frequency, k_x, k_y triple, separated by commas."
mode="k_omega_points" multiple optional mode="k_omega_points"
string
multiple optional
modeoption "omegafile" F "Path to a file containing a list of frequencies\ modeoption "omegafile" F "Path to a file containing a list of frequencies\
separated by whitespaces." separated by whitespaces."
mode="k_omega_meshgrid" multiple optional mode="k_omega_meshgrid"
string
multiple optional
modeoption "omega" f "Specifies frequency (or multiple frequencies separated by semicolons) on the command line." modeoption "omega" f "Specifies frequency (or multiple frequencies separated by semicolons) on the command line."
mode="k_omega_meshgrid" multiple optional mode="k_omega_meshgrid"
string
multiple optional
modeoption "kfile" K "Path to a file containing a list of k_x, k_y pairs." modeoption "kfile" K "Path to a file containing a list of k_x, k_y pairs."
mode="k_omega_meshgrid" multiple optional mode="k_omega_meshgrid"
string
multiple optional
default="-" default="-"
modeoption "k" k "Specifies pair(s) of k_x, k_y values" modeoption "k" k "Specifies pair(s) of k_x, k_y values"
mode="k_omega_meshgrid" multiple optional mode="k_omega_meshgrid"
string
multiple optional
#option <long> <short> "<desc>" #option <long> <short> "<desc>"

View File

@ -43,18 +43,18 @@ const char *gengetopt_args_info_detailed_help[] = {
" -N, --normalisation=ENUM VSWF normalisation convention (possible\n values=\"Power\", \"None\", \"SH\"\n default=`Power')", " -N, --normalisation=ENUM VSWF normalisation convention (possible\n values=\"Power\", \"None\", \"SH\"\n default=`Power')",
" -c, --csphase=INT Whether the Condon-Shortley phase is included\n in VSWF definition (-1) or not (+1)\n (possible values=\"+1\", \"-1\" default=`-1')", " -c, --csphase=INT Whether the Condon-Shortley phase is included\n in VSWF definition (-1) or not (+1)\n (possible values=\"+1\", \"-1\" default=`-1')",
" -e, --Ewald-parameter=DOUBLE The value of Ewald parameter η", " -e, --Ewald-parameter=DOUBLE The value of Ewald parameter η",
" -u, --frequency-unit=STRING Specifies the frequency unit is used for\n inputs. (possible values=\"eV\", \"scuff\"\n default=`scuff')", " -u, --frequency-unit=ENUM Specifies the frequency unit is used for\n inputs. (possible values=\"eV\", \"scuff\"\n default=`scuff')",
" -L, --lMax=INT Maximum spherical multipole order to which the\n translation operator elements are calculated", " -L, --lMax=INT Maximum spherical multipole order to which the\n translation operator elements are calculated",
" -n, --eta=DOUBLE Medium refractive index", " -n, --eta=DOUBLE Medium refractive index",
" -p, --particle Specify the x and y coordinates of a single\n particle; If not specified, one particle per\n unit cell is assumed.", " -p, --particle=STRING Specify the x and y coordinates of a single\n particle; If not specified, one particle per\n unit cell is assumed.",
"\n Mode: k_omega_points\n Specifying each (ω, k) pair separately.", "\n Mode: k_omega_points\n Specifying each (ω, k) pair separately.",
" -T, --pointfile Path to a file containing frequency, k_x, k_y\n triples(separated by white spaces). If not\n specified, read them from stdin.", " -T, --pointfile=STRING Path to a file containing frequency, k_x, k_y\n triples(separated by white spaces). If not\n specified, read them from stdin.\n (default=`-')",
" -t, --point Specifies a frequency, k_x, k_y triple,\n separated by commas.", " -t, --point=STRING Specifies a frequency, k_x, k_y triple,\n separated by commas.",
"\n Mode: k_omega_meshgrid\n Specifying lists of ω and k, from which all possible pairs are generated.", "\n Mode: k_omega_meshgrid\n Specifying lists of ω and k, from which all possible pairs are generated.",
" -F, --omegafile Path to a file containing a list of\n frequenciesseparated by whitespaces.", " -F, --omegafile=STRING Path to a file containing a list of\n frequenciesseparated by whitespaces.",
" -f, --omega Specifies frequency (or multiple frequencies\n separated by semicolons) on the command line.", " -f, --omega=STRING Specifies frequency (or multiple frequencies\n separated by semicolons) on the command line.",
" -K, --kfile Path to a file containing a list of k_x, k_y\n pairs.", " -K, --kfile=STRING Path to a file containing a list of k_x, k_y\n pairs. (default=`-')",
" -k, --k Specifies pair(s) of k_x, k_y values", " -k, --k=STRING Specifies pair(s) of k_x, k_y values",
0 0
}; };
@ -151,10 +151,24 @@ void clear_args (struct gengetopt_args_info *args_info)
args_info->csphase_arg = -1; args_info->csphase_arg = -1;
args_info->csphase_orig = NULL; args_info->csphase_orig = NULL;
args_info->Ewald_parameter_orig = NULL; args_info->Ewald_parameter_orig = NULL;
args_info->frequency_unit_arg = gengetopt_strdup ("scuff"); args_info->frequency_unit_arg = frequency_unit_arg_scuff;
args_info->frequency_unit_orig = NULL; args_info->frequency_unit_orig = NULL;
args_info->lMax_orig = NULL; args_info->lMax_orig = NULL;
args_info->eta_orig = NULL; args_info->eta_orig = NULL;
args_info->particle_arg = NULL;
args_info->particle_orig = NULL;
args_info->pointfile_arg = NULL;
args_info->pointfile_orig = NULL;
args_info->point_arg = NULL;
args_info->point_orig = NULL;
args_info->omegafile_arg = NULL;
args_info->omegafile_orig = NULL;
args_info->omega_arg = NULL;
args_info->omega_orig = NULL;
args_info->kfile_arg = NULL;
args_info->kfile_orig = NULL;
args_info->k_arg = NULL;
args_info->k_orig = NULL;
} }
@ -282,6 +296,52 @@ free_string_field (char **s)
} }
} }
/** @brief generic value variable */
union generic_value {
int int_arg;
double double_arg;
char *string_arg;
const char *default_string_arg;
};
/** @brief holds temporary values for multiple options */
struct generic_list
{
union generic_value arg;
char *orig;
struct generic_list *next;
};
/**
* @brief add a node at the head of the list
*/
static void add_node(struct generic_list **list) {
struct generic_list *new_node = (struct generic_list *) malloc (sizeof (struct generic_list));
new_node->next = *list;
*list = new_node;
new_node->arg.string_arg = 0;
new_node->orig = 0;
}
static void
free_multiple_string_field(unsigned int len, char ***arg, char ***orig)
{
unsigned int i;
if (*arg) {
for (i = 0; i < len; ++i)
{
free_string_field(&((*arg)[i]));
free_string_field(&((*orig)[i]));
}
free_string_field(&((*arg)[0])); /* free default string */
free (*arg);
*arg = 0;
free (*orig);
*orig = 0;
}
}
static void static void
cmdline_parser_release (struct gengetopt_args_info *args_info) cmdline_parser_release (struct gengetopt_args_info *args_info)
@ -294,10 +354,16 @@ cmdline_parser_release (struct gengetopt_args_info *args_info)
free_string_field (&(args_info->normalisation_orig)); free_string_field (&(args_info->normalisation_orig));
free_string_field (&(args_info->csphase_orig)); free_string_field (&(args_info->csphase_orig));
free_string_field (&(args_info->Ewald_parameter_orig)); free_string_field (&(args_info->Ewald_parameter_orig));
free_string_field (&(args_info->frequency_unit_arg));
free_string_field (&(args_info->frequency_unit_orig)); free_string_field (&(args_info->frequency_unit_orig));
free_string_field (&(args_info->lMax_orig)); free_string_field (&(args_info->lMax_orig));
free_string_field (&(args_info->eta_orig)); free_string_field (&(args_info->eta_orig));
free_multiple_string_field (args_info->particle_given, &(args_info->particle_arg), &(args_info->particle_orig));
free_multiple_string_field (args_info->pointfile_given, &(args_info->pointfile_arg), &(args_info->pointfile_orig));
free_multiple_string_field (args_info->point_given, &(args_info->point_arg), &(args_info->point_orig));
free_multiple_string_field (args_info->omegafile_given, &(args_info->omegafile_arg), &(args_info->omegafile_orig));
free_multiple_string_field (args_info->omega_given, &(args_info->omega_arg), &(args_info->omega_orig));
free_multiple_string_field (args_info->kfile_given, &(args_info->kfile_arg), &(args_info->kfile_orig));
free_multiple_string_field (args_info->k_given, &(args_info->k_arg), &(args_info->k_orig));
@ -399,13 +465,13 @@ cmdline_parser_dump(FILE *outfile, struct gengetopt_args_info *args_info)
write_into_file(outfile, "lMax", args_info->lMax_orig, 0); write_into_file(outfile, "lMax", args_info->lMax_orig, 0);
if (args_info->eta_given) if (args_info->eta_given)
write_into_file(outfile, "eta", args_info->eta_orig, 0); write_into_file(outfile, "eta", args_info->eta_orig, 0);
write_multiple_into_file(outfile, args_info->particle_given, "particle", 0, 0); write_multiple_into_file(outfile, args_info->particle_given, "particle", args_info->particle_orig, 0);
write_multiple_into_file(outfile, args_info->pointfile_given, "pointfile", 0, 0); write_multiple_into_file(outfile, args_info->pointfile_given, "pointfile", args_info->pointfile_orig, 0);
write_multiple_into_file(outfile, args_info->point_given, "point", 0, 0); write_multiple_into_file(outfile, args_info->point_given, "point", args_info->point_orig, 0);
write_multiple_into_file(outfile, args_info->omegafile_given, "omegafile", 0, 0); write_multiple_into_file(outfile, args_info->omegafile_given, "omegafile", args_info->omegafile_orig, 0);
write_multiple_into_file(outfile, args_info->omega_given, "omega", 0, 0); write_multiple_into_file(outfile, args_info->omega_given, "omega", args_info->omega_orig, 0);
write_multiple_into_file(outfile, args_info->kfile_given, "kfile", 0, 0); write_multiple_into_file(outfile, args_info->kfile_given, "kfile", args_info->kfile_orig, 0);
write_multiple_into_file(outfile, args_info->k_given, "k", 0, 0); write_multiple_into_file(outfile, args_info->k_given, "k", args_info->k_orig, 0);
i = EXIT_SUCCESS; i = EXIT_SUCCESS;
@ -453,6 +519,86 @@ gengetopt_strdup (const char *s)
return result; return result;
} }
static char *
get_multiple_arg_token(const char *arg)
{
const char *tok;
char *ret;
size_t len, num_of_escape, i, j;
if (!arg)
return 0;
tok = strchr (arg, ',');
num_of_escape = 0;
/* make sure it is not escaped */
while (tok)
{
if (*(tok-1) == '\\')
{
/* find the next one */
tok = strchr (tok+1, ',');
++num_of_escape;
}
else
break;
}
if (tok)
len = (size_t)(tok - arg + 1);
else
len = strlen (arg) + 1;
len -= num_of_escape;
ret = (char *) malloc (len);
i = 0;
j = 0;
while (arg[i] && (j < len-1))
{
if (arg[i] == '\\' &&
arg[ i + 1 ] &&
arg[ i + 1 ] == ',')
++i;
ret[j++] = arg[i++];
}
ret[len-1] = '\0';
return ret;
}
static const char *
get_multiple_arg_token_next(const char *arg)
{
const char *tok;
if (!arg)
return 0;
tok = strchr (arg, ',');
/* make sure it is not escaped */
while (tok)
{
if (*(tok-1) == '\\')
{
/* find the next one */
tok = strchr (tok+1, ',');
}
else
break;
}
if (! tok || strlen(tok) == 1)
return 0;
return tok+1;
}
static int static int
check_multiple_option_occurrences(const char *prog_name, unsigned int option_given, unsigned int min, unsigned int max, const char *option_desc); check_multiple_option_occurrences(const char *prog_name, unsigned int option_given, unsigned int min, unsigned int max, const char *option_desc);
@ -770,6 +916,151 @@ int update_arg(void *field, char **orig_field,
return 0; /* OK */ return 0; /* OK */
} }
/**
* @brief store information about a multiple option in a temporary list
* @param list where to (temporarily) store multiple options
*/
static
int update_multiple_arg_temp(struct generic_list **list,
unsigned int *prev_given, const char *val,
const char *possible_values[], const char *default_value,
cmdline_parser_arg_type arg_type,
const char *long_opt, char short_opt,
const char *additional_error)
{
/* store single arguments */
char *multi_token;
const char *multi_next;
if (arg_type == ARG_NO) {
(*prev_given)++;
return 0; /* OK */
}
multi_token = get_multiple_arg_token(val);
multi_next = get_multiple_arg_token_next (val);
while (1)
{
add_node (list);
if (update_arg((void *)&((*list)->arg), &((*list)->orig), 0,
prev_given, multi_token, possible_values, default_value,
arg_type, 0, 1, 1, 1, long_opt, short_opt, additional_error)) {
if (multi_token) free(multi_token);
return 1; /* failure */
}
if (multi_next)
{
multi_token = get_multiple_arg_token(multi_next);
multi_next = get_multiple_arg_token_next (multi_next);
}
else
break;
}
return 0; /* OK */
}
/**
* @brief free the passed list (including possible string argument)
*/
static
void free_list(struct generic_list *list, short string_arg)
{
if (list) {
struct generic_list *tmp;
while (list)
{
tmp = list;
if (string_arg && list->arg.string_arg)
free (list->arg.string_arg);
if (list->orig)
free (list->orig);
list = list->next;
free (tmp);
}
}
}
/**
* @brief updates a multiple option starting from the passed list
*/
static
void update_multiple_arg(void *field, char ***orig_field,
unsigned int field_given, unsigned int prev_given, union generic_value *default_value,
cmdline_parser_arg_type arg_type,
struct generic_list *list)
{
int i;
struct generic_list *tmp;
if (prev_given && list) {
*orig_field = (char **) realloc (*orig_field, (field_given + prev_given) * sizeof (char *));
switch(arg_type) {
case ARG_INT:
case ARG_ENUM:
*((int **)field) = (int *)realloc (*((int **)field), (field_given + prev_given) * sizeof (int)); break;
case ARG_DOUBLE:
*((double **)field) = (double *)realloc (*((double **)field), (field_given + prev_given) * sizeof (double)); break;
case ARG_STRING:
*((char ***)field) = (char **)realloc (*((char ***)field), (field_given + prev_given) * sizeof (char *)); break;
default:
break;
};
for (i = (prev_given - 1); i >= 0; --i)
{
tmp = list;
switch(arg_type) {
case ARG_INT:
(*((int **)field))[i + field_given] = tmp->arg.int_arg; break;
case ARG_DOUBLE:
(*((double **)field))[i + field_given] = tmp->arg.double_arg; break;
case ARG_ENUM:
(*((int **)field))[i + field_given] = tmp->arg.int_arg; break;
case ARG_STRING:
(*((char ***)field))[i + field_given] = tmp->arg.string_arg; break;
default:
break;
}
(*orig_field) [i + field_given] = list->orig;
list = list->next;
free (tmp);
}
} else { /* set the default value */
if (default_value && ! field_given) {
switch(arg_type) {
case ARG_INT:
case ARG_ENUM:
if (! *((int **)field)) {
*((int **)field) = (int *)malloc (sizeof (int));
(*((int **)field))[0] = default_value->int_arg;
}
break;
case ARG_DOUBLE:
if (! *((double **)field)) {
*((double **)field) = (double *)malloc (sizeof (double));
(*((double **)field))[0] = default_value->double_arg;
}
break;
case ARG_STRING:
if (! *((char ***)field)) {
*((char ***)field) = (char **)malloc (sizeof (char *));
(*((char ***)field))[0] = gengetopt_strdup(default_value->string_arg);
}
break;
default: break;
}
if (!(*orig_field)) {
*orig_field = (char **) malloc (sizeof (char *));
(*orig_field)[0] = 0;
}
}
}
}
static int check_modes( static int check_modes(
int given1[], const char *options1[], int given1[], const char *options1[],
@ -802,6 +1093,13 @@ cmdline_parser_internal (
int c; /* Character of the parsed option. */ int c; /* Character of the parsed option. */
union generic_value multiple_default_value; union generic_value multiple_default_value;
struct generic_list * particle_list = NULL;
struct generic_list * pointfile_list = NULL;
struct generic_list * point_list = NULL;
struct generic_list * omegafile_list = NULL;
struct generic_list * omega_list = NULL;
struct generic_list * kfile_list = NULL;
struct generic_list * k_list = NULL;
int error_occurred = 0; int error_occurred = 0;
struct gengetopt_args_info local_args_info; struct gengetopt_args_info local_args_info;
@ -843,17 +1141,17 @@ cmdline_parser_internal (
{ "frequency-unit", 1, NULL, 'u' }, { "frequency-unit", 1, NULL, 'u' },
{ "lMax", 1, NULL, 'L' }, { "lMax", 1, NULL, 'L' },
{ "eta", 1, NULL, 'n' }, { "eta", 1, NULL, 'n' },
{ "particle", 0, NULL, 'p' }, { "particle", 1, NULL, 'p' },
{ "pointfile", 0, NULL, 'T' }, { "pointfile", 1, NULL, 'T' },
{ "point", 0, NULL, 't' }, { "point", 1, NULL, 't' },
{ "omegafile", 0, NULL, 'F' }, { "omegafile", 1, NULL, 'F' },
{ "omega", 0, NULL, 'f' }, { "omega", 1, NULL, 'f' },
{ "kfile", 0, NULL, 'K' }, { "kfile", 1, NULL, 'K' },
{ "k", 0, NULL, 'k' }, { "k", 1, NULL, 'k' },
{ 0, 0, 0, 0 } { 0, 0, 0, 0 }
}; };
c = getopt_long (argc, argv, "hVo:E:N:c:e:u:L:n:pTtFfKk", long_options, &option_index); c = getopt_long (argc, argv, "hVo:E:N:c:e:u:L:n:p:T:t:F:f:K:k:", long_options, &option_index);
if (c == -1) break; /* Exit from `while (1)' loop. */ if (c == -1) break; /* Exit from `while (1)' loop. */
@ -934,7 +1232,7 @@ cmdline_parser_internal (
if (update_arg( (void *)&(args_info->frequency_unit_arg), if (update_arg( (void *)&(args_info->frequency_unit_arg),
&(args_info->frequency_unit_orig), &(args_info->frequency_unit_given), &(args_info->frequency_unit_orig), &(args_info->frequency_unit_given),
&(local_args_info.frequency_unit_given), optarg, cmdline_parser_frequency_unit_values, "scuff", ARG_STRING, &(local_args_info.frequency_unit_given), optarg, cmdline_parser_frequency_unit_values, "scuff", ARG_ENUM,
check_ambiguity, override, 0, 0, check_ambiguity, override, 0, 0,
"frequency-unit", 'u', "frequency-unit", 'u',
additional_error)) additional_error))
@ -967,43 +1265,71 @@ cmdline_parser_internal (
break; break;
case 'p': /* Specify the x and y coordinates of a single particle; If not specified, one particle per unit cell is assumed.. */ case 'p': /* Specify the x and y coordinates of a single particle; If not specified, one particle per unit cell is assumed.. */
local_args_info.particle_given++; if (update_multiple_arg_temp(&particle_list,
&(local_args_info.particle_given), optarg, 0, 0, ARG_STRING,
"particle", 'p',
additional_error))
goto failure;
break; break;
case 'T': /* Path to a file containing frequency, k_x, k_y triples(separated by white spaces). If not specified, read them from stdin.. */ case 'T': /* Path to a file containing frequency, k_x, k_y triples(separated by white spaces). If not specified, read them from stdin.. */
args_info->k_omega_points_mode_counter += 1; args_info->k_omega_points_mode_counter += 1;
local_args_info.pointfile_given++; if (update_multiple_arg_temp(&pointfile_list,
&(local_args_info.pointfile_given), optarg, 0, "-", ARG_STRING,
"pointfile", 'T',
additional_error))
goto failure;
break; break;
case 't': /* Specifies a frequency, k_x, k_y triple, separated by commas.. */ case 't': /* Specifies a frequency, k_x, k_y triple, separated by commas.. */
args_info->k_omega_points_mode_counter += 1; args_info->k_omega_points_mode_counter += 1;
local_args_info.point_given++; if (update_multiple_arg_temp(&point_list,
&(local_args_info.point_given), optarg, 0, 0, ARG_STRING,
"point", 't',
additional_error))
goto failure;
break; break;
case 'F': /* Path to a file containing a list of frequenciesseparated by whitespaces.. */ case 'F': /* Path to a file containing a list of frequenciesseparated by whitespaces.. */
args_info->k_omega_meshgrid_mode_counter += 1; args_info->k_omega_meshgrid_mode_counter += 1;
local_args_info.omegafile_given++; if (update_multiple_arg_temp(&omegafile_list,
&(local_args_info.omegafile_given), optarg, 0, 0, ARG_STRING,
"omegafile", 'F',
additional_error))
goto failure;
break; break;
case 'f': /* Specifies frequency (or multiple frequencies separated by semicolons) on the command line.. */ case 'f': /* Specifies frequency (or multiple frequencies separated by semicolons) on the command line.. */
args_info->k_omega_meshgrid_mode_counter += 1; args_info->k_omega_meshgrid_mode_counter += 1;
local_args_info.omega_given++; if (update_multiple_arg_temp(&omega_list,
&(local_args_info.omega_given), optarg, 0, 0, ARG_STRING,
"omega", 'f',
additional_error))
goto failure;
break; break;
case 'K': /* Path to a file containing a list of k_x, k_y pairs.. */ case 'K': /* Path to a file containing a list of k_x, k_y pairs.. */
args_info->k_omega_meshgrid_mode_counter += 1; args_info->k_omega_meshgrid_mode_counter += 1;
local_args_info.kfile_given++; if (update_multiple_arg_temp(&kfile_list,
&(local_args_info.kfile_given), optarg, 0, "-", ARG_STRING,
"kfile", 'K',
additional_error))
goto failure;
break; break;
case 'k': /* Specifies pair(s) of k_x, k_y values. */ case 'k': /* Specifies pair(s) of k_x, k_y values. */
args_info->k_omega_meshgrid_mode_counter += 1; args_info->k_omega_meshgrid_mode_counter += 1;
local_args_info.k_given++; if (update_multiple_arg_temp(&k_list,
&(local_args_info.k_given), optarg, 0, 0, ARG_STRING,
"k", 'k',
additional_error))
goto failure;
break; break;
@ -1025,6 +1351,36 @@ cmdline_parser_internal (
} /* while */ } /* while */
update_multiple_arg((void *)&(args_info->particle_arg),
&(args_info->particle_orig), args_info->particle_given,
local_args_info.particle_given, 0,
ARG_STRING, particle_list);
multiple_default_value.default_string_arg = "-";
update_multiple_arg((void *)&(args_info->pointfile_arg),
&(args_info->pointfile_orig), args_info->pointfile_given,
local_args_info.pointfile_given, &multiple_default_value,
ARG_STRING, pointfile_list);
update_multiple_arg((void *)&(args_info->point_arg),
&(args_info->point_orig), args_info->point_given,
local_args_info.point_given, 0,
ARG_STRING, point_list);
update_multiple_arg((void *)&(args_info->omegafile_arg),
&(args_info->omegafile_orig), args_info->omegafile_given,
local_args_info.omegafile_given, 0,
ARG_STRING, omegafile_list);
update_multiple_arg((void *)&(args_info->omega_arg),
&(args_info->omega_orig), args_info->omega_given,
local_args_info.omega_given, 0,
ARG_STRING, omega_list);
multiple_default_value.default_string_arg = "-";
update_multiple_arg((void *)&(args_info->kfile_arg),
&(args_info->kfile_orig), args_info->kfile_given,
local_args_info.kfile_given, &multiple_default_value,
ARG_STRING, kfile_list);
update_multiple_arg((void *)&(args_info->k_arg),
&(args_info->k_orig), args_info->k_given,
local_args_info.k_given, 0,
ARG_STRING, k_list);
args_info->particle_given += local_args_info.particle_given; args_info->particle_given += local_args_info.particle_given;
local_args_info.particle_given = 0; local_args_info.particle_given = 0;
@ -1062,6 +1418,13 @@ cmdline_parser_internal (
return 0; return 0;
failure: failure:
free_list (particle_list, 1 );
free_list (pointfile_list, 1 );
free_list (point_list, 1 );
free_list (omegafile_list, 1 );
free_list (omega_list, 1 );
free_list (kfile_list, 1 );
free_list (k_list, 1 );
cmdline_parser_release (&local_args_info); cmdline_parser_release (&local_args_info);
return (EXIT_FAILURE); return (EXIT_FAILURE);

View File

@ -35,6 +35,7 @@ extern "C" {
#endif #endif
enum enum_normalisation { normalisation__NULL = -1, normalisation_arg_Power = 0, normalisation_arg_None, normalisation_arg_SH }; enum enum_normalisation { normalisation__NULL = -1, normalisation_arg_Power = 0, normalisation_arg_None, normalisation_arg_SH };
enum enum_frequency_unit { frequency_unit__NULL = -1, frequency_unit_arg_eV = 0, frequency_unit_arg_scuff };
/** @brief Where the command line options are stored */ /** @brief Where the command line options are stored */
struct gengetopt_args_info struct gengetopt_args_info
@ -57,7 +58,7 @@ struct gengetopt_args_info
double Ewald_parameter_arg; /**< @brief The value of Ewald parameter η. */ double Ewald_parameter_arg; /**< @brief The value of Ewald parameter η. */
char * Ewald_parameter_orig; /**< @brief The value of Ewald parameter η original value given at command line. */ char * Ewald_parameter_orig; /**< @brief The value of Ewald parameter η original value given at command line. */
const char *Ewald_parameter_help; /**< @brief The value of Ewald parameter η help description. */ const char *Ewald_parameter_help; /**< @brief The value of Ewald parameter η help description. */
char * frequency_unit_arg; /**< @brief Specifies the frequency unit is used for inputs. (default='scuff'). */ enum enum_frequency_unit frequency_unit_arg; /**< @brief Specifies the frequency unit is used for inputs. (default='scuff'). */
char * frequency_unit_orig; /**< @brief Specifies the frequency unit is used for inputs. original value given at command line. */ char * frequency_unit_orig; /**< @brief Specifies the frequency unit is used for inputs. original value given at command line. */
const char *frequency_unit_help; /**< @brief Specifies the frequency unit is used for inputs. help description. */ const char *frequency_unit_help; /**< @brief Specifies the frequency unit is used for inputs. help description. */
int lMax_arg; /**< @brief Maximum spherical multipole order to which the translation operator elements are calculated. */ int lMax_arg; /**< @brief Maximum spherical multipole order to which the translation operator elements are calculated. */
@ -66,24 +67,38 @@ struct gengetopt_args_info
double eta_arg; /**< @brief Medium refractive index. */ double eta_arg; /**< @brief Medium refractive index. */
char * eta_orig; /**< @brief Medium refractive index original value given at command line. */ char * eta_orig; /**< @brief Medium refractive index original value given at command line. */
const char *eta_help; /**< @brief Medium refractive index help description. */ const char *eta_help; /**< @brief Medium refractive index help description. */
char ** particle_arg; /**< @brief Specify the x and y coordinates of a single particle; If not specified, one particle per unit cell is assumed.. */
char ** particle_orig; /**< @brief Specify the x and y coordinates of a single particle; If not specified, one particle per unit cell is assumed. original value given at command line. */
unsigned int particle_min; /**< @brief Specify the x and y coordinates of a single particle; If not specified, one particle per unit cell is assumed.'s minimum occurreces */ unsigned int particle_min; /**< @brief Specify the x and y coordinates of a single particle; If not specified, one particle per unit cell is assumed.'s minimum occurreces */
unsigned int particle_max; /**< @brief Specify the x and y coordinates of a single particle; If not specified, one particle per unit cell is assumed.'s maximum occurreces */ unsigned int particle_max; /**< @brief Specify the x and y coordinates of a single particle; If not specified, one particle per unit cell is assumed.'s maximum occurreces */
const char *particle_help; /**< @brief Specify the x and y coordinates of a single particle; If not specified, one particle per unit cell is assumed. help description. */ const char *particle_help; /**< @brief Specify the x and y coordinates of a single particle; If not specified, one particle per unit cell is assumed. help description. */
char ** pointfile_arg; /**< @brief Path to a file containing frequency, k_x, k_y triples(separated by white spaces). If not specified, read them from stdin. (default='-'). */
char ** pointfile_orig; /**< @brief Path to a file containing frequency, k_x, k_y triples(separated by white spaces). If not specified, read them from stdin. original value given at command line. */
unsigned int pointfile_min; /**< @brief Path to a file containing frequency, k_x, k_y triples(separated by white spaces). If not specified, read them from stdin.'s minimum occurreces */ unsigned int pointfile_min; /**< @brief Path to a file containing frequency, k_x, k_y triples(separated by white spaces). If not specified, read them from stdin.'s minimum occurreces */
unsigned int pointfile_max; /**< @brief Path to a file containing frequency, k_x, k_y triples(separated by white spaces). If not specified, read them from stdin.'s maximum occurreces */ unsigned int pointfile_max; /**< @brief Path to a file containing frequency, k_x, k_y triples(separated by white spaces). If not specified, read them from stdin.'s maximum occurreces */
const char *pointfile_help; /**< @brief Path to a file containing frequency, k_x, k_y triples(separated by white spaces). If not specified, read them from stdin. help description. */ const char *pointfile_help; /**< @brief Path to a file containing frequency, k_x, k_y triples(separated by white spaces). If not specified, read them from stdin. help description. */
char ** point_arg; /**< @brief Specifies a frequency, k_x, k_y triple, separated by commas.. */
char ** point_orig; /**< @brief Specifies a frequency, k_x, k_y triple, separated by commas. original value given at command line. */
unsigned int point_min; /**< @brief Specifies a frequency, k_x, k_y triple, separated by commas.'s minimum occurreces */ unsigned int point_min; /**< @brief Specifies a frequency, k_x, k_y triple, separated by commas.'s minimum occurreces */
unsigned int point_max; /**< @brief Specifies a frequency, k_x, k_y triple, separated by commas.'s maximum occurreces */ unsigned int point_max; /**< @brief Specifies a frequency, k_x, k_y triple, separated by commas.'s maximum occurreces */
const char *point_help; /**< @brief Specifies a frequency, k_x, k_y triple, separated by commas. help description. */ const char *point_help; /**< @brief Specifies a frequency, k_x, k_y triple, separated by commas. help description. */
char ** omegafile_arg; /**< @brief Path to a file containing a list of frequenciesseparated by whitespaces.. */
char ** omegafile_orig; /**< @brief Path to a file containing a list of frequenciesseparated by whitespaces. original value given at command line. */
unsigned int omegafile_min; /**< @brief Path to a file containing a list of frequenciesseparated by whitespaces.'s minimum occurreces */ unsigned int omegafile_min; /**< @brief Path to a file containing a list of frequenciesseparated by whitespaces.'s minimum occurreces */
unsigned int omegafile_max; /**< @brief Path to a file containing a list of frequenciesseparated by whitespaces.'s maximum occurreces */ unsigned int omegafile_max; /**< @brief Path to a file containing a list of frequenciesseparated by whitespaces.'s maximum occurreces */
const char *omegafile_help; /**< @brief Path to a file containing a list of frequenciesseparated by whitespaces. help description. */ const char *omegafile_help; /**< @brief Path to a file containing a list of frequenciesseparated by whitespaces. help description. */
char ** omega_arg; /**< @brief Specifies frequency (or multiple frequencies separated by semicolons) on the command line.. */
char ** omega_orig; /**< @brief Specifies frequency (or multiple frequencies separated by semicolons) on the command line. original value given at command line. */
unsigned int omega_min; /**< @brief Specifies frequency (or multiple frequencies separated by semicolons) on the command line.'s minimum occurreces */ unsigned int omega_min; /**< @brief Specifies frequency (or multiple frequencies separated by semicolons) on the command line.'s minimum occurreces */
unsigned int omega_max; /**< @brief Specifies frequency (or multiple frequencies separated by semicolons) on the command line.'s maximum occurreces */ unsigned int omega_max; /**< @brief Specifies frequency (or multiple frequencies separated by semicolons) on the command line.'s maximum occurreces */
const char *omega_help; /**< @brief Specifies frequency (or multiple frequencies separated by semicolons) on the command line. help description. */ const char *omega_help; /**< @brief Specifies frequency (or multiple frequencies separated by semicolons) on the command line. help description. */
char ** kfile_arg; /**< @brief Path to a file containing a list of k_x, k_y pairs. (default='-'). */
char ** kfile_orig; /**< @brief Path to a file containing a list of k_x, k_y pairs. original value given at command line. */
unsigned int kfile_min; /**< @brief Path to a file containing a list of k_x, k_y pairs.'s minimum occurreces */ unsigned int kfile_min; /**< @brief Path to a file containing a list of k_x, k_y pairs.'s minimum occurreces */
unsigned int kfile_max; /**< @brief Path to a file containing a list of k_x, k_y pairs.'s maximum occurreces */ unsigned int kfile_max; /**< @brief Path to a file containing a list of k_x, k_y pairs.'s maximum occurreces */
const char *kfile_help; /**< @brief Path to a file containing a list of k_x, k_y pairs. help description. */ const char *kfile_help; /**< @brief Path to a file containing a list of k_x, k_y pairs. help description. */
char ** k_arg; /**< @brief Specifies pair(s) of k_x, k_y values. */
char ** k_orig; /**< @brief Specifies pair(s) of k_x, k_y values original value given at command line. */
unsigned int k_min; /**< @brief Specifies pair(s) of k_x, k_y values's minimum occurreces */ unsigned int k_min; /**< @brief Specifies pair(s) of k_x, k_y values's minimum occurreces */
unsigned int k_max; /**< @brief Specifies pair(s) of k_x, k_y values's maximum occurreces */ unsigned int k_max; /**< @brief Specifies pair(s) of k_x, k_y values's maximum occurreces */
const char *k_help; /**< @brief Specifies pair(s) of k_x, k_y values help description. */ const char *k_help; /**< @brief Specifies pair(s) of k_x, k_y values help description. */