From: Maxim Mamontov Date: Sat, 10 Aug 2013 07:03:42 +0000 (+0300) Subject: Cosmetic changes. X-Git-Url: https://git.stg.codes/stg.git/commitdiff_plain/dd4d8887d9e281e81c4cd511026ed44e7dcf68b4 Cosmetic changes. --- diff --git a/projects/stargazer/plugins/store/postgresql/postgresql_store.cpp b/projects/stargazer/plugins/store/postgresql/postgresql_store.cpp index dd2fbbab..aabce23b 100644 --- a/projects/stargazer/plugins/store/postgresql/postgresql_store.cpp +++ b/projects/stargazer/plugins/store/postgresql/postgresql_store.cpp @@ -38,16 +38,15 @@ * */ -#include -#include -#include - -#include +#include "postgresql_store.h" #include "stg/module_settings.h" #include "stg/plugin_creator.h" -#include "postgresql_store_utils.h" -#include "postgresql_store.h" + +#include + +#include +#include namespace { @@ -93,37 +92,25 @@ pthread_mutex_destroy(&mutex); int POSTGRESQL_STORE::ParseSettings() { std::vector::iterator i; -std::string s; for(i = settings.moduleParams.begin(); i != settings.moduleParams.end(); ++i) { - s = i->param; - std::transform(s.begin(), s.end(), s.begin(), ToLower()); + std::string param(ToLower(i->param)); if (s == "server") - { server = *(i->value.begin()); - } - if (s == "database") - { + else if (s == "database") database = *(i->value.begin()); - } - if (s == "user") - { + else if (s == "user") user = *(i->value.begin()); - } - if (s == "password") - { + else if (s == "password") password = *(i->value.begin()); - } - if (s == "retries") - { + else if (s == "retries") if (str2x(*(i->value.begin()), retries)) { strError = "Invalid 'retries' value"; printfd(__FILE__, "POSTGRESQL_STORE::ParseSettings(): '%s'\n", strError.c_str()); return -1; } - } } clientEncoding = "KOI8"; diff --git a/projects/stargazer/plugins/store/postgresql/postgresql_store_utils.cpp b/projects/stargazer/plugins/store/postgresql/postgresql_store_utils.cpp index f5dec89f..ef705053 100644 --- a/projects/stargazer/plugins/store/postgresql/postgresql_store_utils.cpp +++ b/projects/stargazer/plugins/store/postgresql/postgresql_store_utils.cpp @@ -26,14 +26,15 @@ * */ +#include "postgresql_store.h" + +#include "stg/common.h" + #include #include #include -#include "stg/common.h" -#include "postgresql_store.h" - extern volatile time_t stgTime; int POSTGRESQL_STORE::StartTransaction() const @@ -93,10 +94,10 @@ int error = 0; char * buf = new char[(value.length() << 1) + 1]; PQescapeStringConn(connection, - buf, - value.c_str(), - value.length(), - &error); + buf, + value.c_str(), + value.length(), + &error); if (error) { @@ -114,7 +115,6 @@ return 0; std::string POSTGRESQL_STORE::Int2TS(time_t ts) const { -char buf[32]; struct tm brokenTime; brokenTime.tm_wday = 0; @@ -123,6 +123,7 @@ brokenTime.tm_isdst = 0; gmtime_r(&ts, &brokenTime); +char buf[32]; strftime(buf, 32, "%Y-%m-%d %H:%M:%S", &brokenTime); return buf; @@ -160,8 +161,6 @@ if (year) else { time_t curTime = stgTime; - /*time(&curTime);*/ - localtime_r(&curTime, &brokenTime); } @@ -173,4 +172,3 @@ strftime(buf, 32, "%Y-%m-%d", &brokenTime); date = buf; } - diff --git a/projects/stargazer/plugins/store/postgresql/postgresql_store_utils.h b/projects/stargazer/plugins/store/postgresql/postgresql_store_utils.h deleted file mode 100644 index 4ffa6ecf..00000000 --- a/projects/stargazer/plugins/store/postgresql/postgresql_store_utils.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef POSTGRESQL_UTILS_STORE_H -#define POSTGRESQL_UTILS_STORE_H - -#include - -struct ToLower : public std::unary_function -{ -char operator() (char c) const { return static_cast(std::tolower(c)); } -}; - -#endif