64 lines
1.8 KiB
C++
64 lines
1.8 KiB
C++
#include "owlps-positioning.hh"
|
|
|
|
int main(int argc, char** argv)
|
|
{
|
|
|
|
po::options_description desc("Options");
|
|
po::options_description conf("Configuration Positioner");
|
|
po::options_description opt("Aide");
|
|
po::variables_map vm;
|
|
|
|
string file = DEFAULT_CONFIG_FILE;
|
|
int port, mport;
|
|
|
|
desc.add_options()
|
|
("help", "\t: Affichage de l'aide")
|
|
("file-conf,F", po::value<string>(), "\t: Fichier de configuration")
|
|
("input-topo,T", po::value<string>(), "\t: Input file topology")
|
|
("input-waypoint,W", po::value<string>(), "\t: Input file waypoint")
|
|
("input-refpoint,R", po::value<string>(), "\t: Input file reference point")
|
|
("input-ap,A", po::value<string>(), "\t: Input file accesspoint")
|
|
;
|
|
|
|
conf.add_options()
|
|
("Server.port", po::value<int>(&port) -> default_value(9902), "\t: Port du serveur")
|
|
("Server.mobile-port", po::value<int>(&mport) -> default_value(9903), "\t: Port d'envoi vers le mobile")
|
|
("BDD.name", po::value<string>(), "\t: Nom de la BdD")
|
|
("BDD.hostaddr", po::value<string>(), "\t: Adresse de l'hôte de la BdD")
|
|
("BDD.user", po::value<string>(), "\t: Nom de l'utilisateur de la BdD")
|
|
("BDD.passwd", po::value<string>(), "\t: Mot de passe de la BdD")
|
|
;
|
|
|
|
opt.add(desc).add(conf);
|
|
po::store(po::parse_command_line(argc, argv, desc), vm);
|
|
|
|
if (vm.count("file-conf"))
|
|
file = vm["file-conf"].as<string>();
|
|
|
|
ifstream ifs(file.c_str());
|
|
|
|
if (!ifs.is_open())
|
|
{
|
|
cerr << "Erreur lors de la lecture du fichier ! Le fichier n'existe pas ou ne peut être lu.\nUtilisation des valeurs par défaut..." << endl;
|
|
}
|
|
else
|
|
{
|
|
po::store(po::parse_config_file(ifs, conf), vm);
|
|
}
|
|
po::notify(vm);
|
|
|
|
if (vm.count("help"))
|
|
{
|
|
cout << opt << endl;
|
|
return 0;
|
|
}
|
|
|
|
Server server(port, mport);
|
|
|
|
if (server.init(vm)) return 1;
|
|
|
|
server.start();
|
|
|
|
return 0;
|
|
}
|