63 lines
1.5 KiB
C++
63 lines
1.5 KiB
C++
|
|
|
|
#include <QCoreApplication>
|
|
#include <QStringList>
|
|
#include <QHostAddress>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include "tetra_if.h"
|
|
|
|
#include <NGLLogger/NGLLoggerBootstrap.h>
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
QCoreApplication app(argc, argv);
|
|
|
|
|
|
NGL::NGLLoggerBootstrap::createNGLRootLogger("log4cxx_tetra.props", false);
|
|
|
|
NGL::INGLLogger &logger(NGL::NGLLoggerBootstrap::getNGLRootLogger());
|
|
|
|
const QStringList args = app.arguments().mid(1);
|
|
if (args.count() < 4)
|
|
TetraIF::usage();
|
|
QHostAddress tetra(args[0]);
|
|
if (tetra.isNull())
|
|
{
|
|
ERROR_LOG(logger) << "Invalid IP address " << args[0];
|
|
TetraIF::usage();
|
|
}
|
|
bool bOk;
|
|
unsigned short port = args[1].toUShort(&bOk);
|
|
if (!bOk)
|
|
{
|
|
ERROR_LOG(logger) << "Invalid IP port " << args[1];
|
|
TetraIF::usage();
|
|
}
|
|
unsigned short issi = args[2].toUShort(&bOk);
|
|
if (!bOk)
|
|
{
|
|
ERROR_LOG(logger) << "Invalid ISSI id " << args[2];
|
|
TetraIF::usage();
|
|
}
|
|
const QString mode = args[3].toLower();
|
|
if (mode != QLatin1String("listen") &&
|
|
mode != QLatin1String("send_random") &&
|
|
mode != QLatin1String("send_file"))
|
|
{
|
|
ERROR_LOG(logger) << "Invalid mode " << args[3];
|
|
TetraIF::usage();
|
|
}
|
|
TetraIF t(tetra, port, issi);
|
|
if (mode == QLatin1String("listen"))
|
|
t.listenMode(args.mid(4));
|
|
else if (mode == QLatin1String("send_random"))
|
|
t.randomMode(args.mid(4));
|
|
else if (mode == QLatin1String("send_file"))
|
|
t.fileMode(args.mid(4));
|
|
|
|
t.start();
|
|
|
|
return app.exec();
|
|
}
|