From 931822cb32b82594418095a2d1fc13fdb46b9f68 Mon Sep 17 00:00:00 2001 From: Jan Darmochwal Date: Sat, 9 Oct 2010 11:58:54 +0200 Subject: Return EXIT_SUCCESS or EXIT_FAILURE in main() --- src/main.cpp | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 68f92ef..356b0b6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,18 +1,20 @@ -#include -#include "dialog.h" - -#include -#include -#include #include #include #include +#include #include +#include + +#include +#include +#include + +#include "command_line_options.h" +#include "dialog.h" +#include "globals.h" #include "save_restore_session.h" -#include "xsession.h" #include "vsession.h" -#include "globals.h" -#include "command_line_options.h" +#include "xsession.h" bool myLessThan(Session* a, Session* b) { return *a < *b; @@ -43,17 +45,17 @@ int main(int argc, char *argv[]) { if (cmdOptions.contains("error")) { std::cerr << usage; - return 1; + return EXIT_FAILURE; } if (cmdOptions.contains("usage")) { std::cout << usage; - return 0; + return EXIT_SUCCESS; } if (cmdOptions.contains("version")) { std::cout << version; - return 0; + return EXIT_SUCCESS; } if (cmdOptions.contains("file")) { @@ -61,15 +63,22 @@ int main(int argc, char *argv[]) { if (file.endsWith(".desktop")) { XSession s; - return s.init(file) && s.run(); + if (s.init(file) && s.run()) { + return EXIT_SUCCESS; + } + // TODO: error message + return EXIT_FAILURE; } else if (file.endsWith(".xml")) { // our XML-files can contain multiple sessions // let's just take the first one Session* s(VSession::readXmlFile(file).value(0)); - return s && s->run(); + if (s && s->run()) { + return EXIT_SUCCESS; + } + return EXIT_FAILURE; } else { std::cerr << "not a valid session file" << std::endl; - return 1; + return EXIT_FAILURE; } } -- cgit v1.2.3-55-g7522