- Change filenames to follow a consistent naming scheme
git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@307 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
parent
68a0cef9d9
commit
87558b5c26
20 changed files with 33 additions and 33 deletions
118
src/parse_opts.cc
Normal file
118
src/parse_opts.cc
Normal file
|
@ -0,0 +1,118 @@
|
|||
// src/parseopts.cc - Copyright 2005, 2006, University
|
||||
// of Padova, dept. of Pure and Applied
|
||||
// Mathematics
|
||||
//
|
||||
// This file is part of SGPEMv2.
|
||||
//
|
||||
// This is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// SGPEMv2 is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with SGPEMv2; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
#include "config.h"
|
||||
#include "gettext.h"
|
||||
|
||||
#include "main.hh"
|
||||
#include "parse_opts.hh"
|
||||
|
||||
#ifdef _GNU_SOURCE
|
||||
#include <getopt.h>
|
||||
#endif
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
|
||||
// Static declarations:
|
||||
static void display_help();
|
||||
|
||||
void
|
||||
parse_options(int& argc, char**& argv)
|
||||
{
|
||||
print_license();
|
||||
|
||||
static const char* short_options = "nh";
|
||||
|
||||
#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
|
||||
|
||||
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 );
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue