1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
/*
SPDX-FileCopyrightText: 2010 Joris Guisson <joris.guisson@gmail.com>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "ktcli.h"
#include <QCommandLineParser>
#include <QDir>
#include <util/error.h>
#include <util/functions.h>
#include <util/log.h>
#include <version.h>
#ifndef Q_OS_WIN
#include <csignal>
void signalhandler(int sig)
{
if (sig == SIGINT) {
qApp->quit();
}
}
#endif
using namespace bt;
using namespace Qt::Literals::StringLiterals;
int main(int argc, char **argv)
{
#ifndef Q_OS_WIN
signal(SIGINT, signalhandler);
#endif
try {
if (!bt::InitLibKTorrent()) {
fprintf(stderr, "Failed to initialize libktorrent\n");
return -1;
}
QCoreApplication::setApplicationName(u"ktcli"_s);
QCoreApplication::setApplicationVersion(bt::GetVersionString());
KTCLI app(argc, argv);
if (!app.start())
return -1;
else
return app.exec();
} catch (bt::Error &err) {
Out(SYS_GEN | LOG_IMPORTANT) << "Uncaught error: " << err.toString() << endl;
} catch (std::exception &err) {
Out(SYS_GEN | LOG_IMPORTANT) << "Uncaught error: " << err.what() << endl;
}
return -1;
}
|