mirror of
https://github.com/eclipse/paho.mqtt-sn.embedded-c.git
synced 2025-12-14 07:56:52 +01:00
Update: config file is a command line parameter.
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
#include <signal.h>
|
||||
#include <Timer.h>
|
||||
#include <exception>
|
||||
#include <getopt.h>
|
||||
#include "MQTTSNGWProcess.h"
|
||||
#include "Threading.h"
|
||||
|
||||
@@ -74,6 +75,18 @@ void Process::initialize(int argc, char** argv)
|
||||
signal(SIGINT, signalHandler);
|
||||
signal(SIGTERM, signalHandler);
|
||||
signal(SIGHUP, signalHandler);
|
||||
|
||||
_configFile = string(MQTTSNGW_CONFIG_DIRECTORY) + string(MQTTSNGW_CONFIG_FILE);
|
||||
|
||||
int opt;
|
||||
while ((opt = getopt(_argc, _argv, "f:")) != -1)
|
||||
{
|
||||
if ( opt == 'f' )
|
||||
{
|
||||
_configFile = string(optarg);
|
||||
}
|
||||
}
|
||||
WRITELOG("Using config file:[%s]\n", _configFile.c_str());
|
||||
}
|
||||
|
||||
int Process::getArgc()
|
||||
@@ -92,13 +105,11 @@ int Process::getParam(const char* parameter, char* value)
|
||||
char param[MQTTSNGW_PARAM_MAX];
|
||||
FILE *fp;
|
||||
|
||||
string filename = string(MQTTSNGW_CONFIG_DIRECTORY) + string(MQTTSNGW_CONFIG_FILE);
|
||||
|
||||
int i = 0, j = 0;
|
||||
|
||||
if ((fp = fopen(filename.c_str(), "r")) == NULL)
|
||||
if ((fp = fopen(_configFile.c_str(), "r")) == NULL)
|
||||
{
|
||||
WRITELOG("No config file:[%s]\n", filename.c_str());
|
||||
WRITELOG("No config file:[%s]\n", _configFile.c_str());
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user