summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJuergen Gehring <juergen.gehring@bmw.de>2017-06-19 07:47:01 -0700
committerJuergen Gehring <juergen.gehring@bmw.de>2017-06-19 07:47:01 -0700
commit008f6c11f5371e93c06b3ed337326008d2031084 (patch)
treef25b96bab93d4b71496793d5944e054fc8d303af /src
parent66de998220d90116aa603d7458e245fe6094b4eb (diff)
downloadgenivi-common-api-runtime-008f6c11f5371e93c06b3ed337326008d2031084.tar.gz
CommonAPI 3.1.123.1.12
Diffstat (limited to 'src')
-rw-r--r--src/CommonAPI/Address.cpp7
-rw-r--r--src/CommonAPI/IniFileReader.cpp103
-rw-r--r--src/CommonAPI/Logger.cpp2
-rw-r--r--src/CommonAPI/LoggerImpl.cpp2
-rw-r--r--src/CommonAPI/Proxy.cpp8
-rw-r--r--src/CommonAPI/Runtime.cpp8
6 files changed, 73 insertions, 57 deletions
diff --git a/src/CommonAPI/Address.cpp b/src/CommonAPI/Address.cpp
index 280c0be..a80b2cf 100644
--- a/src/CommonAPI/Address.cpp
+++ b/src/CommonAPI/Address.cpp
@@ -75,7 +75,10 @@ Address::getAddress() const {
void
Address::setAddress(const std::string &_address) {
std::string itsDomain, itsInterface, itsVersion, itsInstance;
- std::size_t itsDomainPos, itsInterfacePos, itsVersionPos, itsInstancePos;
+ std::size_t itsDomainPos(0);
+ std::size_t itsInterfacePos(0);
+ std::size_t itsVersionPos(0);
+ std::size_t itsInstancePos(0);
bool isValid(true);
itsDomainPos = _address.find(':');
@@ -114,7 +117,7 @@ Address::setAddress(const std::string &_address) {
isValid = false;
if(isValid) {
for (auto it = itsVersion.begin()+1; it != itsVersion.end(); ++it) {
- if (!isdigit(*it) && *it != '_') {
+ if (!isdigit(static_cast<unsigned char>(*it)) && *it != '_') {
isValid = false;
break;
}
diff --git a/src/CommonAPI/IniFileReader.cpp b/src/CommonAPI/IniFileReader.cpp
index c91e91f..94057e0 100644
--- a/src/CommonAPI/IniFileReader.cpp
+++ b/src/CommonAPI/IniFileReader.cpp
@@ -29,65 +29,66 @@ IniFileReader::Section::getValue(const std::string &_key) const {
bool
IniFileReader::load(const std::string &_path) {
std::ifstream configStream(_path);
- if (configStream.is_open()) {
- //COMMONAPI_INFO("Loading ini file from ", _path);
+ if (!configStream.is_open()) {
+ COMMONAPI_ERROR("Failed to load ini file: ", _path);
+ return false;
+ }
- int lineCounter(0);
- std::string currentSectionName;
- std::shared_ptr<Section> currentSection;
+ int lineCounter(0);
+ std::string currentSectionName;
+ std::shared_ptr<Section> currentSection;
- while (!configStream.eof()) {
- std::string line;
- std::getline(configStream, line);
- lineCounter++;
+ while (!configStream.eof()) {
+ std::string line;
+ std::getline(configStream, line);
+ lineCounter++;
- trim(line);
+ trim(line);
- std::size_t start = line.find('[');
- if (start == 0) {
- std::size_t end = line.find(']');
- if (end != line.npos) {
- currentSectionName = line.substr(++start, --end);
- if (sections_.end() == sections_.find(currentSectionName)) {
- currentSection = std::make_shared<Section>();
- if (currentSection) {
- sections_[currentSectionName] = currentSection;
- }
- } else {
- COMMONAPI_ERROR("Double definition of section \'",
- currentSectionName,
- "\' ignoring definition (line ",
- lineCounter,
- ")");
- currentSection = nullptr;
+ std::size_t start = line.find('[');
+ if (start == 0) {
+ std::size_t end = line.find(']');
+ if (end != line.npos) {
+ currentSectionName = line.substr(++start, --end);
+ if (sections_.end() == sections_.find(currentSectionName)) {
+ currentSection = std::make_shared<Section>();
+ if (currentSection) {
+ sections_[currentSectionName] = currentSection;
}
} else {
- COMMONAPI_ERROR("Missing \']\' in section definition (line ",
- lineCounter, ")");
+ COMMONAPI_ERROR("Double definition of section \'",
+ currentSectionName,
+ "\' ignoring definition (line ",
+ lineCounter,
+ ")");
+ currentSection = nullptr;
}
- } else if (currentSection) {
- std::size_t pos = line.find('=');
- if (pos != line.npos) {
- std::string key = line.substr(0, pos);
- trim(key);
- if (currentSection->mappings_.end()
- != currentSection->mappings_.find(key)) {
- COMMONAPI_ERROR("Double definition for key \'",
- key,
- "'\' in section \'",
- currentSectionName,
- "\' (line ",
- lineCounter,
- ")");
- } else {
- std::string value = line.substr(pos+1);
- trim(value);
- currentSection->mappings_[key] = value;
- }
- } else if (line.size() > 0) {
- COMMONAPI_ERROR("Missing \'=\' in key=value definition (line ",
- lineCounter, ")");
+ } else {
+ COMMONAPI_ERROR("Missing \']\' in section definition (line ",
+ lineCounter, ")");
+ }
+ } else if (currentSection) {
+ std::size_t pos = line.find('=');
+ if (pos != line.npos) {
+ std::string key = line.substr(0, pos);
+ trim(key);
+ if (currentSection->mappings_.end()
+ != currentSection->mappings_.find(key)) {
+ COMMONAPI_ERROR("Double definition for key \'",
+ key,
+ "'\' in section \'",
+ currentSectionName,
+ "\' (line ",
+ lineCounter,
+ ")");
+ } else {
+ std::string value = line.substr(pos+1);
+ trim(value);
+ currentSection->mappings_[key] = value;
}
+ } else if (line.size() > 0) {
+ COMMONAPI_ERROR("Missing \'=\' in key=value definition (line ",
+ lineCounter, ")");
}
}
}
diff --git a/src/CommonAPI/Logger.cpp b/src/CommonAPI/Logger.cpp
index 8d5c18f..268be6f 100644
--- a/src/CommonAPI/Logger.cpp
+++ b/src/CommonAPI/Logger.cpp
@@ -6,7 +6,7 @@
#include <CommonAPI/Logger.hpp>
#include <CommonAPI/Runtime.hpp>
-namespace CommonAPI {;
+namespace CommonAPI {
void
Logger::init(bool _useConsole, const std::string &_fileName, bool _useDlt, const std::string &_level) {
LoggerImpl::init(_useConsole, _fileName, _useDlt, _level);
diff --git a/src/CommonAPI/LoggerImpl.cpp b/src/CommonAPI/LoggerImpl.cpp
index 28143bf..fabb109 100644
--- a/src/CommonAPI/LoggerImpl.cpp
+++ b/src/CommonAPI/LoggerImpl.cpp
@@ -10,7 +10,7 @@
#include <CommonAPI/Runtime.hpp>
#endif
-namespace CommonAPI {;
+namespace CommonAPI {
#if defined(USE_CONSOLE) || defined(USE_FILE)
std::mutex LoggerImpl::mutex_;
diff --git a/src/CommonAPI/Proxy.cpp b/src/CommonAPI/Proxy.cpp
index f611059..6e22f5e 100644
--- a/src/CommonAPI/Proxy.cpp
+++ b/src/CommonAPI/Proxy.cpp
@@ -7,9 +7,17 @@
namespace CommonAPI {
+Proxy::~Proxy() {
+ completed_.set_value();
+}
+
const Address &
Proxy::getAddress() const {
return address_;
}
+std::future<void> Proxy::getCompletionFuture() {
+ return completed_.get_future();
+}
+
} // namespace CommonAPI
diff --git a/src/CommonAPI/Runtime.cpp b/src/CommonAPI/Runtime.cpp
index 221264c..b9124cd 100644
--- a/src/CommonAPI/Runtime.cpp
+++ b/src/CommonAPI/Runtime.cpp
@@ -150,6 +150,7 @@ bool
Runtime::readConfiguration() {
#define MAX_PATH_LEN 255
std::string config;
+ bool tryLoadConfig(true);
char currentDirectory[MAX_PATH_LEN];
#ifdef _WIN32
if (GetCurrentDirectory(MAX_PATH_LEN, currentDirectory)) {
@@ -163,11 +164,14 @@ Runtime::readConfiguration() {
struct stat s;
if (stat(usedConfig_.c_str(), &s) != 0) {
usedConfig_ = defaultConfig_;
+ if (stat(usedConfig_.c_str(), &s) != 0) {
+ tryLoadConfig = false;
+ }
}
}
IniFileReader reader;
- if (!reader.load(usedConfig_))
+ if (tryLoadConfig && !reader.load(usedConfig_))
return false;
std::string itsConsole("true");
@@ -367,7 +371,7 @@ Runtime::loadLibrary(const std::string &_library) {
// Check the version information
while (soStart < itsLibrary.length()) {
if (itsLibrary[soStart] != '.'
- && !std::isdigit(itsLibrary[soStart])) {
+ && !std::isdigit(static_cast<unsigned char>(itsLibrary[soStart]))) {
break;
}
soStart++;