|
funkalicious 0.1
|
#include <glib-2.0/glib.h>#include <gio/gio.h>
Include dependency graph for material_property_args.h:
This graph shows which files directly or indirectly include this file:Go to the source code of this file.
Classes | |
| struct | args |
Functions | |
| struct args * | process_args (int argc, char **argv, GError **err) |
| struct args* process_args | ( | int | argc, |
| char ** | argv, | ||
| GError ** | err | ||
| ) | [read] |
Processes the arguments to process_args
| argc | argc from main |
| argv | argv from main |
Definition at line 84 of file get_vhartree_slice_args.c.
{
int errored = 0;
gchar **file_names = NULL;
gboolean print_version = FALSE;
gchar** xslices = NULL;
gchar** yslices = NULL;
gchar** zslices = NULL;
GOptionEntry options[] = {
{ G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_FILENAME_ARRAY, &file_names,},
{ "version", 'v', G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_NONE, &print_version, "Print version information about this program", NULL },
{ "xslice", 'X', G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_STRING_ARRAY, &(xslices), "x coordinate (in grid sites) along which to output a 2D slice of the total density and the resulting potential", NULL},
{ "yslice", 'Y', G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_STRING_ARRAY, &(yslices), "y coordinate (in grid sites) along which to output a 2D slice of the total density and the resulting potential", NULL},
{ "zslice", 'Z', G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_STRING_ARRAY, &(zslices), "z coordinate (in grid sites) along which to output a 2D slice of the total density and the resulting potential", NULL},
{NULL}
};
GOptionContext *ctx;
ctx = g_option_context_new("- create a dotcode potential for the specified grid of nearest neighbors");
g_option_context_add_main_entries(ctx, options, "Options");
g_option_context_parse(ctx, &argc, &argv, NULL);
args.xslices = NULL;
int *d;
GError *e = NULL;
if(xslices != NULL) {
for(int i=0; xslices[i] != NULL; i++) {
if((d=new_int_from_string(xslices[i], &e)) != NULL) {
args.xslices = g_list_append(args.xslices, d);
}else{
*err = e;
return NULL;
}
}
}
args.yslices = NULL;
e = NULL;
if(yslices != NULL) {
for(int i=0; yslices[i] != NULL; i++) {
if((d=new_int_from_string(yslices[i], &e)) != NULL) {
args.yslices = g_list_append(args.yslices, d);
}else{
*err = e;
return NULL;
}
}
}
args.zslices = NULL;
e = NULL;
if(zslices != NULL) {
for(int i=0; zslices[i] != NULL; i++) {
if((d=new_int_from_string(zslices[i], &e)) != NULL) {
args.zslices = g_list_append(args.zslices, d);
}else{
*err = e;
return NULL;
}
}
}
gchar* htext = g_option_context_get_help(ctx, FALSE, NULL);
g_option_context_free(ctx);
args.struct_list = NULL;
if(file_names != NULL) {
for(int i = 0; file_names[i] != NULL; i++) {
args.struct_list = g_list_append(args.struct_list, g_file_new_for_commandline_arg(file_names[i]));
}
}
if(args.struct_list == NULL) {
fprintf(stderr, "ERROR: you MUST give at least one grid to process!\n");
errored=1;
}
if(errored){
printf("%s", htext);
printf("\n\n**For version and compilation information, run with --version***");
*err = g_error_new(GET_VHARTREE_SLICE_ARGS_GERROR_DOMAIN, 7, "\n");
return NULL;
}
if(print_version){
program_print_version(stdout);
libdotcode_print_version(stdout);
printf("autotools info:\n\tProject: %s\n\tVersion: %s\n", PACKAGE_NAME, VERSION);
printf("Platform information:\n\tSize of int=%d double=%d\n\tEndianness: %s\n", SIZEOF_INT, SIZEOF_DOUBLE,
#ifdef WORDS_BIGENDIAN
"big"
#else
"little"
#endif
);
*err = g_error_new(GET_VHARTREE_SLICE_ARGS_GERROR_DOMAIN, 7, "\n");
return NULL;
}
if(errored){
return NULL;
}
return &args;
}