- Add copyright notices to existing builtin python policies
- Implement system to dinamically pass plugins and policies search paths to the sgpemv2 binary and tests (class GlobalSettings) - Drastically reduce usage of hardcoded paths in code except as default overridable values git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@514 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
parent
24a0194368
commit
92e6f3be2b
9 changed files with 353 additions and 88 deletions
|
@ -21,7 +21,7 @@
|
|||
#include "config.h"
|
||||
#include "gettext.h"
|
||||
|
||||
#include "main.hh"
|
||||
#include "backend/global_settings.hh"
|
||||
#include "parse_opts.hh"
|
||||
|
||||
#ifdef _GNU_SOURCE
|
||||
|
@ -39,81 +39,102 @@ static void display_help();
|
|||
void
|
||||
parse_options(int& argc, char**& argv)
|
||||
{
|
||||
print_license();
|
||||
using sgpem::GlobalSettings;
|
||||
|
||||
print_license();
|
||||
|
||||
static const char* short_options = "nh";
|
||||
static const char* short_options = "NhP:M:";
|
||||
|
||||
#ifdef _GNU_SOURCE
|
||||
// Initialize the array for GNU long options
|
||||
static struct option long_options[] =
|
||||
{
|
||||
{"no-gui", no_argument, NULL, 'n' },
|
||||
{"help", no_argument, NULL, 'h' },
|
||||
};
|
||||
int option_index = 0;
|
||||
#endif
|
||||
|
||||
int opt;
|
||||
do
|
||||
{
|
||||
#ifdef _GNU_SOURCE
|
||||
opt = getopt_long(argc, argv, short_options,
|
||||
long_options, &option_index);
|
||||
#else
|
||||
opt = getopt(argc, argv, short_options);
|
||||
#endif
|
||||
#ifdef _GNU_SOURCE
|
||||
// Initialize the array for GNU long options
|
||||
static struct option long_options[] =
|
||||
{
|
||||
{"no-gui", no_argument, NULL, 'N' },
|
||||
{"help", no_argument, NULL, 'h' },
|
||||
{"policies-dir", required_argument, NULL, 'P'},
|
||||
{"modules-dir", required_argument, NULL, 'M'}
|
||||
};
|
||||
int option_index = 0;
|
||||
#endif
|
||||
|
||||
int opt;
|
||||
do
|
||||
{
|
||||
#ifdef _GNU_SOURCE
|
||||
opt = getopt_long(argc, argv, short_options,
|
||||
long_options, &option_index);
|
||||
#else
|
||||
opt = getopt(argc, argv, short_options);
|
||||
#endif
|
||||
|
||||
switch(opt)
|
||||
{
|
||||
case -1:
|
||||
// We have finished normally
|
||||
break;
|
||||
case 'n' :
|
||||
// We don't return to main, instead we
|
||||
// initialize the command line version
|
||||
// of sgpemv2 (?)
|
||||
|
||||
// FIXME : to be written!
|
||||
break;
|
||||
case 'h' :
|
||||
default :
|
||||
display_help();
|
||||
}
|
||||
} while( opt != -1 );
|
||||
switch(opt)
|
||||
{
|
||||
case -1:
|
||||
// We have finished normally
|
||||
break;
|
||||
case 'N' :
|
||||
// We don't return to main, instead we
|
||||
// initialize the command line version
|
||||
// of sgpemv2 (?)
|
||||
|
||||
// FIXME : to be written!
|
||||
break;
|
||||
case 'P':
|
||||
GlobalSettings::instance().add_policies_dir(optarg);
|
||||
break;
|
||||
case 'M':
|
||||
GlobalSettings::instance().add_modules_dir(optarg);
|
||||
break;
|
||||
case ':':
|
||||
printf(_("[EE] Wrong number of parameters. Please see \n"
|
||||
"%s --help\n"), argv[0]);
|
||||
exit(-1);
|
||||
case 'h' :
|
||||
default :
|
||||
display_help();
|
||||
}
|
||||
} while( opt != -1 );
|
||||
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
// Set these two to start from additional filenames on the cmdline:
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
display_help()
|
||||
{
|
||||
printf( _("SGPEMv2 is an educational software acting as a process scheduling simulator\n"
|
||||
"\n\nUsage : sgpemv2 [options]" // filenames"
|
||||
"\n\nOptions:\n"
|
||||
"\t-h, --help this help you're reading\n"
|
||||
"\t-n, --no-gui starts the program in command line mode\n"
|
||||
// "\nFilenames:\n"
|
||||
// "\t a list of any valid SGPEMv2 XML file\n"
|
||||
// "\t to be opened, space-separated.\n"
|
||||
"\nLong options are available only on GNU systems.\n\n" ) );
|
||||
exit(0);
|
||||
printf( _("SGPEMv2 is an educational software acting as a process scheduling simulator\n"
|
||||
"\n\nUsage : sgpemv2 [options]" // filenames"
|
||||
"\n\nOptions:\n"
|
||||
"\t-h, --help this help you're reading\n"
|
||||
"\t-N, --no-gui starts the program in command line mode\n"
|
||||
"\t-P dir, --policies-dir=dir\n"
|
||||
"\t add this directory to the default modules\n"
|
||||
"\t search path\n"
|
||||
"\t-M dir, --modules-dir=dir\n"
|
||||
"\t add this directory to default plugin\n"
|
||||
"\t search path\n"
|
||||
"\nFilenames:\n"
|
||||
"\t a list of any valid SGPEMv2 XML file\n"
|
||||
"\t to be opened, space-separated.\n"
|
||||
"\nLong options are available only on GNU systems.\n\n" ) );
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
print_license()
|
||||
{
|
||||
// Do _NOT_ translate this text.
|
||||
std::cerr <<
|
||||
"SGPEMv2, Copyright (C) 2005, 2006 University of Padova,\n"
|
||||
" dept. of Pure and Applied Mathematics.\n"
|
||||
"SGPEMv2 comes with ABSOLUTELY NO WARRANTY. This is free \n"
|
||||
"software, and you are welcome to redistribute it under \n"
|
||||
"the terms of the GNU General Public License; for details\n"
|
||||
"see file COPYING contained in the source package. \n"
|
||||
<< std::endl;
|
||||
// Do _NOT_ translate this text.
|
||||
std::cerr <<
|
||||
"SGPEMv2, Copyright (C) 2005, 2006 University of Padova,\n"
|
||||
" dept. of Pure and Applied Mathematics.\n"
|
||||
"SGPEMv2 comes with ABSOLUTELY NO WARRANTY. This is free \n"
|
||||
"software, and you are welcome to redistribute it under \n"
|
||||
"the terms of the GNU General Public License; for details\n"
|
||||
"see file COPYING contained in the source package. \n"
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue