git.stg.codes
/
stg.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
23d052c
)
Cosmetic changes.
author
Maxim Mamontov
<faust.madf@gmail.com>
Sat, 10 Aug 2013 07:03:42 +0000
(10:03 +0300)
committer
Maxim Mamontov
<faust.madf@gmail.com>
Sat, 10 Aug 2013 07:03:42 +0000
(10:03 +0300)
projects/stargazer/plugins/store/postgresql/postgresql_store.cpp
patch
|
blob
|
history
projects/stargazer/plugins/store/postgresql/postgresql_store_utils.cpp
patch
|
blob
|
history
projects/stargazer/plugins/store/postgresql/postgresql_store_utils.h
[deleted file]
patch
|
blob
|
history
diff --git
a/projects/stargazer/plugins/store/postgresql/postgresql_store.cpp
b/projects/stargazer/plugins/store/postgresql/postgresql_store.cpp
index dd2fbbab7a168ed159feff737cf04e63be0f4898..aabce23b4dd396b36568f5aae8f752b453ba8d2a 100644
(file)
--- a/
projects/stargazer/plugins/store/postgresql/postgresql_store.cpp
+++ b/
projects/stargazer/plugins/store/postgresql/postgresql_store.cpp
@@
-38,16
+38,15
@@
*
*/
*
*/
-#include <string>
-#include <vector>
-#include <algorithm>
-
-#include <libpq-fe.h>
+#include "postgresql_store.h"
#include "stg/module_settings.h"
#include "stg/plugin_creator.h"
#include "stg/module_settings.h"
#include "stg/plugin_creator.h"
-#include "postgresql_store_utils.h"
-#include "postgresql_store.h"
+
+#include <libpq-fe.h>
+
+#include <string>
+#include <vector>
namespace
{
namespace
{
@@
-93,37
+92,25
@@
pthread_mutex_destroy(&mutex);
int POSTGRESQL_STORE::ParseSettings()
{
std::vector<PARAM_VALUE>::iterator i;
int POSTGRESQL_STORE::ParseSettings()
{
std::vector<PARAM_VALUE>::iterator i;
-std::string s;
for(i = settings.moduleParams.begin(); i != settings.moduleParams.end(); ++i)
{
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")
if (s == "server")
- {
server = *(i->value.begin());
server = *(i->value.begin());
- }
- if (s == "database")
- {
+ else if (s == "database")
database = *(i->value.begin());
database = *(i->value.begin());
- }
- if (s == "user")
- {
+ else if (s == "user")
user = *(i->value.begin());
user = *(i->value.begin());
- }
- if (s == "password")
- {
+ else if (s == "password")
password = *(i->value.begin());
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;
}
if (str2x(*(i->value.begin()), retries))
{
strError = "Invalid 'retries' value";
printfd(__FILE__, "POSTGRESQL_STORE::ParseSettings(): '%s'\n", strError.c_str());
return -1;
}
- }
}
clientEncoding = "KOI8";
}
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 f5dec89ff5ec223159423d3cabe3d2846157ed6e..ef70505389fc372eb2425398903256a805e4882f 100644
(file)
--- 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 <string>
#include <ctime>
#include <libpq-fe.h>
#include <string>
#include <ctime>
#include <libpq-fe.h>
-#include "stg/common.h"
-#include "postgresql_store.h"
-
extern volatile time_t stgTime;
int POSTGRESQL_STORE::StartTransaction() const
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,
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)
{
if (error)
{
@@
-114,7
+115,6
@@
return 0;
std::string POSTGRESQL_STORE::Int2TS(time_t ts) const
{
std::string POSTGRESQL_STORE::Int2TS(time_t ts) const
{
-char buf[32];
struct tm brokenTime;
brokenTime.tm_wday = 0;
struct tm brokenTime;
brokenTime.tm_wday = 0;
@@
-123,6
+123,7
@@
brokenTime.tm_isdst = 0;
gmtime_r(&ts, &brokenTime);
gmtime_r(&ts, &brokenTime);
+char buf[32];
strftime(buf, 32, "%Y-%m-%d %H:%M:%S", &brokenTime);
return buf;
strftime(buf, 32, "%Y-%m-%d %H:%M:%S", &brokenTime);
return buf;
@@
-160,8
+161,6
@@
if (year)
else
{
time_t curTime = stgTime;
else
{
time_t curTime = stgTime;
- /*time(&curTime);*/
-
localtime_r(&curTime, &brokenTime);
}
localtime_r(&curTime, &brokenTime);
}
@@
-173,4
+172,3
@@
strftime(buf, 32, "%Y-%m-%d", &brokenTime);
date = buf;
}
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
(file)
index
4ffa6ec
..0000000
--- 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 <functional>
-
-struct ToLower : public std::unary_function<char, char>
-{
-char operator() (char c) const { return static_cast<char>(std::tolower(c)); }
-};
-
-#endif