diff --git a/src/cli/Extract.cpp b/src/cli/Extract.cpp index 4ad658784..73581d8f1 100644 --- a/src/cli/Extract.cpp +++ b/src/cli/Extract.cpp @@ -15,6 +15,7 @@ * along with this program. If not, see . */ +#include #include #include "Extract.h" @@ -45,7 +46,7 @@ int Extract::execute(int argc, char **argv) const QStringList args = parser.positionalArguments(); if (args.size() != 1) { parser.showHelp(); - return 1; + return EXIT_FAILURE; } static QTextStream inputTextStream(stdin, QIODevice::ReadOnly); @@ -56,11 +57,11 @@ int Extract::execute(int argc, char **argv) QFile dbFile(databaseFilename); if (!dbFile.exists()) { qCritical("File %s does not exist.", qPrintable(databaseFilename)); - return 1; + return EXIT_FAILURE; } if (!dbFile.open(QIODevice::ReadOnly)) { qCritical("Unable to open file %s.", qPrintable(databaseFilename)); - return 1; + return EXIT_FAILURE; } KeePass2Reader reader; @@ -73,15 +74,15 @@ int Extract::execute(int argc, char **argv) if (reader.hasError()) { if (xmlData.isEmpty()) { qCritical("Error while reading the database:\n%s", qPrintable(reader.errorString())); - return 1; } else { qWarning("Error while parsing the database:\n%s\n", qPrintable(reader.errorString())); } + return EXIT_FAILURE; } QTextStream out(stdout); out << xmlData.constData() << "\n"; - return 0; + return EXIT_SUCCESS; } diff --git a/src/cli/Merge.cpp b/src/cli/Merge.cpp index bac8f4bd8..caa8d19c1 100644 --- a/src/cli/Merge.cpp +++ b/src/cli/Merge.cpp @@ -15,6 +15,8 @@ * along with this program. If not, see . */ +#include + #include "Merge.h" #include @@ -48,7 +50,7 @@ int Merge::execute(int argc, char** argv) const QStringList args = parser.positionalArguments(); if (args.size() != 2) { parser.showHelp(); - return 1; + return EXIT_FAILURE; } static QTextStream inputTextStream(stdin, QIODevice::ReadOnly); @@ -70,11 +72,11 @@ int Merge::execute(int argc, char** argv) QFile dbFile1(databaseFilename1); if (!dbFile1.exists()) { qCritical("File %s does not exist.", qPrintable(databaseFilename1)); - return 1; + return EXIT_FAILURE; } if (!dbFile1.open(QIODevice::ReadOnly)) { qCritical("Unable to open file %s.", qPrintable(databaseFilename1)); - return 1; + return EXIT_FAILURE; } KeePass2Reader reader1; @@ -82,7 +84,7 @@ int Merge::execute(int argc, char** argv) if (reader1.hasError()) { qCritical("Error while parsing the database:\n%s\n", qPrintable(reader1.errorString())); - return 1; + return EXIT_FAILURE; } @@ -90,11 +92,11 @@ int Merge::execute(int argc, char** argv) QFile dbFile2(databaseFilename2); if (!dbFile2.exists()) { qCritical("File %s does not exist.", qPrintable(databaseFilename2)); - return 1; + return EXIT_FAILURE; } if (!dbFile2.open(QIODevice::ReadOnly)) { qCritical("Unable to open file %s.", qPrintable(databaseFilename2)); - return 1; + return EXIT_FAILURE; } KeePass2Reader reader2; @@ -102,7 +104,7 @@ int Merge::execute(int argc, char** argv) if (reader2.hasError()) { qCritical("Error while parsing the database:\n%s\n", qPrintable(reader2.errorString())); - return 1; + return EXIT_FAILURE; } db1->merge(db2); @@ -110,7 +112,7 @@ int Merge::execute(int argc, char** argv) QSaveFile saveFile(databaseFilename1); if (!saveFile.open(QIODevice::WriteOnly)) { qCritical("Unable to open file %s for writing.", qPrintable(databaseFilename1)); - return 1; + return EXIT_FAILURE; } KeePass2Writer writer; @@ -118,15 +120,15 @@ int Merge::execute(int argc, char** argv) if (writer.hasError()) { qCritical("Error while updating the database:\n%s\n", qPrintable(writer.errorString())); - return 1; + return EXIT_FAILURE; } if (!saveFile.commit()) { qCritical("Error while updating the database:\n%s\n", qPrintable(writer.errorString())); - return 0; + return EXIT_FAILURE; } qDebug("Successfully merged the database files.\n"); - return 0; + return EXIT_SUCCESS; } diff --git a/src/cli/keepassxc-cli.cpp b/src/cli/keepassxc-cli.cpp index 7df4d7d87..e745dd09f 100644 --- a/src/cli/keepassxc-cli.cpp +++ b/src/cli/keepassxc-cli.cpp @@ -15,13 +15,14 @@ * along with this program. If not, see . */ -#include -#include +#include #include #include #include +#include +#include #include "config-keepassx.h" #include "core/Tools.h" #include "crypto/Crypto.h" @@ -34,7 +35,7 @@ int main(int argc, char **argv) if (!Crypto::init()) { qFatal("Fatal error while testing the cryptographic functions:\n%s", qPrintable(Crypto::errorString())); - return 1; + return EXIT_FAILURE; } QCoreApplication app(argc, argv); @@ -51,7 +52,7 @@ int main(int argc, char **argv) const QStringList args = parser.positionalArguments(); if (args.size() < 1) { parser.showHelp(); - return 1; + return EXIT_FAILURE; } QString commandName = args.at(0); @@ -74,6 +75,6 @@ int main(int argc, char **argv) qCritical("Invalid command %s.", qPrintable(commandName)); parser.showHelp(); - return 1; + return EXIT_FAILURE; }