code style, missing initializers and imports

This commit is contained in:
john30
2018-04-04 15:48:26 +02:00
parent d01385cb6d
commit bd5f800426
9 changed files with 34 additions and 29 deletions
+2 -2
View File
@@ -59,7 +59,7 @@ istream* FileReader::openFile(const string& filename, string* errorDescription,
return stream;
}
result_t FileReader::readFromStream(istream* stream, const string& filename, time_t& mtime, bool verbose,
result_t FileReader::readFromStream(istream* stream, const string& filename, const time_t& mtime, bool verbose,
map<string, string>* defaults, string* errorDescription, size_t* hash, size_t* size) {
if (hash) {
*hash = 0;
@@ -241,7 +241,7 @@ const string MappedFileReader::normalizeLanguage(const string& lang) {
return normLang;
}
result_t MappedFileReader::readFromStream(istream* stream, const string& filename, time_t& mtime, bool verbose,
result_t MappedFileReader::readFromStream(istream* stream, const string& filename, const time_t& mtime, bool verbose,
map<string, string>* defaults, string* errorDescription, size_t* hash, size_t* size) {
m_mutex.lock();
m_columnNames.clear();
+2 -2
View File
@@ -96,7 +96,7 @@ class FileReader {
* @param size optional pointer to a @a size_t value for storing the normalized size of the file, or NULL.
* @return @a RESULT_OK on success, or an error code.
*/
virtual result_t readFromStream(istream* stream, const string& filename, time_t& mtime, bool verbose,
virtual result_t readFromStream(istream* stream, const string& filename, const time_t& mtime, bool verbose,
map<string, string>* defaults, string* errorDescription, size_t* hash = NULL, size_t* size = NULL);
/**
@@ -204,7 +204,7 @@ class MappedFileReader : public FileReader {
static const string normalizeLanguage(const string& lang);
// @copydoc
result_t readFromStream(istream* stream, const string& filename, time_t& mtime, bool verbose,
result_t readFromStream(istream* stream, const string& filename, const time_t& mtime, bool verbose,
map<string, string>* defaults, string* errorDescription, size_t* hash = NULL, size_t* size = NULL) override;
/**
+3 -2
View File
@@ -2104,7 +2104,7 @@ bool MessageMap::extractDefaultsFromFilename(const string& filename, map<string,
return true;
}
result_t MessageMap::readFromStream(istream* stream, const string& filename, time_t& mtime, bool verbose,
result_t MessageMap::readFromStream(istream* stream, const string& filename, const time_t& mtime, bool verbose,
map<string, string>* defaults, string* errorDescription, size_t* hash, size_t* size) {
size_t localHash, localSize;
if (!hash) {
@@ -2113,7 +2113,8 @@ result_t MessageMap::readFromStream(istream* stream, const string& filename, tim
if (!size) {
size = &localSize;
}
result_t result = MappedFileReader::readFromStream(stream, filename, mtime, verbose, defaults, errorDescription, hash, size);
result_t result = MappedFileReader::readFromStream(stream, filename, mtime, verbose, defaults, errorDescription, hash,
size);
if (defaults) {
string circuit = AttributedItem::pluck("circuit", defaults);
if (!circuit.empty() && m_circuitData.find(circuit) == m_circuitData.end()) {
+1 -1
View File
@@ -1261,7 +1261,7 @@ class MessageMap : public MappedFileReader {
symbol_t* destAddress = NULL, unsigned int* software = NULL, unsigned int* hardware = NULL) const override;
// @copydoc
result_t readFromStream(istream* stream, const string& filename, time_t& mtime, bool verbose,
result_t readFromStream(istream* stream, const string& filename, const time_t& mtime, bool verbose,
map<string, string>* defaults, string* errorDescription, size_t* hash = NULL, size_t* size = NULL) override;
// @copydoc
+10 -10
View File
@@ -119,10 +119,10 @@ bool HttpClient::post(const string& uri, const string& body, string& response) {
}
const int indexToMonth[] = {
-1, -1, 2, 12, -1, -1, 1, -1, // 0-7
-1, -1, -1, -1, 7, -1, 6, 8, // 8-15
9, 5, 3, -1, 10, -1, 11, -1, // 16-23
-1, -1, 4, -1, -1, -1, -1, -1, // 24-31
-1, -1, 2, 12, -1, -1, 1, -1, // 0-7
-1, -1, -1, -1, 7, -1, 6, 8, // 8-15
9, 5, 3, -1, 10, -1, 11, -1, // 16-23
-1, -1, 4, -1, -1, -1, -1, -1, // 24-31
};
bool HttpClient::request(const string& method, const string& uri, const string& body, string& response, time_t* time) {
@@ -157,7 +157,7 @@ bool HttpClient::request(const string& method, const string& uri, const string&
pos += sent;
}
string result;
size_t pos = readUntil(" ", 4 * 1024, result); // max 4k headers
size_t pos = readUntil(" ", 4 * 1024, result); // max 4k headers
if (pos == string::npos || pos > 8 || result.substr(0, 5) != "HTTP/") {
disconnect();
response = "receive error (headers)";
@@ -169,13 +169,13 @@ bool HttpClient::request(const string& method, const string& uri, const string&
response = "receive error: " + result.substr(pos+1, endpos == string::npos ? endpos : endpos-pos-1);
return false;
}
pos = readUntil("\r\n\r\n", 4 * 1024, result); // max 4k headers
pos = readUntil("\r\n\r\n", 4 * 1024, result); // max 4k headers
if (pos == string::npos) {
disconnect();
response = "receive error (headers)";
return false;
}
string headers = result.substr(0, pos+2); // including final \r\n
string headers = result.substr(0, pos+2); // including final \r\n
const char* hdrs = headers.c_str();
response = result.substr(pos+4);
if (time) {
@@ -215,15 +215,15 @@ bool HttpClient::request(const string& method, const string& uri, const string&
if (t.tm_mday > 0 && t.tm_mon >= 0 && t.tm_year >= 0 && t.tm_hour >= 0 && t.tm_min >=0 && t.tm_sec >= 0) {
*time = timegm(&t);
}
};
}
}
pos = headers.find("\r\nContent-Length: "); // 16 chars
pos = headers.find("\r\nContent-Length: ");
if (pos == string::npos) {
disconnect();
return true;
}
char* strEnd = NULL;
unsigned long length = strtoul(hdrs+pos+strlen("\r\nContent-Length: "), &strEnd, 10);
unsigned long length = strtoul(hdrs + pos + strlen("\r\nContent-Length: "), &strEnd, 10);
if (strEnd == NULL || *strEnd != '\r') {
disconnect();
response = "invalid content length ";