1 #include <cstring> // for strrchr()
3 #include <unistd.h> // for getopt()
5 #include "parameters.h"
8 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simu);
12 const char* program_name;
14 const char* platform_file;
15 const char* application_file;
17 int help_requested = 0;
18 bool version_requested = false;
20 int parse_args(int* argc, char* argv[])
22 program_name = strrchr(argv[0], '/');
23 program_name = (program_name ? program_name + 1 : argv[0]);
27 while ((c = getopt(*argc, argv, "hV")) != -1) {
33 version_requested = true;
36 WARN1("invalid option -- '%c'", optopt);
40 if (version_requested || help_requested)
43 switch (*argc - optind) {
45 ERROR0("missing parameter -- <plaform_file>");
47 ERROR0("missing parameter -- <application_file>");
51 platform_file = argv[optind];
52 application_file = argv[optind + 1];
53 for (int i = optind + 2 ; i < *argc ; ++i)
54 WARN1("unused parameter -- \"%s\"", argv[i]);
63 INFO0(",----[ Simulation parameters ]");
64 INFO1("| platform_file.....: \"%s\"", platform_file);
65 INFO1("| application_file..: \"%s\"", application_file);
71 std::clog << "Usage: " << program_name << " [options] <platform_file> <application_file>\n";
72 std::clog << " -h print help and exit (use -hh or -hhh for extended help)\n";
73 if (help_requested < 1)
75 std::clog << " -V print version and exit\n";