PCAP/PDML Import: Reworked the test code to use the Ostinato QSettings
This commit is contained in:
parent
0274fd4479
commit
486fe5dcac
@ -3,36 +3,47 @@
|
||||
#include "pcapfileformat.h"
|
||||
#include "protocol.pb.h"
|
||||
#include "protocolmanager.h"
|
||||
#include "settings.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QFile>
|
||||
#include <QSettings>
|
||||
#include <QString>
|
||||
|
||||
extern ProtocolManager *OstProtocolManager;
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
QSettings *appSettings;
|
||||
|
||||
#if defined(Q_OS_WIN32)
|
||||
QString kGzipPathDefaultValue;
|
||||
QString kDiffPathDefaultValue;
|
||||
QString kAwkPathDefaultValue;
|
||||
#endif
|
||||
|
||||
int usage(int argc, char* argv[])
|
||||
{
|
||||
printf("usage:\n");
|
||||
printf("%s <command>\n", argv[0]);
|
||||
printf("command -\n");
|
||||
printf(" importpcap\n");
|
||||
|
||||
return 255;
|
||||
}
|
||||
|
||||
int testImportPcap(int argc, char* argv[])
|
||||
{
|
||||
bool isOk;
|
||||
QCoreApplication app(argc, argv);
|
||||
QString error;
|
||||
|
||||
if (argc != 2)
|
||||
if (argc != 3)
|
||||
{
|
||||
printf("%s <infile>\n", argv[0]);
|
||||
exit(255);
|
||||
printf("usage:\n");
|
||||
printf("%s importpcap <pcapfile>\n", argv[0]);
|
||||
return 255;
|
||||
}
|
||||
|
||||
OstProtocolManager = new ProtocolManager();
|
||||
|
||||
OstProto::StreamConfigList streams;
|
||||
QString inFile(argv[1]);
|
||||
|
||||
OstProtocolManager = new ProtocolManager();
|
||||
|
||||
OstProtoLib::setExternalApplicationPaths(
|
||||
"c:/Program Files/Wireshark/Tshark.exe",
|
||||
"d:/srivatsp/projects/ostinato/pdml/bin/gzip.exe",
|
||||
"d:/srivatsp/projects/ostinato/pdml/bin/diff.exe",
|
||||
"d:/srivatsp/projects/ostinato/pdml/bin/gawk.exe");
|
||||
QString inFile(argv[2]);
|
||||
|
||||
isOk = pcapFileFormat.openStreams(inFile, streams, error);
|
||||
if (!error.isEmpty())
|
||||
@ -42,7 +53,57 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
|
||||
if (!isOk)
|
||||
exit(1);
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
QCoreApplication app(argc, argv);
|
||||
int exitCode = 0;
|
||||
|
||||
// app init starts ...
|
||||
#if defined(Q_OS_WIN32)
|
||||
kGzipPathDefaultValue = app.applicationDirPath() + "/gzip.exe";
|
||||
kDiffPathDefaultValue = app.applicationDirPath() + "/diff.exe";
|
||||
kAwkPathDefaultValue = app.applicationDirPath() + "/gawk.exe";
|
||||
#endif
|
||||
|
||||
app.setApplicationName("Ostinato");
|
||||
app.setOrganizationName("Ostinato");
|
||||
|
||||
OstProtocolManager = new ProtocolManager();
|
||||
|
||||
/* (Portable Mode) If we have a .ini file in the same directory as the
|
||||
executable, we use that instead of the platform specific location
|
||||
and format for the settings */
|
||||
QString portableIni = QCoreApplication::applicationDirPath()
|
||||
+ "/ostinato.ini";
|
||||
if (QFile::exists(portableIni))
|
||||
appSettings = new QSettings(portableIni, QSettings::IniFormat);
|
||||
else
|
||||
appSettings = new QSettings();
|
||||
|
||||
OstProtoLib::setExternalApplicationPaths(
|
||||
appSettings->value(kTsharkPathKey, kTsharkPathDefaultValue).toString(),
|
||||
appSettings->value(kGzipPathKey, kGzipPathDefaultValue).toString(),
|
||||
appSettings->value(kDiffPathKey, kDiffPathDefaultValue).toString(),
|
||||
appSettings->value(kAwkPathKey, kAwkPathDefaultValue).toString());
|
||||
|
||||
// ... app init finished
|
||||
|
||||
//
|
||||
// identify and run specified test
|
||||
//
|
||||
if (argc < 2)
|
||||
exitCode = usage(argc, argv);
|
||||
else if (strcmp(argv[1],"importpcap") == 0)
|
||||
exitCode = testImportPcap(argc, argv);
|
||||
else
|
||||
exitCode = usage(argc, argv);
|
||||
|
||||
delete appSettings;
|
||||
return exitCode;
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
TEMPLATE = app
|
||||
CONFIG += qt console
|
||||
QT += xml network script
|
||||
INCLUDEPATH += "../rpc/" "../common/"
|
||||
INCLUDEPATH += "../rpc/" "../common/" "../client"
|
||||
win32 {
|
||||
LIBS += -lwpcap -lpacket
|
||||
CONFIG(debug, debug|release) {
|
||||
|
Loading…
Reference in New Issue
Block a user