2 // Copyright (C) 2008 Francesco Salvestrini
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 2 of the License, or
7 // (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License along
15 // with this program; if not, write to the Free Software Foundation, Inc.,
16 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 #include "misc/debug.h"
27 #include "misc/environment.h"
32 << PACKAGE
<< " (" << PACKAGE_NAME
<< ") " << PACKAGE_VERSION
<< std::endl
34 << "Copyright (C) 2008 Francesco Salvestrini" << std::endl
36 << "This is free software. You may redistribute copies of it under the terms of" << std::endl
37 << "the GNU General Public License <http://www.gnu.org/licenses/gpl.html>." << std::endl
38 << "There is NO WARRANTY, to the extent permitted by law." << std::endl
;
45 << "Usage: " << PACKAGE
<< " [OPTION]... "<< std::endl
47 << "Options: " << std::endl
48 << " -t, --time-out=TIME start time-out (seconds)" << std::endl
49 << " -j, --job=FILE use FILE as job to distribute" << std::endl
50 << " -d, --debug enable debugging traces" << std::endl
51 << " -h, --help print this help, then exit" << std::endl
52 << " -V, --version print version number, then exit" << std::endl
54 << "Report bugs to <" << PACKAGE_BUGREPORT
<< ">" << std::endl
;
57 void hint(const std::string
& message
)
59 BUG_ON(message
.size() == 0);
62 << message
<< std::endl
63 << "Try `" << PACKAGE
<< " -h' for more information." << std::endl
;
66 int main(int argc
, char * argv
[])
69 int time_out
= 0; // XXX FIXME: Change to a constant
70 std::string job
= ""; // XXX FIXME: Change to a constant
73 //int digit_optind = 0;
75 //int this_option_optind = optind ? optind : 1;
78 static struct option long_options
[] = {
80 { "time-out", 1, 0, 't' },
81 { "debug", 0, 0, 'd' },
82 { "version", 0, 0, 'V' },
83 { "help", 0, 0, 'h' },
87 c
= getopt_long(argc
, argv
, "t:j:dVh",
88 long_options
, &option_index
);
97 // The current solution is ugly.
98 // Add modifiers (s, m, h) to
99 // this option in order to use
100 // different time granularity.
102 time_out
= atoi(optarg
);
104 hint("Wrong time-out value");
112 trace_level
= TR_LVL_DEBUG
;
121 hint("Unrecognized option");
130 // XXX FIXME: Add options related checks here
132 // Build configuration file path
133 std::string homedir
= Environment::get("HOME");
134 std::string confdir
=
138 std::string(PACKAGE_TARNAME
);
140 // Dump (acquired and derived) infos
141 TR_DBG("Time out: '%d'\n", time_out
);
142 TR_DBG("Job: '%s'\n", job
.c_str());
143 TR_DBG("Home directory: '%s'\n", homedir
.c_str());
144 TR_DBG("Configuration file: '%s'\n", confdir
.c_str());
146 // Do the supposed work