Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
uniset2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UniSet project repositories
uniset2
Commits
b72b5783
Commit
b72b5783
authored
Jul 14, 2009
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rename Jrn to Storage family, add Makefile.am for build test
parent
4ff8b8fa
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
232 additions
and
163 deletions
+232
-163
JrnTest.cc
Utilities/JrnTests/JrnTest.cc
+10
-10
Makefile.am
Utilities/JrnTests/Makefile.am
+11
-0
Makefile.in
Utilities/JrnTests/Makefile.in
+0
-0
Makefile.am
Utilities/Makefile.am
+1
-1
Makefile.in
Utilities/Makefile.in
+2
-2
configure
configure
+2
-1
configure.ac
configure.ac
+1
-0
Storages.h
include/Storages.h
+19
-14
UniSetObject.h
include/UniSetObject.h
+1
-1
CycleStorage.cc
src/Various/CycleStorage.cc
+19
-131
Makefile.am
src/Various/Makefile.am
+2
-1
Makefile.in
src/Various/Makefile.in
+20
-2
TableStorage.cc
src/Various/TableStorage.cc
+144
-0
No files found.
Utilities/JrnTests/Jrn
t
est.cc
→
Utilities/JrnTests/Jrn
T
est.cc
View file @
b72b5783
...
...
@@ -26,7 +26,7 @@
#include "stdio.h"
#include "string.h"
#include "
Jrn
.h"
#include "
Storages
.h"
char
*
itoa
(
int
val
,
int
base
)
{
...
...
@@ -48,14 +48,14 @@ void testTable(void)
{
char
*
chr
=
new
char
[
2
];
char
*
val
=
new
char
[
2
];
StorageTabl
e
*
t
;
t
=
new
StorageTabl
e
(
"table.test"
,
6000
,
0
);
TableStorag
e
*
t
;
t
=
new
TableStorag
e
(
"table.test"
,
6000
,
0
);
int
i
;
printf
(
"testTable
\n
size = %d
\n
"
,
t
->
size
);
for
(
i
=
0
;
i
<
t
->
size
+
5
;
i
++
)
{
chr
[
0
]
=
i
%
256
;
if
(
t
->
AddRow
(
chr
,
chr
)
==
1
)
printf
(
"elem number %d - no space in
StorageTabl
e
\n
"
,
i
);
if
(
t
->
AddRow
(
chr
,
chr
)
==
1
)
printf
(
"elem number %d - no space in
TableStorag
e
\n
"
,
i
);
}
printf
(
"elements with values=keys added
\n
"
);
for
(
i
=
40
;
i
<
60
;
i
++
)
...
...
@@ -81,11 +81,11 @@ void testTable(void)
void
testJournal1
(
void
)
{
Cycle
Journal
*
j
;
Cycle
Storage
*
j
;
int
i
;
char
*
str
=
new
char
[
6
];
printf
(
"journal test 1
\n
"
);
j
=
new
Cycle
Journal
(
"journal.test"
,
2000000
,
0
);
j
=
new
Cycle
Storage
(
"journal.test"
,
2000000
,
0
);
printf
(
"size = %d
\n
"
,
j
->
size
);
for
(
i
=
1
;
i
<
30000
;
i
++
)
{
...
...
@@ -109,17 +109,17 @@ void testJournal1(void)
j
->
ViewRows
(
0
,
20
);
printf
(
"
\n
the same after reopen:
\n
"
);
delete
j
;
j
=
new
Cycle
Journal
(
"journal.test"
,
2000000
,
0
);
j
=
new
Cycle
Storage
(
"journal.test"
,
2000000
,
0
);
j
->
ViewRows
(
0
,
20
);
printf
(
"
\n
"
);
}
void
testJournal2
(
void
)
{
Cycle
Journal
*
j
;
Cycle
Storage
*
j
;
int
i
,
k
;
char
*
str
=
new
char
[
4
];
j
=
new
Cycle
Journal
(
"journal.test"
,
2000000
,
0
);
j
=
new
Cycle
Storage
(
"journal.test"
,
2000000
,
0
);
printf
(
"journal test 2 - checking number of iterations to find head/tail
\n
"
);
printf
(
"size = %d
\n\n
"
,
j
->
size
);
printf
(
"iterations = %d
\n
"
,
j
->
iter
);
...
...
@@ -131,7 +131,7 @@ void testJournal2(void)
j
->
AddRow
(
str
);
}
delete
j
;
j
=
new
Cycle
Journal
(
"journal.test"
,
2000000
,
0
);
j
=
new
Cycle
Storage
(
"journal.test"
,
2000000
,
0
);
printf
(
"iterations = %d
\n
"
,
j
->
iter
);
}
printf
(
"
\n
"
);
...
...
Utilities/JrnTests/Makefile.am
0 → 100644
View file @
b72b5783
############################################################################
# This file is part of the UniSet library #
############################################################################
bin_PROGRAMS
=
jrntest
jrntest_SOURCES
=
JrnTest.cc
jrntest_LDADD
=
$(top_builddir)
/lib/libUniSet.la
jrntest_CPPFLAGS
=
-I
$(top_builddir)
/include
include
$(top_builddir)/conf/setting.mk
Utilities/JrnTests/Makefile.in
0 → 100644
View file @
b72b5783
This diff is collapsed.
Click to expand it.
Utilities/Makefile.am
View file @
b72b5783
...
...
@@ -3,7 +3,7 @@
############################################################################
UTILS
=
scripts Admin NullController SViewer-text
\
InfoServer SMonit MBTester codegen
InfoServer SMonit MBTester codegen
JrnTests
#MapSourceParser ClassGen
if
DISABLE_MYSQL
...
...
Utilities/Makefile.in
View file @
b72b5783
...
...
@@ -67,7 +67,7 @@ AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \
ETAGS
=
etags
CTAGS
=
ctags
DIST_SUBDIRS
=
scripts Admin NullController SViewer-text InfoServer
\
SMonit MBTester codegen DBServer-MySQL
SMonit MBTester codegen
JrnTests
DBServer-MySQL
DISTFILES
=
$(DIST_COMMON)
$(DIST_SOURCES)
$(TEXINFOS)
$(EXTRA_DIST)
am__relativize
=
\
dir0
=
`
pwd
`
;
\
...
...
@@ -226,7 +226,7 @@ top_build_prefix = @top_build_prefix@
top_builddir
=
@top_builddir@
top_srcdir
=
@top_srcdir@
UTILS
=
scripts Admin NullController SViewer-text
\
InfoServer SMonit MBTester codegen
InfoServer SMonit MBTester codegen
JrnTests
@DISABLE_MYSQL_FALSE@
SUBDIRS
=
${
UTILS
}
DBServer-MySQL
#MapSourceParser ClassGen
...
...
configure
View file @
b72b5783
...
...
@@ -18579,7 +18579,7 @@ fi
done
ac_config_files
=
"
$ac_config_files
Makefile libUniSet.pc lib/Makefile IDL/Makefile IDL/UniSetTypes/Makefile IDL/Processes/Makefile IDL/Services/Makefile src/Communications/Makefile src/Communications/Modbus/Makefile src/IOs/Makefile src/Interfaces/Makefile src/ObjectRepository/Makefile src/Processes/Makefile src/Services/Makefile src/Threads/Makefile src/Timers/Makefile src/Various/Makefile src/Makefile include/Makefile include/modbus/Makefile include/IOs/Makefile docs/Makefile docs/UniSetDox.cfg docs/UniSetDoxDevel.cfg Utilities/Makefile Utilities/scripts/Makefile Utilities/Admin/Makefile Utilities/NullController/Makefile Utilities/SViewer-text/Makefile Utilities/SMonit/Makefile Utilities/InfoServer/Makefile Utilities/MBTester/Makefile Utilities/DBServer-MySQL/Makefile Utilities/codegen/Makefile Utilities/codegen/uniset-codegen Utilities/codegen/tests/Makefile extensions/Makefile extensions/libUniSetExtensions.pc extensions/lib/Makefile extensions/include/Makefile extensions/IOControl/Makefile extensions/IOControl/libUniSetIOControl.pc extensions/RTUExchange/Makefile extensions/RTUExchange/libUniSetRTU.pc extensions/UDPExchange/Makefile extensions/UDPExchange/libUniSetUDP.pc extensions/ModbusSlave/Makefile extensions/ModbusSlave/libUniSetMBSlave.pc extensions/MBTCPMaster/Makefile extensions/MBTCPMaster/libUniSetMBTCPMaster.pc extensions/LogicProcessor/Makefile extensions/LogicProcessor/libUniSetLogicProcessor.pc extensions/SMViewer/Makefile extensions/SharedMemory/Makefile extensions/SharedMemory/libUniSetSharedMemory.pc extensions/SharedMemoryPlus/Makefile"
ac_config_files
=
"
$ac_config_files
Makefile libUniSet.pc lib/Makefile IDL/Makefile IDL/UniSetTypes/Makefile IDL/Processes/Makefile IDL/Services/Makefile src/Communications/Makefile src/Communications/Modbus/Makefile src/IOs/Makefile src/Interfaces/Makefile src/ObjectRepository/Makefile src/Processes/Makefile src/Services/Makefile src/Threads/Makefile src/Timers/Makefile src/Various/Makefile src/Makefile include/Makefile include/modbus/Makefile include/IOs/Makefile docs/Makefile docs/UniSetDox.cfg docs/UniSetDoxDevel.cfg Utilities/Makefile Utilities/scripts/Makefile Utilities/Admin/Makefile Utilities/NullController/Makefile Utilities/SViewer-text/Makefile Utilities/SMonit/Makefile Utilities/InfoServer/Makefile Utilities/MBTester/Makefile Utilities/DBServer-MySQL/Makefile Utilities/
JrnTests/Makefile Utilities/
codegen/Makefile Utilities/codegen/uniset-codegen Utilities/codegen/tests/Makefile extensions/Makefile extensions/libUniSetExtensions.pc extensions/lib/Makefile extensions/include/Makefile extensions/IOControl/Makefile extensions/IOControl/libUniSetIOControl.pc extensions/RTUExchange/Makefile extensions/RTUExchange/libUniSetRTU.pc extensions/UDPExchange/Makefile extensions/UDPExchange/libUniSetUDP.pc extensions/ModbusSlave/Makefile extensions/ModbusSlave/libUniSetMBSlave.pc extensions/MBTCPMaster/Makefile extensions/MBTCPMaster/libUniSetMBTCPMaster.pc extensions/LogicProcessor/Makefile extensions/LogicProcessor/libUniSetLogicProcessor.pc extensions/SMViewer/Makefile extensions/SharedMemory/Makefile extensions/SharedMemory/libUniSetSharedMemory.pc extensions/SharedMemoryPlus/Makefile"
cat
>
confcache
<<
\
_ACEOF
...
...
@@ -19638,6 +19638,7 @@ do
"Utilities/InfoServer/Makefile") CONFIG_FILES="
$CONFIG_FILES
Utilities/InfoServer/Makefile" ;;
"Utilities/MBTester/Makefile") CONFIG_FILES="
$CONFIG_FILES
Utilities/MBTester/Makefile" ;;
"Utilities/DBServer-MySQL/Makefile") CONFIG_FILES="
$CONFIG_FILES
Utilities/DBServer-MySQL/Makefile" ;;
"Utilities/JrnTests/Makefile") CONFIG_FILES="
$CONFIG_FILES
Utilities/JrnTests/Makefile" ;;
"Utilities/codegen/Makefile") CONFIG_FILES="
$CONFIG_FILES
Utilities/codegen/Makefile" ;;
"Utilities/codegen/uniset-codegen") CONFIG_FILES="
$CONFIG_FILES
Utilities/codegen/uniset-codegen" ;;
"Utilities/codegen/tests/Makefile") CONFIG_FILES="
$CONFIG_FILES
Utilities/codegen/tests/Makefile" ;;
...
...
configure.ac
View file @
b72b5783
...
...
@@ -174,6 +174,7 @@ AC_CONFIG_FILES([Makefile
Utilities/InfoServer/Makefile
Utilities/MBTester/Makefile
Utilities/DBServer-MySQL/Makefile
Utilities/JrnTests/Makefile
Utilities/codegen/Makefile
Utilities/codegen/uniset-codegen
Utilities/codegen/tests/Makefile
...
...
include/
Jrn
.h
→
include/
Storages
.h
View file @
b72b5783
/* This file is part of the UniSet project
* Copyright (c) 200
2
Free Software Foundation, Inc.
* Copyright (c) 200
2
Ivan Donchevskiy
* Copyright (c) 200
9
Free Software Foundation, Inc.
* Copyright (c) 200
9
Ivan Donchevskiy
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
...
...
@@ -24,51 +24,56 @@
*/
// --------------------------------------------------------------------------
#include "stdio.h"
#include "string.h"
#ifndef Storages_H_
#define Storages_H_
#include <stdio.h>
#include <string.h>
#define str_size 80
#define key_size 20
#define val_size 40
struct
StorageTabl
eElem
struct
TableStorag
eElem
{
char
key
[
key_size
];
char
value
[
val_size
];
}
__attribute__
((
__packed__
));
struct
Cycle
Journal
Elem
struct
Cycle
Storage
Elem
{
char
str
[
str_size
];
int
status
;
}
__attribute__
((
__packed__
));
class
StorageTabl
e
class
TableStorag
e
{
FILE
*
file
;
int
seekpos
;
public
:
int
size
;
StorageTabl
e
();
StorageTabl
e
(
const
char
*
name
,
int
sz
,
int
seek
);
~
StorageTabl
e
();
TableStorag
e
();
TableStorag
e
(
const
char
*
name
,
int
sz
,
int
seek
);
~
TableStorag
e
();
int
AddRow
(
char
*
key
,
char
*
val
);
int
DelRow
(
char
*
key
);
char
*
FindKeyValue
(
char
*
key
,
char
*
val
);
};
class
Cycle
Journal
class
Cycle
Storage
{
FILE
*
file
;
int
seekpos
;
int
head
,
tail
;
public
:
int
size
,
iter
;
Cycle
Journal
();
Cycle
Journal
(
const
char
*
name
,
int
sz
,
int
seek
);
~
Cycle
Journal
();
Cycle
Storage
();
Cycle
Storage
(
const
char
*
name
,
int
sz
,
int
seek
);
~
Cycle
Storage
();
int
AddRow
(
char
*
str
);
int
DelRow
(
int
row
);
int
DelAllRows
(
void
);
int
ViewRows
(
int
beg
,
int
num
);
};
#endif
include/UniSetObject.h
View file @
b72b5783
...
...
@@ -76,7 +76,7 @@ class UniSetObject:
virtual
CORBA
::
Boolean
exist
();
virtual
char
*
getName
(){
return
(
char
*
)
myname
.
c_str
();}
virtual
UniSetTypes
::
ObjectId
getId
(){
return
myid
;
}
virtual
UniSetTypes
::
ObjectType
getType
()
{
return
"UniSetObject"
;
}
virtual
UniSetTypes
::
ObjectType
getType
()
{
static
UniSetTypes
::
ObjectType
ot
(
"UniSetObject"
);
return
ot
;
}
virtual
UniSetTypes
::
SimpleInfo
*
getInfo
();
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
UniSetObject
&
obj
);
...
...
src/Various/
Jrn
.cc
→
src/Various/
CycleStorage
.cc
View file @
b72b5783
...
...
@@ -24,126 +24,14 @@
*/
// --------------------------------------------------------------------------
#include "stdio.h"
#include "string.h"
#include "Jrn.h"
#include <stdio.h>
#include <string.h>
StorageTable
::
StorageTable
()
{
file
=
fopen
(
"tbl"
,
"r+"
);
if
(
file
==
NULL
)
{
file
=
fopen
(
"tbl"
,
"w"
);
StorageTableElem
*
t
=
new
StorageTableElem
();
for
(
int
i
=
0
;
i
<
100
;
i
++
)
fwrite
(
t
,
sizeof
(
*
t
),
1
,
file
);
fclose
(
file
);
file
=
fopen
(
"tbl"
,
"r+"
);
}
size
=
100
;
seekpos
=
0
;
}
StorageTable
::
StorageTable
(
const
char
*
name
,
int
sz
,
int
seek
)
{
file
=
fopen
(
name
,
"r+"
);
size
=
sz
/
sizeof
(
StorageTableElem
);
if
(
file
==
NULL
)
{
file
=
fopen
(
name
,
"w"
);
StorageTableElem
*
t
=
new
StorageTableElem
();
for
(
int
i
=
0
;
i
<
size
;
i
++
)
fwrite
(
t
,
sizeof
(
*
t
),
1
,
file
);
fclose
(
file
);
file
=
fopen
(
name
,
"r+"
);
seekpos
=
0
;
}
else
seekpos
=
seek
;
}
StorageTable
::~
StorageTable
()
{
fclose
(
file
);
}
int
StorageTable
::
AddRow
(
char
*
key
,
char
*
value
)
{
StorageTableElem
*
tbl
=
new
StorageTableElem
();
int
i
;
if
(
file
!=
NULL
)
{
fseek
(
file
,
seekpos
,
0
);
for
(
i
=
0
;
i
<
size
;
i
++
)
{
fread
(
tbl
,
sizeof
(
*
tbl
),
1
,
file
);
if
(
!
strcmp
(
tbl
->
key
,
key
))
{
strcpy
(
tbl
->
value
,
value
);
fseek
(
file
,
seekpos
+
i
*
sizeof
(
*
tbl
),
0
);
fwrite
(
tbl
,
sizeof
(
*
tbl
),
1
,
file
);
return
0
;
}
}
fseek
(
file
,
seekpos
,
0
);
for
(
i
=
0
;
i
<
size
;
i
++
)
{
fread
(
tbl
,
sizeof
(
*
tbl
),
1
,
file
);
if
(
*
(
tbl
->
key
)
==
0
)
{
strcpy
(
tbl
->
key
,
key
);
strcpy
(
tbl
->
value
,
value
);
fseek
(
file
,
seekpos
+
i
*
sizeof
(
*
tbl
),
0
);
fwrite
(
tbl
,
sizeof
(
*
tbl
),
1
,
file
);
return
0
;
}
}
}
return
1
;
}
int
StorageTable
::
DelRow
(
char
*
key
)
{
StorageTableElem
*
tbl
=
new
StorageTableElem
();
int
i
;
if
(
file
!=
NULL
)
{
fseek
(
file
,
seekpos
,
0
);
for
(
i
=
0
;
i
<
size
;
i
++
)
{
fread
(
tbl
,(
key_size
+
val_size
),
1
,
file
);
if
(
!
strcmp
(
tbl
->
key
,
key
))
{
tbl
->
key
[
0
]
=
0
;
fseek
(
file
,
seekpos
+
i
*
(
key_size
+
val_size
),
0
);
fwrite
(
tbl
,(
key_size
+
val_size
),
1
,
file
);
return
0
;
}
}
}
return
1
;
}
char
*
StorageTable
::
FindKeyValue
(
char
*
key
,
char
*
val
)
{
StorageTableElem
*
tbl
=
new
StorageTableElem
();
int
i
;
if
(
file
!=
NULL
)
{
fseek
(
file
,
seekpos
,
0
);
for
(
i
=
0
;
i
<
size
;
i
++
)
{
fread
(
tbl
,(
key_size
+
val_size
),
1
,
file
);
if
(
!
strcmp
(
tbl
->
key
,
key
))
{
strcpy
(
val
,
tbl
->
value
);
return
val
;
}
}
}
return
0
;
}
#include "Storages.h"
Cycle
Journal
::
CycleJournal
()
Cycle
Storage
::
CycleStorage
()
{
Cycle
JournalElem
*
jrn
=
new
CycleJournal
Elem
();
Cycle
StorageElem
*
jrn
=
new
CycleStorage
Elem
();
file
=
fopen
(
"jrn"
,
"r+"
);
size
=
100
;
seekpos
=
0
;
...
...
@@ -152,7 +40,7 @@ CycleJournal::CycleJournal()
if
(
file
==
NULL
)
{
file
=
fopen
(
"jrn"
,
"w"
);
Cycle
JournalElem
*
t
=
new
CycleJournal
Elem
();
Cycle
StorageElem
*
t
=
new
CycleStorage
Elem
();
for
(
int
i
=
0
;
i
<
100
;
i
++
)
fwrite
(
t
,
sizeof
(
*
t
),
1
,
file
);
fclose
(
file
);
file
=
fopen
(
"jrn"
,
"r+"
);
...
...
@@ -240,17 +128,17 @@ CycleJournal::CycleJournal()
}
}
Cycle
Journal
::
CycleJournal
(
const
char
*
name
,
int
sz
,
int
seek
)
Cycle
Storage
::
CycleStorage
(
const
char
*
name
,
int
sz
,
int
seek
)
{
Cycle
JournalElem
*
jrn
=
new
CycleJournal
Elem
();
Cycle
StorageElem
*
jrn
=
new
CycleStorage
Elem
();
file
=
fopen
(
name
,
"r+"
);
size
=
sz
/
sizeof
(
Cycle
Journal
Elem
);
size
=
sz
/
sizeof
(
Cycle
Storage
Elem
);
int
l
=-
1
,
r
=
size
,
mid
;
iter
=
0
;
if
(
file
==
NULL
)
{
file
=
fopen
(
name
,
"w"
);
Cycle
JournalElem
*
t
=
new
CycleJournal
Elem
();
Cycle
StorageElem
*
t
=
new
CycleStorage
Elem
();
for
(
int
i
=
0
;
i
<
size
;
i
++
)
fwrite
(
t
,
sizeof
(
*
t
),
1
,
file
);
fclose
(
file
);
file
=
fopen
(
name
,
"r+"
);
...
...
@@ -340,14 +228,14 @@ CycleJournal::CycleJournal(const char* name, int sz, int seek)
}
}
Cycle
Journal
::~
CycleJournal
()
Cycle
Storage
::~
CycleStorage
()
{
fclose
(
file
);
}
int
Cycle
Journal
::
AddRow
(
char
*
str
)
int
Cycle
Storage
::
AddRow
(
char
*
str
)
{
Cycle
JournalElem
*
jrn
=
new
CycleJournal
Elem
();
Cycle
StorageElem
*
jrn
=
new
CycleStorage
Elem
();
int
i
;
if
(
file
!=
NULL
)
{
...
...
@@ -413,9 +301,9 @@ int CycleJournal::AddRow(char* str)
return
1
;
}
int
Cycle
Journal
::
DelRow
(
int
row
)
int
Cycle
Storage
::
DelRow
(
int
row
)
{
Cycle
JournalElem
*
jrn
=
new
CycleJournal
Elem
();
Cycle
StorageElem
*
jrn
=
new
CycleStorage
Elem
();
int
i
=
(
head
+
row
)
%
size
,
j
;
if
(
row
>=
size
)
return
1
;
if
(
file
!=
NULL
)
...
...
@@ -439,9 +327,9 @@ int CycleJournal::DelRow(int row)
return
1
;
}
int
Cycle
Journal
::
DelAllRows
()
int
Cycle
Storage
::
DelAllRows
()
{
Cycle
JournalElem
*
jrn
=
new
CycleJournal
Elem
();
Cycle
StorageElem
*
jrn
=
new
CycleStorage
Elem
();
int
i
;
if
(
file
!=
NULL
)
{
...
...
@@ -472,9 +360,9 @@ int CycleJournal::DelAllRows()
return
1
;
}
int
Cycle
Journal
::
ViewRows
(
int
beg
,
int
num
)
int
Cycle
Storage
::
ViewRows
(
int
beg
,
int
num
)
{
Cycle
JournalElem
*
jrn
=
new
CycleJournal
Elem
();
Cycle
StorageElem
*
jrn
=
new
CycleStorage
Elem
();
int
i
,
j
=
(
head
+
beg
)
%
size
,
n
=
num
;
if
(
num
==
0
)
n
=
size
;
if
(
num
>
size
)
n
=
size
;
...
...
src/Various/Makefile.am
View file @
b72b5783
...
...
@@ -10,7 +10,8 @@ libVarious_la_SOURCES = DebugStream.cc Debug.cc UniXML.cc MessageType.cc Config
NCRestorer.cc NCRestorer_XML.cc
\
ISRestorer.cc ISRestorer_XML.cc
\
RunLock.cc Mutex.cc SViewer.cc SMonitor.cc LT_Object.cc
\
MessageInterface_XML.cc MessageInterface_idXML.cc WDTInterface.cc
MessageInterface_XML.cc MessageInterface_idXML.cc WDTInterface.cc
\
CycleStorage.cc TableStorage.cc
include
$(top_builddir)/conf/setting.mk
...
...
src/Various/Makefile.in
View file @
b72b5783
...
...
@@ -65,7 +65,8 @@ am_libVarious_la_OBJECTS = libVarious_la-DebugStream.lo \
libVarious_la-SMonitor.lo libVarious_la-LT_Object.lo
\
libVarious_la-MessageInterface_XML.lo
\
libVarious_la-MessageInterface_idXML.lo
\
libVarious_la-WDTInterface.lo
libVarious_la-WDTInterface.lo libVarious_la-CycleStorage.lo
\
libVarious_la-TableStorage.lo
libVarious_la_OBJECTS
=
$(am_libVarious_la_OBJECTS)
DEFAULT_INCLUDES
=
-I
.@am__isrc@
-I
$(top_builddir)
depcomp
=
$(SHELL)
$(top_srcdir)
/depcomp
...
...
@@ -224,7 +225,8 @@ libVarious_la_SOURCES = DebugStream.cc Debug.cc UniXML.cc MessageType.cc Configu
NCRestorer.cc NCRestorer_XML.cc
\
ISRestorer.cc ISRestorer_XML.cc
\
RunLock.cc Mutex.cc SViewer.cc SMonitor.cc LT_Object.cc
\
MessageInterface_XML.cc MessageInterface_idXML.cc WDTInterface.cc
MessageInterface_XML.cc MessageInterface_idXML.cc WDTInterface.cc
\
CycleStorage.cc TableStorage.cc
all
:
all-am
...
...
@@ -279,6 +281,7 @@ distclean-compile:
-
rm
-f
*
.tab.c
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/libVarious_la-Configuration.Plo@am__quote@
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/libVarious_la-CycleStorage.Plo@am__quote@
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/libVarious_la-Debug.Plo@am__quote@
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/libVarious_la-DebugStream.Plo@am__quote@
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/libVarious_la-ISRestorer.Plo@am__quote@
...
...
@@ -295,6 +298,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/libVarious_la-SMonitor.Plo@am__quote@
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/libVarious_la-SViewer.Plo@am__quote@
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/libVarious_la-SystemGuard.Plo@am__quote@
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/libVarious_la-TableStorage.Plo@am__quote@
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/libVarious_la-TextIndex.Plo@am__quote@
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/libVarious_la-UniXML.Plo@am__quote@
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/libVarious_la-WDTInterface.Plo@am__quote@
...
...
@@ -460,6 +464,20 @@ libVarious_la-WDTInterface.lo: WDTInterface.cc
@AMDEP_TRUE@@am__fastdepCXX_FALSE@
DEPDIR
=
$(DEPDIR)
$(CXXDEPMODE)
$(depcomp)
@AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@
$(LIBTOOL)
--tag
=
CXX
$(AM_LIBTOOLFLAGS)
$(LIBTOOLFLAGS)
--mode
=
compile
$(CXX)
$(DEFS)
$(DEFAULT_INCLUDES)
$(INCLUDES)
$(libVarious_la_CPPFLAGS)
$(CPPFLAGS)
$(AM_CXXFLAGS)
$(CXXFLAGS)
-c
-o
libVarious_la-WDTInterface.lo
`
test
-f
'WDTInterface.cc'
||
echo
'
$(srcdir)
/'
`
WDTInterface.cc
libVarious_la-CycleStorage.lo
:
CycleStorage.cc
@am__fastdepCXX_TRUE@
$(LIBTOOL)
--tag
=
CXX
$(AM_LIBTOOLFLAGS)
$(LIBTOOLFLAGS)
--mode
=
compile
$(CXX)
$(DEFS)
$(DEFAULT_INCLUDES)
$(INCLUDES)
$(libVarious_la_CPPFLAGS)
$(CPPFLAGS)
$(AM_CXXFLAGS)
$(CXXFLAGS)
-MT
libVarious_la-CycleStorage.lo
-MD
-MP
-MF
$(DEPDIR)
/libVarious_la-CycleStorage.Tpo
-c
-o
libVarious_la-CycleStorage.lo
`
test
-f
'CycleStorage.cc'
||
echo
'
$(srcdir)
/'
`
CycleStorage.cc
@am__fastdepCXX_TRUE@
$(am__mv)
$(DEPDIR)/libVarious_la-CycleStorage.Tpo
$(DEPDIR)/libVarious_la-CycleStorage.Plo
@AMDEP_TRUE@@am__fastdepCXX_FALSE@
source
=
'CycleStorage.cc'
object
=
'libVarious_la-CycleStorage.lo'
libtool
=
yes
@AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@
DEPDIR
=
$(DEPDIR)
$(CXXDEPMODE)
$(depcomp)
@AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@
$(LIBTOOL)
--tag
=
CXX
$(AM_LIBTOOLFLAGS)
$(LIBTOOLFLAGS)
--mode
=
compile
$(CXX)
$(DEFS)
$(DEFAULT_INCLUDES)
$(INCLUDES)
$(libVarious_la_CPPFLAGS)
$(CPPFLAGS)
$(AM_CXXFLAGS)
$(CXXFLAGS)
-c
-o
libVarious_la-CycleStorage.lo
`
test
-f
'CycleStorage.cc'
||
echo
'
$(srcdir)
/'
`
CycleStorage.cc
libVarious_la-TableStorage.lo
:
TableStorage.cc
@am__fastdepCXX_TRUE@
$(LIBTOOL)
--tag
=
CXX
$(AM_LIBTOOLFLAGS)
$(LIBTOOLFLAGS)
--mode
=
compile
$(CXX)
$(DEFS)
$(DEFAULT_INCLUDES)
$(INCLUDES)
$(libVarious_la_CPPFLAGS)
$(CPPFLAGS)
$(AM_CXXFLAGS)
$(CXXFLAGS)
-MT
libVarious_la-TableStorage.lo
-MD
-MP
-MF
$(DEPDIR)
/libVarious_la-TableStorage.Tpo
-c
-o
libVarious_la-TableStorage.lo
`
test
-f
'TableStorage.cc'
||
echo
'
$(srcdir)
/'
`
TableStorage.cc
@am__fastdepCXX_TRUE@
$(am__mv)
$(DEPDIR)/libVarious_la-TableStorage.Tpo
$(DEPDIR)/libVarious_la-TableStorage.Plo
@AMDEP_TRUE@@am__fastdepCXX_FALSE@
source
=
'TableStorage.cc'
object
=
'libVarious_la-TableStorage.lo'
libtool
=
yes
@AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@
DEPDIR
=
$(DEPDIR)
$(CXXDEPMODE)
$(depcomp)
@AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@
$(LIBTOOL)
--tag
=
CXX
$(AM_LIBTOOLFLAGS)
$(LIBTOOLFLAGS)
--mode
=
compile
$(CXX)
$(DEFS)
$(DEFAULT_INCLUDES)
$(INCLUDES)
$(libVarious_la_CPPFLAGS)
$(CPPFLAGS)
$(AM_CXXFLAGS)
$(CXXFLAGS)
-c
-o
libVarious_la-TableStorage.lo
`
test
-f
'TableStorage.cc'
||
echo
'
$(srcdir)
/'
`
TableStorage.cc
mostlyclean-libtool
:
-
rm
-f
*
.lo
...
...
src/Various/TableStorage.cc
0 → 100644
View file @
b72b5783
/* This file is part of the UniSet project
* Copyright (c) 2009 Free Software Foundation, Inc.
* Copyright (c) 2009 Ivan Donchevskiy
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// --------------------------------------------------------------------------
/*! \file
* \author Ivan Donchevskiy
* \date $Date: 2009/07/14 16:59:00 $
* \version $Id: Jrn.h,v 1.0 2009/07/14 16:59:00 vpashka Exp $
*/
// --------------------------------------------------------------------------
#include <stdio.h>
#include <string.h>
#include "Storages.h"
TableStorage
::
TableStorage
()
{
file
=
fopen
(
"tbl"
,
"r+"
);
if
(
file
==
NULL
)
{
file
=
fopen
(
"tbl"
,
"w"
);
TableStorageElem
*
t
=
new
TableStorageElem
();
for
(
int
i
=
0
;
i
<
100
;
i
++
)
fwrite
(
t
,
sizeof
(
*
t
),
1
,
file
);
fclose
(
file
);
file
=
fopen
(
"tbl"
,
"r+"
);
}
size
=
100
;
seekpos
=
0
;
}
TableStorage
::
TableStorage
(
const
char
*
name
,
int
sz
,
int
seek
)
{
file
=
fopen
(
name
,
"r+"
);
size
=
sz
/
sizeof
(
TableStorageElem
);
if
(
file
==
NULL
)
{
file
=
fopen
(
name
,
"w"
);
TableStorageElem
*
t
=
new
TableStorageElem
();
for
(
int
i
=
0
;
i
<
size
;
i
++
)
fwrite
(
t
,
sizeof
(
*
t
),
1
,
file
);
fclose
(
file
);
file
=
fopen
(
name
,
"r+"
);
seekpos
=
0
;
}
else
seekpos
=
seek
;
}
TableStorage
::~
TableStorage
()
{
fclose
(
file
);
}
int
TableStorage
::
AddRow
(
char
*
key
,
char
*
value
)
{
TableStorageElem
*
tbl
=
new
TableStorageElem
();
int
i
;
if
(
file
!=
NULL
)
{
fseek
(
file
,
seekpos
,
0
);
for
(
i
=
0
;
i
<
size
;
i
++
)
{
fread
(
tbl
,
sizeof
(
*
tbl
),
1
,
file
);
if
(
!
strcmp
(
tbl
->
key
,
key
))
{
strcpy
(
tbl
->
value
,
value
);
fseek
(
file
,
seekpos
+
i
*
sizeof
(
*
tbl
),
0
);
fwrite
(
tbl
,
sizeof
(
*
tbl
),
1
,
file
);
return
0
;
}
}
fseek
(
file
,
seekpos
,
0
);
for
(
i
=
0
;
i
<
size
;
i
++
)
{
fread
(
tbl
,
sizeof
(
*
tbl
),
1
,
file
);
if
(
*
(
tbl
->
key
)
==
0
)
{
strcpy
(
tbl
->
key
,
key
);
strcpy
(
tbl
->
value
,
value
);
fseek
(
file
,
seekpos
+
i
*
sizeof
(
*
tbl
),
0
);
fwrite
(
tbl
,
sizeof
(
*
tbl
),
1
,
file
);
return
0
;
}
}
}
return
1
;
}
int
TableStorage
::
DelRow
(
char
*
key
)
{
TableStorageElem
*
tbl
=
new
TableStorageElem
();
int
i
;
if
(
file
!=
NULL
)
{
fseek
(
file
,
seekpos
,
0
);
for
(
i
=
0
;
i
<
size
;
i
++
)
{
fread
(
tbl
,(
key_size
+
val_size
),
1
,
file
);
if
(
!
strcmp
(
tbl
->
key
,
key
))
{
tbl
->
key
[
0
]
=
0
;
fseek
(
file
,
seekpos
+
i
*
(
key_size
+
val_size
),
0
);
fwrite
(
tbl
,(
key_size
+
val_size
),
1
,
file
);
return
0
;
}
}
}
return
1
;
}
char
*
TableStorage
::
FindKeyValue
(
char
*
key
,
char
*
val
)
{
TableStorageElem
*
tbl
=
new
TableStorageElem
();
int
i
;
if
(
file
!=
NULL
)
{
fseek
(
file
,
seekpos
,
0
);
for
(
i
=
0
;
i
<
size
;
i
++
)
{
fread
(
tbl
,(
key_size
+
val_size
),
1
,
file
);
if
(
!
strcmp
(
tbl
->
key
,
key
))
{
strcpy
(
val
,
tbl
->
value
);
return
val
;
}
}
}
return
0
;
}
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