diff options
author | Christian Pointner <equinox@anytun.org> | 2009-01-28 10:53:05 +0000 |
---|---|---|
committer | Christian Pointner <equinox@anytun.org> | 2009-01-28 10:53:05 +0000 |
commit | 9e0b7d81ba534ef469b751b59a6f222329f8f674 (patch) | |
tree | 9e2d1bd7769c6af6106ab93de16feb673ce08ca9 /src/anytun-controld.cpp | |
parent | setting device status to up after ifconfig (diff) |
merged options parser
Diffstat (limited to 'src/anytun-controld.cpp')
-rw-r--r-- | src/anytun-controld.cpp | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/src/anytun-controld.cpp b/src/anytun-controld.cpp index 64f7570..c73abbd 100644 --- a/src/anytun-controld.cpp +++ b/src/anytun-controld.cpp @@ -41,7 +41,7 @@ #include "log.h" #include "signalController.h" -#include "anyCtrOptions.h" +#include "options.h" #include "syncServer.h" #include "daemon.hpp" @@ -97,16 +97,26 @@ int main(int argc, char* argv[]) bool daemonized=false; try { - - if(!gOpt.parse(argc, argv)) + cLog.setLogName("anytun-controld"); + cLog.msg(Log::PRIO_NOTICE) << "anytun-controld started..."; + + try + { + bool result = gOpt.parse(argc, argv); + if(!result) { + cLog.msg(Log::PRIO_NOTICE) << "printing help text and exitting"; + gOpt.printUsage(); + exit(0); + } + } + catch(syntax_error& e) { + std::cerr << e << std::endl; + cLog.msg(Log::PRIO_NOTICE) << "exitting after syntax error"; gOpt.printUsage(); exit(-1); } - - cLog.setLogName("anytun-controld"); - cLog.msg(Log::PRIO_NOTICE) << "anytun-controld started..."; - + std::ifstream file( gOpt.getFileName().c_str() ); if( file.is_open() ) file.close(); |