bug fix, exchanged std:string by QString, some code style changes
This commit is contained in:
parent
ab4775f6a0
commit
c6068689d5
5 changed files with 238 additions and 139 deletions
|
@ -567,6 +567,6 @@ CConnectionLessChannel::CConnectionLessChannel()
|
||||||
SIGNAL ( CLRegisterServerReceived ( CHostAddress, CServerCoreInfo ) ) );
|
SIGNAL ( CLRegisterServerReceived ( CHostAddress, CServerCoreInfo ) ) );
|
||||||
|
|
||||||
QObject::connect( &Protocol,
|
QObject::connect( &Protocol,
|
||||||
SIGNAL ( CLSendEmptyMes ( CHostAddress, CHostAddress ) ),
|
SIGNAL ( CLSendEmptyMes ( CHostAddress ) ),
|
||||||
SIGNAL ( CLSendEmptyMes ( CHostAddress, CHostAddress ) ) );
|
SIGNAL ( CLSendEmptyMes ( CHostAddress ) ) );
|
||||||
}
|
}
|
||||||
|
|
|
@ -224,8 +224,7 @@ signals:
|
||||||
void CLPingReceived ( CHostAddress InetAddr, int iMs );
|
void CLPingReceived ( CHostAddress InetAddr, int iMs );
|
||||||
void CLRegisterServerReceived ( CHostAddress InetAddr,
|
void CLRegisterServerReceived ( CHostAddress InetAddr,
|
||||||
CServerCoreInfo ServerInfo );
|
CServerCoreInfo ServerInfo );
|
||||||
void CLSendEmptyMes ( CHostAddress InetAddr,
|
void CLSendEmptyMes ( CHostAddress TargetInetAddr );
|
||||||
CHostAddress TargetInetAddr );
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
33
src/global.h
33
src/global.h
|
@ -250,13 +250,34 @@ public:
|
||||||
|
|
||||||
/* Prototypes for global functions ********************************************/
|
/* Prototypes for global functions ********************************************/
|
||||||
// command line parsing, TODO do not declare functions globally but in a class
|
// command line parsing, TODO do not declare functions globally but in a class
|
||||||
std::string UsageArguments ( char** argv );
|
QString UsageArguments ( char** argv );
|
||||||
bool GetFlagArgument ( char** argv, int& i, std::string strShortOpt, std::string strLongOpt );
|
|
||||||
bool GetStringArgument ( int argc, char** argv, int& i, std::string strShortOpt, std::string strLongOpt, std::string& strArg );
|
bool GetFlagArgument ( char** argv,
|
||||||
bool GetNumericArgument ( int argc, char** argv, int& i, std::string strShortOpt, std::string strLongOpt, double rRangeStart, double rRangeStop, double& rValue);
|
int& i,
|
||||||
|
QString strShortOpt,
|
||||||
|
QString strLongOpt );
|
||||||
|
|
||||||
|
bool GetStringArgument ( QTextStream& tsConsole,
|
||||||
|
int argc,
|
||||||
|
char** argv,
|
||||||
|
int& i,
|
||||||
|
QString strShortOpt,
|
||||||
|
QString strLongOpt,
|
||||||
|
QString& strArg );
|
||||||
|
|
||||||
|
bool GetNumericArgument ( QTextStream& tsConsole,
|
||||||
|
int argc,
|
||||||
|
char** argv,
|
||||||
|
int& i,
|
||||||
|
QString strShortOpt,
|
||||||
|
QString strLongOpt,
|
||||||
|
double rRangeStart,
|
||||||
|
double rRangeStop,
|
||||||
|
double& rValue);
|
||||||
|
|
||||||
// posting a window message
|
// posting a window message
|
||||||
void PostWinMessage ( const _MESSAGE_IDENT MessID, const int iMessageParam = 0,
|
void PostWinMessage ( const _MESSAGE_IDENT MessID,
|
||||||
const int iChanNum = 0 );
|
const int iMessageParam = 0,
|
||||||
|
const int iChanNum = 0 );
|
||||||
|
|
||||||
#endif /* !defined ( GLOBAL_H__3B123453_4344_BB2B_23E7A0D31912__INCLUDED_ ) */
|
#endif /* !defined ( GLOBAL_H__3B123453_4344_BB2B_23E7A0D31912__INCLUDED_ ) */
|
||||||
|
|
329
src/main.cpp
329
src/main.cpp
|
@ -25,7 +25,7 @@
|
||||||
#include <qapplication.h>
|
#include <qapplication.h>
|
||||||
#include <qmessagebox.h>
|
#include <qmessagebox.h>
|
||||||
#include <qdir.h>
|
#include <qdir.h>
|
||||||
#include <iostream>
|
#include <qtextstream.h>
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "llconclientdlg.h"
|
#include "llconclientdlg.h"
|
||||||
#include "llconserverdlg.h"
|
#include "llconserverdlg.h"
|
||||||
|
@ -35,28 +35,36 @@
|
||||||
|
|
||||||
// Implementation **************************************************************
|
// Implementation **************************************************************
|
||||||
// these pointers are only used for the post-event routine
|
// these pointers are only used for the post-event routine
|
||||||
QApplication* pApp = NULL;
|
QApplication* pApp = NULL;
|
||||||
QDialog* pMainWindow = NULL;
|
QDialog* pMainWindow = NULL;
|
||||||
|
|
||||||
|
|
||||||
int main ( int argc, char** argv )
|
int main ( int argc, char** argv )
|
||||||
{
|
{
|
||||||
std::string strArgument;
|
#ifdef _WIN32
|
||||||
|
// no console on windows -> just write in string and dump it
|
||||||
|
QString strDummySink;
|
||||||
|
QTextStream tsConsole ( &strDummySink );
|
||||||
|
#else
|
||||||
|
QTextStream tsConsole ( stdout );
|
||||||
|
#endif
|
||||||
|
QString strArgument;
|
||||||
double rDbleArgument;
|
double rDbleArgument;
|
||||||
|
|
||||||
// check if server or client application shall be started
|
// initialize all flags and string which might be changed by command line
|
||||||
bool bIsClient = true;
|
// arguments
|
||||||
bool bUseGUI = true;
|
bool bIsClient = true;
|
||||||
bool bConnectOnStartup = false;
|
bool bUseGUI = true;
|
||||||
bool bDisalbeLEDs = false;
|
bool bConnectOnStartup = false;
|
||||||
bool bIsCentralServer = false;
|
bool bDisalbeLEDs = false;
|
||||||
quint16 iPortNumber = LLCON_DEFAULT_PORT_NUMBER;
|
bool bIsCentralServer = false;
|
||||||
std::string strIniFileName = "";
|
quint16 iPortNumber = LLCON_DEFAULT_PORT_NUMBER;
|
||||||
std::string strHTMLStatusFileName = "";
|
QString strIniFileName = "";
|
||||||
std::string strServerName = "";
|
QString strHTMLStatusFileName = "";
|
||||||
std::string strLoggingFileName = "";
|
QString strServerName = "";
|
||||||
std::string strHistoryFileName = "";
|
QString strLoggingFileName = "";
|
||||||
std::string strCentralServer = "";
|
QString strHistoryFileName = "";
|
||||||
|
QString strCentralServer = "";
|
||||||
|
|
||||||
// QT docu: argv()[0] is the program name, argv()[1] is the first
|
// QT docu: argv()[0] is the program name, argv()[1] is the first
|
||||||
// argument and argv()[argc()-1] is the last argument.
|
// argument and argv()[argc()-1] is the last argument.
|
||||||
|
@ -64,116 +72,173 @@ int main ( int argc, char** argv )
|
||||||
for ( int i = 1; i < argc; i++ )
|
for ( int i = 1; i < argc; i++ )
|
||||||
{
|
{
|
||||||
// Server mode flag ----------------------------------------------------
|
// Server mode flag ----------------------------------------------------
|
||||||
if ( GetFlagArgument ( argv, i, "-s", "--server" ) )
|
if ( GetFlagArgument ( argv,
|
||||||
|
i,
|
||||||
|
"-s",
|
||||||
|
"--server" ) )
|
||||||
{
|
{
|
||||||
bIsClient = false;
|
bIsClient = false;
|
||||||
cout << "- server mode chosen" << std::endl;
|
tsConsole << "- server mode chosen" << endl;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Use GUI flag --------------------------------------------------------
|
// Use GUI flag --------------------------------------------------------
|
||||||
if ( GetFlagArgument ( argv, i, "-n", "--nogui" ) )
|
if ( GetFlagArgument ( argv,
|
||||||
|
i,
|
||||||
|
"-n",
|
||||||
|
"--nogui" ) )
|
||||||
{
|
{
|
||||||
bUseGUI = false;
|
bUseGUI = false;
|
||||||
cout << "- no GUI mode chosen" << std::endl;
|
tsConsole << "- no GUI mode chosen" << endl;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Disable LEDs flag ---------------------------------------------------
|
// Disable LEDs flag ---------------------------------------------------
|
||||||
if ( GetFlagArgument ( argv, i, "-d", "--disableleds" ) )
|
if ( GetFlagArgument ( argv,
|
||||||
|
i,
|
||||||
|
"-d",
|
||||||
|
"--disableleds" ) )
|
||||||
{
|
{
|
||||||
bDisalbeLEDs = true;
|
bDisalbeLEDs = true;
|
||||||
cout << "- disable LEDs in main window" << std::endl;
|
tsConsole << "- disable LEDs in main window" << endl;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Use logging ---------------------------------------------------------
|
// Use logging ---------------------------------------------------------
|
||||||
if ( GetStringArgument ( argc, argv, i, "-l", "--log", strArgument ) )
|
if ( GetStringArgument ( tsConsole,
|
||||||
|
argc,
|
||||||
|
argv,
|
||||||
|
i,
|
||||||
|
"-l",
|
||||||
|
"--log",
|
||||||
|
strArgument ) )
|
||||||
{
|
{
|
||||||
strLoggingFileName = strArgument;
|
strLoggingFileName = strArgument;
|
||||||
cout << "- logging file name: " << strLoggingFileName << std::endl;
|
tsConsole << "- logging file name: " << strLoggingFileName << endl;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Port number ---------------------------------------------------------
|
// Port number ---------------------------------------------------------
|
||||||
if ( GetNumericArgument ( argc, argv, i, "-p", "--port",
|
if ( GetNumericArgument ( tsConsole,
|
||||||
0, 65535, rDbleArgument ) )
|
argc,
|
||||||
|
argv,
|
||||||
|
i,
|
||||||
|
"-p",
|
||||||
|
"--port",
|
||||||
|
0,
|
||||||
|
65535,
|
||||||
|
rDbleArgument ) )
|
||||||
{
|
{
|
||||||
iPortNumber = static_cast<quint16> ( rDbleArgument );
|
iPortNumber = static_cast<quint16> ( rDbleArgument );
|
||||||
cout << "- selected port number: " << iPortNumber << std::endl;
|
tsConsole << "- selected port number: " << iPortNumber << endl;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// HTML status file ----------------------------------------------------
|
// HTML status file ----------------------------------------------------
|
||||||
if ( GetStringArgument ( argc, argv, i, "-m", "--htmlstatus", strArgument ) )
|
if ( GetStringArgument ( tsConsole,
|
||||||
|
argc,
|
||||||
|
argv,
|
||||||
|
i,
|
||||||
|
"-m",
|
||||||
|
"--htmlstatus",
|
||||||
|
strArgument ) )
|
||||||
{
|
{
|
||||||
strHTMLStatusFileName = strArgument;
|
strHTMLStatusFileName = strArgument;
|
||||||
cout << "- HTML status file name: " << strHTMLStatusFileName << std::endl;
|
tsConsole << "- HTML status file name: " << strHTMLStatusFileName << endl;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( GetStringArgument ( argc, argv, i, "-a", "--servername", strArgument ) )
|
if ( GetStringArgument ( tsConsole,
|
||||||
|
argc,
|
||||||
|
argv,
|
||||||
|
i,
|
||||||
|
"-a",
|
||||||
|
"--servername",
|
||||||
|
strArgument ) )
|
||||||
{
|
{
|
||||||
strServerName = strArgument;
|
strServerName = strArgument;
|
||||||
cout << "- server name for HTML status file: " << strServerName << std::endl;
|
tsConsole << "- server name for HTML status file: " << strServerName << endl;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// HTML status file ----------------------------------------------------
|
// HTML status file ----------------------------------------------------
|
||||||
if ( GetStringArgument ( argc, argv, i, "-y", "--history", strArgument ) )
|
if ( GetStringArgument ( tsConsole,
|
||||||
|
argc,
|
||||||
|
argv,
|
||||||
|
i,
|
||||||
|
"-y",
|
||||||
|
"--history",
|
||||||
|
strArgument ) )
|
||||||
{
|
{
|
||||||
strHistoryFileName = strArgument;
|
strHistoryFileName = strArgument;
|
||||||
cout << "- history file name: " << strHistoryFileName << std::endl;
|
tsConsole << "- history file name: " << strHistoryFileName << endl;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Central server ------------------------------------------------------
|
// Central server ------------------------------------------------------
|
||||||
if ( GetStringArgument ( argc, argv, i, "-e", "--centralserver", strArgument ) )
|
if ( GetStringArgument ( tsConsole,
|
||||||
|
argc,
|
||||||
|
argv,
|
||||||
|
i,
|
||||||
|
"-e",
|
||||||
|
"--centralserver",
|
||||||
|
strArgument ) )
|
||||||
{
|
{
|
||||||
strCentralServer = strArgument;
|
strCentralServer = strArgument;
|
||||||
cout << "- central server: " << strCentralServer << std::endl;
|
tsConsole << "- central server: " << strCentralServer << endl;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Initialization file -------------------------------------------------
|
// Initialization file -------------------------------------------------
|
||||||
if ( GetStringArgument ( argc, argv, i, "-i", "--inifile", strArgument ) )
|
if ( GetStringArgument ( tsConsole,
|
||||||
|
argc,
|
||||||
|
argv,
|
||||||
|
i,
|
||||||
|
"-i",
|
||||||
|
"--inifile",
|
||||||
|
strArgument ) )
|
||||||
{
|
{
|
||||||
strIniFileName = strArgument;
|
strIniFileName = strArgument;
|
||||||
cout << "- initialization file name: " << strIniFileName << std::endl;
|
tsConsole << "- initialization file name: " << strIniFileName << endl;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Connect on startup --------------------------------------------------
|
// Connect on startup --------------------------------------------------
|
||||||
if ( GetFlagArgument ( argv, i, "-c", "--connect" ) )
|
if ( GetFlagArgument ( argv,
|
||||||
|
i,
|
||||||
|
"-c",
|
||||||
|
"--connect" ) )
|
||||||
{
|
{
|
||||||
bConnectOnStartup = true;
|
bConnectOnStartup = true;
|
||||||
cout << "- connect on startup enabled" << std::endl;
|
tsConsole << "- connect on startup enabled" << endl;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Help (usage) flag ---------------------------------------------------
|
// Help (usage) flag ---------------------------------------------------
|
||||||
if ( ( !strcmp ( argv[i], "--help" ) ) ||
|
if ( ( !strcmp ( argv[i], "--help" ) ) ||
|
||||||
( !strcmp ( argv[i], "-h" ) ) || ( !strcmp ( argv[i], "-?" ) ) )
|
( !strcmp ( argv[i], "-h" ) ) ||
|
||||||
|
( !strcmp ( argv[i], "-?" ) ) )
|
||||||
{
|
{
|
||||||
const std::string strHelp = UsageArguments(argv);
|
const QString strHelp = UsageArguments ( argv );
|
||||||
cout << strHelp;
|
tsConsole << strHelp << endl;
|
||||||
|
|
||||||
exit ( 1 );
|
exit ( 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unknown option ------------------------------------------------------
|
// Unknown option ------------------------------------------------------
|
||||||
cerr << argv[0] << ": ";
|
tsConsole << argv[0] << ": ";
|
||||||
cerr << "Unknown option '" << argv[i] << "' -- use '--help' for help"
|
tsConsole << "Unknown option '" <<
|
||||||
<< endl;
|
argv[i] << "' -- use '--help' for help" << endl;
|
||||||
|
|
||||||
// clicking on the Mac application bundle, the actual application
|
// clicking on the Mac application bundle, the actual application
|
||||||
// is called with weird command line args -> do not exit on these
|
// is called with weird command line args -> do not exit on these
|
||||||
|
@ -182,9 +247,16 @@ int main ( int argc, char** argv )
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// per definition: if we are in "GUI" server mode and no central server
|
||||||
|
// address is given, we use the default central server address
|
||||||
|
if ( !bIsClient && bUseGUI && strCentralServer.isEmpty() )
|
||||||
|
{
|
||||||
|
strCentralServer = DEFAULT_SERVER_ADDRESS;
|
||||||
|
}
|
||||||
|
|
||||||
// per definition: if we are in server mode and the central server address
|
// per definition: if we are in server mode and the central server address
|
||||||
// is the localhost address, we are in central server mode
|
// is the localhost address, we are in central server mode
|
||||||
if ( !bIsClient && !strCentralServer.empty() )
|
if ( !bIsClient && !strCentralServer.isEmpty() )
|
||||||
{
|
{
|
||||||
bIsCentralServer =
|
bIsCentralServer =
|
||||||
( !strCentralServer.compare ( "localhost" ) ||
|
( !strCentralServer.compare ( "localhost" ) ||
|
||||||
|
@ -213,6 +285,7 @@ int main ( int argc, char** argv )
|
||||||
qInitResources();
|
qInitResources();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// TEST -> activate the following line to activate the test bench,
|
// TEST -> activate the following line to activate the test bench,
|
||||||
//CTestbench Testbench ( "127.0.0.1", LLCON_DEFAULT_PORT_NUMBER );
|
//CTestbench Testbench ( "127.0.0.1", LLCON_DEFAULT_PORT_NUMBER );
|
||||||
|
|
||||||
|
@ -227,15 +300,13 @@ int main ( int argc, char** argv )
|
||||||
|
|
||||||
// load settings from init-file
|
// load settings from init-file
|
||||||
CSettings Settings ( &Client );
|
CSettings Settings ( &Client );
|
||||||
|
Settings.Load ( strIniFileName );
|
||||||
|
|
||||||
// TODO use QString
|
|
||||||
|
|
||||||
Settings.Load ( strIniFileName.c_str() );
|
|
||||||
|
|
||||||
// GUI object
|
// GUI object
|
||||||
CLlconClientDlg ClientDlg (
|
CLlconClientDlg ClientDlg (
|
||||||
&Client, bConnectOnStartup, bDisalbeLEDs,
|
&Client,
|
||||||
|
bConnectOnStartup,
|
||||||
|
bDisalbeLEDs,
|
||||||
0
|
0
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
// this somehow only works reliable on Windows
|
// this somehow only works reliable on Windows
|
||||||
|
@ -245,32 +316,26 @@ int main ( int argc, char** argv )
|
||||||
|
|
||||||
// set main window
|
// set main window
|
||||||
pMainWindow = &ClientDlg;
|
pMainWindow = &ClientDlg;
|
||||||
pApp = &app; // Needed for post-event routine
|
pApp = &app; // Needed for post-event routine
|
||||||
|
|
||||||
// show dialog
|
// show dialog
|
||||||
ClientDlg.show();
|
ClientDlg.show();
|
||||||
app.exec();
|
app.exec();
|
||||||
|
|
||||||
// save settings to init-file
|
// save settings to init-file
|
||||||
|
Settings.Save ( strIniFileName );
|
||||||
// TODO use QString
|
|
||||||
|
|
||||||
Settings.Save ( strIniFileName.c_str() );
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Server:
|
// Server:
|
||||||
// actual server object
|
// actual server object
|
||||||
|
CServer Server ( strLoggingFileName,
|
||||||
// TODO use QString
|
|
||||||
|
|
||||||
CServer Server ( strLoggingFileName.c_str(),
|
|
||||||
iPortNumber,
|
iPortNumber,
|
||||||
strHTMLStatusFileName.c_str(),
|
strHTMLStatusFileName,
|
||||||
strHistoryFileName.c_str(),
|
strHistoryFileName,
|
||||||
strServerName.c_str(),
|
strServerName,
|
||||||
bIsCentralServer,
|
bIsCentralServer,
|
||||||
strCentralServer.c_str() );
|
strCentralServer );
|
||||||
|
|
||||||
if ( bUseGUI )
|
if ( bUseGUI )
|
||||||
{
|
{
|
||||||
|
@ -279,7 +344,7 @@ int main ( int argc, char** argv )
|
||||||
|
|
||||||
// set main window
|
// set main window
|
||||||
pMainWindow = &ServerDlg;
|
pMainWindow = &ServerDlg;
|
||||||
pApp = &app; // needed for post-event routine
|
pApp = &app; // needed for post-event routine
|
||||||
|
|
||||||
// show dialog
|
// show dialog
|
||||||
ServerDlg.show();
|
ServerDlg.show();
|
||||||
|
@ -288,9 +353,7 @@ int main ( int argc, char** argv )
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// only start application without using the GUI
|
// only start application without using the GUI
|
||||||
cout <<
|
tsConsole << CAboutDlg::GetVersionAndNameStr ( false ) << endl;
|
||||||
CAboutDlg::GetVersionAndNameStr ( false ).toStdString() <<
|
|
||||||
std::endl;
|
|
||||||
|
|
||||||
app.exec();
|
app.exec();
|
||||||
}
|
}
|
||||||
|
@ -302,12 +365,15 @@ int main ( int argc, char** argv )
|
||||||
// show generic error
|
// show generic error
|
||||||
if ( bUseGUI )
|
if ( bUseGUI )
|
||||||
{
|
{
|
||||||
QMessageBox::critical (
|
QMessageBox::critical ( 0,
|
||||||
0, APP_NAME, generr.GetErrorText(), "Quit", 0 );
|
APP_NAME,
|
||||||
|
generr.GetErrorText(),
|
||||||
|
"Quit",
|
||||||
|
0 );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qDebug() << generr.GetErrorText();
|
tsConsole << generr.GetErrorText() << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -318,36 +384,37 @@ int main ( int argc, char** argv )
|
||||||
/******************************************************************************\
|
/******************************************************************************\
|
||||||
* Command Line Argument Parsing *
|
* Command Line Argument Parsing *
|
||||||
\******************************************************************************/
|
\******************************************************************************/
|
||||||
std::string UsageArguments ( char **argv )
|
QString UsageArguments ( char **argv )
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
"Usage: " + std::string ( argv[0] ) + " [option] [argument]\n"
|
"Usage: " + QString ( argv[0] ) + " [option] [argument]\n"
|
||||||
"Recognized options:\n"
|
"\nRecognized options:\n"
|
||||||
" -s, --server start server\n"
|
" -s, --server start server\n"
|
||||||
" -n, --nogui disable GUI (server only)\n"
|
" -n, --nogui disable GUI (server only)\n"
|
||||||
" -l, --log enable logging, set file name\n"
|
" -l, --log enable logging, set file name\n"
|
||||||
" -i, --inifile initialization file name (client only)\n"
|
" -i, --inifile initialization file name (client only)\n"
|
||||||
" -p, --port local port number (server only)\n"
|
" -p, --port local port number (server only)\n"
|
||||||
" -m, --htmlstatus enable HTML status file, set file name (server\n"
|
" -m, --htmlstatus enable HTML status file, set file name (server\n"
|
||||||
" only)\n"
|
" only)\n"
|
||||||
" -a, --servername server name, required for HTML status (server\n"
|
" -a, --servername server name, required for HTML status (server\n"
|
||||||
" only)\n"
|
" only)\n"
|
||||||
" -y, --history enable connection history and set file\n"
|
" -y, --history enable connection history and set file\n"
|
||||||
" name (server only)\n"
|
" name (server only)\n"
|
||||||
" -e, --centralserver address of the central server (server only)\n"
|
" -e, --centralserver address of the central server (server only)\n"
|
||||||
" -c, --connect connect to last server on startup (client\n"
|
" -c, --connect connect to last server on startup (client\n"
|
||||||
" only)\n"
|
" only)\n"
|
||||||
" -d, --disableleds disable LEDs in main window (client only)\n"
|
" -d, --disableleds disable LEDs in main window (client only)\n"
|
||||||
" -h, -?, --help this help text\n"
|
" -h, -?, --help this help text\n"
|
||||||
"Example: " + std::string ( argv[0] ) + " -l -inifile myinifile.ini\n";
|
"\nExample: " + QString ( argv[0] ) + " -l -inifile myinifile.ini\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GetFlagArgument ( char** argv,
|
bool GetFlagArgument ( char** argv,
|
||||||
int& i,
|
int& i,
|
||||||
std::string strShortOpt,
|
QString strShortOpt,
|
||||||
std::string strLongOpt )
|
QString strLongOpt )
|
||||||
{
|
{
|
||||||
if ( ( !strShortOpt.compare ( argv[i] ) ) || ( !strLongOpt.compare ( argv[i] ) ) )
|
if ( ( !strShortOpt.compare ( argv[i] ) ) ||
|
||||||
|
( !strLongOpt.compare ( argv[i] ) ) )
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -357,19 +424,21 @@ bool GetFlagArgument ( char** argv,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GetStringArgument ( int argc,
|
bool GetStringArgument ( QTextStream& tsConsole,
|
||||||
char** argv,
|
int argc,
|
||||||
int& i,
|
char** argv,
|
||||||
std::string strShortOpt,
|
int& i,
|
||||||
std::string strLongOpt,
|
QString strShortOpt,
|
||||||
std::string& strArg )
|
QString strLongOpt,
|
||||||
|
QString& strArg )
|
||||||
{
|
{
|
||||||
if ( ( !strShortOpt.compare ( argv[i] ) ) || ( !strLongOpt.compare ( argv[i] ) ) )
|
if ( ( !strShortOpt.compare ( argv[i] ) ) ||
|
||||||
|
( !strLongOpt.compare ( argv[i] ) ) )
|
||||||
{
|
{
|
||||||
if ( ++i >= argc )
|
if ( ++i >= argc )
|
||||||
{
|
{
|
||||||
cerr << argv[0] << ": ";
|
tsConsole << argv[0] << ": ";
|
||||||
cerr << "'" << strLongOpt << "' needs a string argument" << endl;
|
tsConsole << "'" << strLongOpt << "' needs a string argument" << endl;
|
||||||
exit ( 1 );
|
exit ( 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -383,32 +452,42 @@ bool GetStringArgument ( int argc,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GetNumericArgument ( int argc,
|
bool GetNumericArgument ( QTextStream& tsConsole,
|
||||||
char** argv,
|
int argc,
|
||||||
int& i,
|
char** argv,
|
||||||
std::string strShortOpt,
|
int& i,
|
||||||
std::string strLongOpt,
|
QString strShortOpt,
|
||||||
double rRangeStart,
|
QString strLongOpt,
|
||||||
double rRangeStop,
|
double rRangeStart,
|
||||||
double& rValue)
|
double rRangeStop,
|
||||||
|
double& rValue )
|
||||||
{
|
{
|
||||||
if ( ( !strShortOpt.compare ( argv[i] ) ) || ( !strLongOpt.compare ( argv[i] ) ) )
|
if ( ( !strShortOpt.compare ( argv[i] ) ) ||
|
||||||
|
( !strLongOpt.compare ( argv[i] ) ) )
|
||||||
{
|
{
|
||||||
if ( ++i >= argc )
|
if ( ++i >= argc )
|
||||||
{
|
{
|
||||||
cerr << argv[0] << ": ";
|
tsConsole << argv[0] << ": ";
|
||||||
cerr << "'" << strLongOpt << "' needs a numeric argument between "
|
|
||||||
<< rRangeStart << " and " << rRangeStop << endl;
|
tsConsole << "'" <<
|
||||||
|
strLongOpt << "' needs a numeric argument between " <<
|
||||||
|
rRangeStart << " and " << rRangeStop << endl;
|
||||||
|
|
||||||
exit ( 1 );
|
exit ( 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
char *p;
|
char *p;
|
||||||
rValue = strtod ( argv[i], &p );
|
rValue = strtod ( argv[i], &p );
|
||||||
if ( *p || rValue < rRangeStart || rValue > rRangeStop )
|
if ( *p ||
|
||||||
|
( rValue < rRangeStart ) ||
|
||||||
|
( rValue > rRangeStop ) )
|
||||||
{
|
{
|
||||||
cerr << argv[0] << ": ";
|
tsConsole << argv[0] << ": ";
|
||||||
cerr << "'" << strLongOpt << "' needs a numeric argument between "
|
|
||||||
<< rRangeStart << " and " << rRangeStop << endl;
|
tsConsole << "'" <<
|
||||||
|
strLongOpt << "' needs a numeric argument between " <<
|
||||||
|
rRangeStart << " and " << rRangeStop << endl;
|
||||||
|
|
||||||
exit ( 1 );
|
exit ( 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -425,8 +504,8 @@ bool GetNumericArgument ( int argc,
|
||||||
* Window Message System *
|
* Window Message System *
|
||||||
\******************************************************************************/
|
\******************************************************************************/
|
||||||
void PostWinMessage ( const _MESSAGE_IDENT MessID,
|
void PostWinMessage ( const _MESSAGE_IDENT MessID,
|
||||||
const int iMessageParam,
|
const int iMessageParam,
|
||||||
const int iChanNum )
|
const int iChanNum )
|
||||||
{
|
{
|
||||||
// first check if application is initialized
|
// first check if application is initialized
|
||||||
if ( pApp != NULL )
|
if ( pApp != NULL )
|
||||||
|
|
|
@ -339,8 +339,8 @@ void CServerLogging::AddNewConnection ( const QHostAddress& ClientInetAddr )
|
||||||
ClientInetAddr.toString() + ", connected";
|
ClientInetAddr.toString() + ", connected";
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
QTextStream tsConsoloeStream ( stdout );
|
QTextStream tsConsoleStream ( stdout );
|
||||||
tsConsoloeStream << strLogStr << endl; // on console
|
tsConsoleStream << strLogStr << endl; // on console
|
||||||
#endif
|
#endif
|
||||||
*this << strLogStr; // in log file
|
*this << strLogStr; // in log file
|
||||||
|
|
||||||
|
@ -354,8 +354,8 @@ void CServerLogging::AddServerStopped()
|
||||||
"-------------------------------------";
|
"-------------------------------------";
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
QTextStream tsConsoloeStream ( stdout );
|
QTextStream tsConsoleStream ( stdout );
|
||||||
tsConsoloeStream << strLogStr << endl; // on console
|
tsConsoleStream << strLogStr << endl; // on console
|
||||||
#endif
|
#endif
|
||||||
*this << strLogStr; // in log file
|
*this << strLogStr; // in log file
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue