|
k-dot-p 0.1
|
00001 /* 00002 00003 00004 Copyright (C) 2009 Joseph Pingenot 00005 00006 This program is free software: you can redistribute it and/or modify 00007 it under the terms of the GNU Affero General Public License as published by 00008 the Free Software Foundation, either version 3 of the License, or 00009 (at your option) any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU Affero General Public License for more details. 00015 00016 You should have received a copy of the GNU Affero General Public License 00017 along with this program. If not, see <http://www.gnu.org/licenses/>. 00018 00019 */ 00020 00021 #include <stdio.h> 00022 #include <glib.h> 00023 #include <gio/gio.h> 00024 #include "kdotp/makestruct_argprocess.h++" 00025 #include "config.h" 00026 00027 extern "C" { 00028 void program_print_version(FILE* f); 00029 void libkdotp_print_version(FILE* f); 00030 void libmodelxx_print_version(FILE* f); 00031 void liblapackwrap_print_version(FILE* f); 00032 } 00033 00034 void print_version_info(void) { 00035 program_print_version(stdout); 00036 libmodelxx_print_version(stdout); 00037 libkdotp_print_version(stdout); 00038 liblapackwrap_print_version(stdout); 00039 printf("autotools info:\n\tProject: %s\n\tVersion: %s\n", PACKAGE_NAME, VERSION); 00040 } 00041 00042 int parse_makestruct_args(int argc, char** argv, struct makestruct_args* args) { 00043 int errored = 0; 00044 gchar **file_names = NULL; 00045 gboolean print_version = FALSE; 00046 args->matdb = (char*)"/home/solarion/dist/share/materials-databases/matdb.txt"; 00047 GOptionEntry options[] = { 00048 { G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_FILENAME_ARRAY, &file_names,}, 00049 { "version", 'v', G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_NONE, &print_version, "Print version information about this program", NULL }, 00050 { "matdb", 'm', G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_STRING, &(args->matdb), "Use an alternate materials database file.", NULL }, 00051 {NULL, 0, G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_STRING, NULL, "", ""}, 00052 }; 00053 GOptionContext *ctx; 00054 ctx = g_option_context_new("- sets up a structure for k-dot-p calculations"); 00055 g_option_context_add_main_entries(ctx, options, "Options"); 00056 00057 g_option_context_parse(ctx, &argc, &argv, NULL); 00058 00059 00060 00061 gchar* htext = g_option_context_get_help(ctx, FALSE, NULL); 00062 g_option_context_free(ctx); 00063 00064 args->files = NULL; 00065 if(file_names != NULL) { 00066 for(int i = 0; file_names[i] != NULL; i++) { 00067 args->files = g_list_append(args->files, g_file_new_for_commandline_arg(file_names[i])); 00068 } 00069 } 00070 if(args->files == NULL) { 00071 fprintf(stderr, "ERROR: you MUST give at least one file to process!\n"); 00072 errored=1; 00073 } 00074 00075 if(print_version){ 00076 print_version_info(); 00077 return 1; 00078 } 00079 if(errored){ 00080 printf("%s", htext); 00081 printf("\n\n**For version and compilation information, run with --version***\n"); 00082 return 3; 00083 } 00084 return 0; 00085 }