Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
proview
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Esteban Blanc
proview
Commits
cba719f0
Commit
cba719f0
authored
Dec 14, 2016
by
Claes Sjofors
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Sev server, problem with storage of quotes in alarm texts fixed (refs #232)
parent
c07431ea
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
4 deletions
+41
-4
sev/lib/sev/src/sev_dbms.cpp
sev/lib/sev/src/sev_dbms.cpp
+39
-4
sev/lib/sev/src/sev_dbms.h
sev/lib/sev/src/sev_dbms.h
+2
-0
No files found.
sev/lib/sev/src/sev_dbms.cpp
View file @
cba719f0
...
...
@@ -1911,6 +1911,7 @@ int sev_dbms::store_event( pwr_tStatus *sts, int item_idx, sev_event *ep)
{
char
query
[
400
];
char
timstr
[
40
];
char
eventtext
[
100
];
int
rc
;
*
sts
=
time_AtoAscii
(
&
ep
->
time
,
time_eFormat_NumDateAndTime
,
timstr
,
sizeof
(
timstr
));
...
...
@@ -1973,6 +1974,9 @@ int sev_dbms::store_event( pwr_tStatus *sts, int item_idx, sev_event *ep)
if
(
found
)
return
1
;
// Replace " to \" in event text
string_to_mysqlstring
(
ep
->
eventtext
,
eventtext
,
sizeof
(
eventtext
));
if
(
m_items
[
item_idx
].
options
&
pwr_mSevOptionsMask_PosixTime
)
{
if
(
m_items
[
item_idx
].
options
&
pwr_mSevOptionsMask_HighTimeResolution
)
{
// Posix time, high resolution
...
...
@@ -1980,7 +1984,7 @@ int sev_dbms::store_event( pwr_tStatus *sts, int item_idx, sev_event *ep)
"eventid_idx, eventtext, eventname) values (%ld,%ld,%d,%d,%d,%d,%d,'%s','%s')"
,
m_items
[
item_idx
].
tablename
,
(
long
int
)
ep
->
time
.
tv_sec
,
(
long
int
)
ep
->
time
.
tv_nsec
,
ep
->
type
,
ep
->
eventprio
,
ep
->
eventid
.
Nix
,
ep
->
eventid
.
BirthTime
.
tv_sec
,
ep
->
eventid
.
Idx
,
e
p
->
e
venttext
,
ep
->
type
,
ep
->
eventprio
,
ep
->
eventid
.
Nix
,
ep
->
eventid
.
BirthTime
.
tv_sec
,
ep
->
eventid
.
Idx
,
eventtext
,
ep
->
eventname
);
}
else
{
...
...
@@ -1989,7 +1993,7 @@ int sev_dbms::store_event( pwr_tStatus *sts, int item_idx, sev_event *ep)
"eventid_idx, eventtext, eventname) values (%ld,%d,%d,%d,%d,%d,'%s','%s')"
,
m_items
[
item_idx
].
tablename
,
(
long
int
)
ep
->
time
.
tv_sec
,
ep
->
type
,
ep
->
eventprio
,
ep
->
eventid
.
Nix
,
ep
->
eventid
.
BirthTime
.
tv_sec
,
ep
->
eventid
.
Idx
,
e
p
->
e
venttext
,
ep
->
type
,
ep
->
eventprio
,
ep
->
eventid
.
Nix
,
ep
->
eventid
.
BirthTime
.
tv_sec
,
ep
->
eventid
.
Idx
,
eventtext
,
ep
->
eventname
);
}
}
...
...
@@ -2000,7 +2004,7 @@ int sev_dbms::store_event( pwr_tStatus *sts, int item_idx, sev_event *ep)
"eventid_idx, eventtext, eventname) values ('%s',%ld,%d,%d,%d,%d,%d,'%s','%s')"
,
m_items
[
item_idx
].
tablename
,
timstr
,
(
long
int
)
ep
->
time
.
tv_nsec
,
ep
->
type
,
ep
->
eventprio
,
ep
->
eventid
.
Nix
,
ep
->
eventid
.
BirthTime
.
tv_sec
,
ep
->
eventid
.
Idx
,
e
p
->
e
venttext
,
ep
->
type
,
ep
->
eventprio
,
ep
->
eventid
.
Nix
,
ep
->
eventid
.
BirthTime
.
tv_sec
,
ep
->
eventid
.
Idx
,
eventtext
,
ep
->
eventname
);
}
else
{
...
...
@@ -2009,7 +2013,7 @@ int sev_dbms::store_event( pwr_tStatus *sts, int item_idx, sev_event *ep)
"eventid_idx, eventtext, eventname) values ('%s',%d,%d,%d,%d,%d,'%s','%s')"
,
m_items
[
item_idx
].
tablename
,
timstr
,
ep
->
type
,
ep
->
eventprio
,
ep
->
eventid
.
Nix
,
ep
->
eventid
.
BirthTime
.
tv_sec
,
ep
->
eventid
.
Idx
,
e
p
->
e
venttext
,
ep
->
type
,
ep
->
eventprio
,
ep
->
eventid
.
Nix
,
ep
->
eventid
.
BirthTime
.
tv_sec
,
ep
->
eventid
.
Idx
,
eventtext
,
ep
->
eventname
);
}
...
...
@@ -4122,6 +4126,37 @@ int sev_dbms::commit_transaction()
return
1
;
}
void
sev_dbms
::
string_to_mysqlstring
(
char
*
in
,
char
*
out
,
int
size
)
{
char
*
s
,
*
t
;
for
(
s
=
in
,
t
=
out
;
*
s
;
s
++
,
t
++
)
{
if
(
*
s
==
'\"'
||
*
s
==
'\''
)
{
*
t
=
'\\'
;
t
++
;
}
*
t
=
*
s
;
if
(
t
-
out
>=
size
-
1
)
break
;
}
*
t
=
0
;
}
void
sev_dbms
::
mysqlstring_to_string
(
char
*
in
,
char
*
out
,
int
size
)
{
char
*
s
,
*
t
;
for
(
s
=
in
,
t
=
out
;
*
s
;
s
++
,
t
++
)
{
if
(
*
s
==
'\\'
&&
(
*
(
s
+
1
)
==
'\"'
||
*
(
s
+
1
)
==
'\''
))
s
++
;
*
t
=
*
s
;
if
(
t
-
out
>=
size
-
1
)
break
;
}
*
t
=
0
;
}
sev_dbms
::~
sev_dbms
()
{
printf
(
"Freeing memory
\n
"
);
...
...
sev/lib/sev/src/sev_dbms.h
View file @
cba719f0
...
...
@@ -207,6 +207,8 @@ class sev_dbms : public sev_db {
int
begin_transaction
();
int
commit_transaction
();
int
get_closest_time
(
char
*
tablename
,
unsigned
int
options
,
pwr_tTime
*
time
,
int
before
,
int
*
id
);
void
string_to_mysqlstring
(
char
*
in
,
char
*
out
,
int
size
);
void
mysqlstring_to_string
(
char
*
in
,
char
*
out
,
int
size
);
inline
char
*
create_colName
(
unsigned
int
index
,
char
*
attributename
)
{
static
char
colName
[
constMaxColNameLength
];
strncpy
(
colName
,
attributename
,
constMaxColNameLength
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment