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
6dfe533b
Commit
6dfe533b
authored
Jul 17, 2009
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of git.eter:/people/yv/packages/uniset
parents
028d4e56
72839840
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
273 additions
and
93 deletions
+273
-93
JrnTest.cc
Utilities/JrnTests/JrnTest.cc
+104
-31
Storages.h
include/Storages.h
+11
-13
UniXML.h
include/UniXML.h
+2
-1
CycleStorage.cc
src/Various/CycleStorage.cc
+0
-0
TableStorage.cc
src/Various/TableStorage.cc
+156
-48
No files found.
Utilities/JrnTests/JrnTest.cc
View file @
6dfe533b
/* 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
...
...
@@ -19,14 +19,17 @@
// --------------------------------------------------------------------------
/*! \file
* \author Ivan Donchevskiy
* \date $Date: 2009/07/1
4 16:59
:00 $
* \version $Id: Jrn.h,v 1.0 2009/07/1
4 16:59
:00 vpashka Exp $
* \date $Date: 2009/07/1
5 15:55
:00 $
* \version $Id: Jrn.h,v 1.0 2009/07/1
5 15:55
:00 vpashka Exp $
*/
// --------------------------------------------------------------------------
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include "Storages.h"
#include "UniXML.h"
char
*
itoa
(
int
val
,
int
base
)
{
...
...
@@ -46,35 +49,45 @@ char* itoa(int val, int base)
void
testTable
(
void
)
{
char
*
chr
=
new
char
[
2
]
;
char
*
val
=
new
char
[
2
]
;
char
*
chr
=
(
char
*
)
malloc
(
20
)
;
char
*
val
=
(
char
*
)
malloc
(
40
)
;
TableStorage
*
t
;
t
=
new
TableStorage
(
"table.test"
,
600
0
,
0
);
t
=
new
TableStorage
(
"table.test"
,
40
,
122
0
,
0
);
int
i
;
printf
(
"testTable
\n
size = %d
\n
"
,
t
->
size
);
for
(
i
=
0
;
i
<
t
->
size
+
5
;
i
++
)
for
(
i
=
0
;
i
<
t
->
size
;
i
++
)
{
chr
[
0
]
=
i
;
val
=
itoa
(
i
,
10
);
t
->
AddRow
(
chr
,
val
);
}
//printf("elements with values=keys added\nvalues from keys 25-59\n");
printf
(
"elements with values=keys added:
\n
"
);
for
(
i
=
0
;
i
<
40
;
i
++
)
{
chr
[
0
]
=
i
%
256
;
if
(
t
->
AddRow
(
chr
,
chr
)
==
1
)
printf
(
"elem number %d - no space in TableStorage
\n
"
,
i
);
chr
[
0
]
=
i
;
if
(
t
->
FindKeyValue
(
chr
,
val
)
!=
0
)
printf
(
"%s, "
,
val
);
}
printf
(
"
elements with values=keys added
\n
"
);
for
(
i
=
40
;
i
<
60
;
i
++
)
printf
(
"
\n
"
);
for
(
i
=
9
;
i
<
15
;
i
++
)
{
chr
[
0
]
=
i
%
256
;
chr
[
0
]
=
i
;
t
->
DelRow
(
chr
);
}
printf
(
"elements with keys from 40 to 60 deleted
\n
"
);
for
(
i
=
30
;
i
<
50
;
i
++
)
//printf("elements with keys from 40 to 60 deleted\n");
printf
(
"elements with keys from 9 to 14 deleted
\n
"
);
for
(
i
=
9
;
i
<
15
;
i
++
)
{
chr
[
0
]
=
i
;
val
[
0
]
=
i
+
40
;
val
=
itoa
(
i
+
40
,
10
)
;
t
->
AddRow
(
chr
,
val
);
}
printf
(
"elements with keys from 30 to 50 with values=key+40 added
\n
values from keys 25-59
\n
"
);
for
(
i
=
25
;
i
<
60
;
i
++
)
//printf("elements with keys from 30 to 50 with values=key+40 added\nvalues from keys 25-59\n");
printf
(
"elements with keys from 9 to 14 with values=key+40 added, all elements:
\n
"
);
for
(
i
=
0
;
i
<
40
;
i
++
)
{
chr
[
0
]
=
i
;
if
(
t
->
FindKeyValue
(
chr
,
val
)
!=
0
)
printf
(
"%
d, "
,
val
[
0
]
);
if
(
t
->
FindKeyValue
(
chr
,
val
)
!=
0
)
printf
(
"%
s, "
,
val
);
}
printf
(
"
\n
"
);
}
...
...
@@ -83,11 +96,11 @@ void testJournal1(void)
{
CycleStorage
*
j
;
int
i
;
char
*
str
=
new
char
[
6
]
;
char
*
str
=
(
char
*
)
malloc
(
30
)
;
printf
(
"journal test 1
\n
"
);
j
=
new
CycleStorage
(
"journal.test"
,
2
000000
,
0
);
j
=
new
CycleStorage
(
"journal.test"
,
30
,
1
000000
,
0
);
printf
(
"size = %d
\n
"
,
j
->
size
);
for
(
i
=
1
;
i
<
3
0000
;
i
++
)
for
(
i
=
1
;
i
<
4
0000
;
i
++
)
{
str
=
itoa
(
i
,
10
);
j
->
AddRow
(
str
);
...
...
@@ -108,42 +121,102 @@ void testJournal1(void)
}
j
->
ViewRows
(
0
,
20
);
printf
(
"
\n
the same after reopen:
\n
"
);
delete
j
;
j
=
new
CycleStorage
(
"journal.test"
,
2000000
,
0
);
j
=
new
CycleStorage
(
"journal.test"
,
30
,
2000000
,
0
);
j
->
ViewRows
(
0
,
20
);
printf
(
"
\n
"
);
j
->
ExportToXML
(
"Xml.xml"
);
}
void
testJournal2
(
void
)
{
CycleStorage
*
j
;
int
i
,
k
;
char
*
str
=
new
char
[
4
]
;
j
=
new
CycleStorage
(
"journal.test"
,
2
000000
,
0
);
char
*
str
=
(
char
*
)
malloc
(
30
)
;
j
=
new
CycleStorage
(
"journal.test"
,
30
,
1
000000
,
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
);
for
(
i
=
0
;
i
<
20
;
i
++
)
{
for
(
k
=
0
;
k
<
1
000
;
k
++
)
for
(
k
=
1000
;
k
<
3
000
;
k
++
)
{
str
=
itoa
(
k
,
10
);
j
->
AddRow
(
str
);
}
delete
j
;
j
=
new
CycleStorage
(
"journal.test"
,
2000000
,
0
);
j
=
new
CycleStorage
(
"journal.test"
,
30
,
2000000
,
0
);
printf
(
"iterations = %d
\n
"
,
j
->
iter
);
}
printf
(
"
\n
"
);
}
int
main
(
void
)
int
main
(
int
args
,
char
**
argv
)
{
/*if(args<2)
{
printf("Correct usage: jrntest File_name\n");
return 0;
}
CycleStorage *j = new CycleStorage(argv[1],99,1000,0);
printf("commands:\nadd\ndelete\nview\ntoxml\ndel_all\nenter q or quit to exit\n\n");
char* com=new char[8];
char* str=new char[99];
int num,count;
strcpy(com,"qwerty");
while(strcmp(com,"q")&&strcmp(com,"quit"))
{
scanf("%s",com);
if(!strcmp(com,"add"))
{
printf("string to add: ");
if(scanf("%99s",str)>0)
{
j->AddRow(str);
printf("\n");
}
}
else if(!strcmp(com,"delete"))
{
printf("number of string to delete: ");
if(scanf("%d",&num)>0)
{
j->DelRow(num);
printf("\n");
}
}
else if(!strcmp(com,"view"))
{
printf("start number and count (0 0 for all): ");
if(scanf("%d%d",&num,&count)>1)
{
j->ViewRows(num,count);
printf("\n");
}
}
else if(!strcmp(com,"del_all"))
{
printf("are you sure? (y/n) ");
if(scanf("%s",str)>0)
if(!strcmp(str,"y"))
{
j->DelAllRows();
printf("\n");
}
}
else if(!strcmp(com,"toxml"))
{
printf("enter file name: ");
if(scanf("%25s",str)>0)
{
j->ExportToXML(str);
printf("\n");
}
}
else printf("commands:\nadd\ndelete\nview\ntoxml\ndel_all\nenter q or quit to exit\n\n");
}*/
testTable
();
testJournal1
();
testJournal2
();
return
0
;
...
...
include/Storages.h
View file @
6dfe533b
...
...
@@ -19,8 +19,8 @@
// --------------------------------------------------------------------------
/*! \file
* \author Ivan Donchevskiy
* \date $Date: 2009/07/1
4 16:59
:00 $
* \version $Id: Jrn.h,v 1.0 2009/07/1
4 16:59
:00 vpashka Exp $
* \date $Date: 2009/07/1
5 15:55
:00 $
* \version $Id: Jrn.h,v 1.0 2009/07/1
5 15:55
:00 vpashka Exp $
*/
// --------------------------------------------------------------------------
...
...
@@ -29,31 +29,29 @@
#include <stdio.h>
#include <string.h>
#include <UniXML.h>
#define str_size 80
#define key_size 20
#define val_size 40
struct
TableStorageElem
{
char
status
;
char
key
[
key_size
];
char
value
[
val_size
];
}
__attribute__
((
__packed__
));
struct
CycleStorageElem
{
char
str
[
str_size
];
int
status
;
char
status
;
}
__attribute__
((
__packed__
));
class
TableStorage
{
FILE
*
file
;
int
seekpos
;
int
seekpos
,
inf_size
;
int
head
;
public
:
int
size
;
TableStorage
();
TableStorage
(
const
char
*
name
,
int
sz
,
int
seek
);
TableStorage
(
const
char
*
name
,
int
inf_sz
,
int
sz
,
int
seek
);
~
TableStorage
();
int
AddRow
(
char
*
key
,
char
*
val
);
int
DelRow
(
char
*
key
);
...
...
@@ -63,17 +61,17 @@ class TableStorage
class
CycleStorage
{
FILE
*
file
;
int
seekpos
;
int
seekpos
,
inf_size
;
int
head
,
tail
;
public
:
int
size
,
iter
;
CycleStorage
();
CycleStorage
(
const
char
*
name
,
int
sz
,
int
seek
);
CycleStorage
(
const
char
*
name
,
int
inf_sz
,
int
sz
,
int
seek
);
~
CycleStorage
();
int
AddRow
(
char
*
str
);
int
DelRow
(
int
row
);
int
DelAllRows
(
void
);
int
ViewRows
(
int
beg
,
int
num
);
int
ExportToXML
(
const
char
*
name
);
};
#endif
include/UniXML.h
View file @
6dfe533b
...
...
@@ -75,9 +75,10 @@ public:
// , .
static
const
xmlChar
*
local2xml
(
std
::
string
text
);
//
name node
//
XML-
void
newDoc
(
const
std
::
string
&
root_node
,
std
::
string
xml_ver
=
"1.0"
);
// name node
static
std
::
string
getProp
(
xmlNode
*
node
,
const
std
::
string
name
);
// name node
...
...
src/Various/CycleStorage.cc
View file @
6dfe533b
This diff is collapsed.
Click to expand it.
src/Various/TableStorage.cc
View file @
6dfe533b
...
...
@@ -19,45 +19,90 @@
// --------------------------------------------------------------------------
/*! \file
* \author Ivan Donchevskiy
* \date $Date: 2009/07/1
4 16:59
:00 $
* \version $Id: Jrn.h,v 1.0 2009/07/1
4 16:59:00
vpashka Exp $
* \date $Date: 2009/07/1
5 15:55
:00 $
* \version $Id: Jrn.h,v 1.0 2009/07/1
5 15:55:00
vpashka Exp $
*/
// --------------------------------------------------------------------------
#include <stdio.h>
#include <stdlib.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
)
TableStorage
::
TableStorage
(
const
char
*
name
,
int
inf_sz
,
int
sz
,
int
seek
)
{
file
=
fopen
(
name
,
"r+"
);
size
=
sz
/
sizeof
(
TableStorageElem
);
inf_size
=
inf_sz
;
int
l
=-
1
,
r
=
size
,
mid
;
size
=
sz
/
(
sizeof
(
TableStorageElem
)
+
inf_size
);
TableStorageElem
*
t
=
(
TableStorageElem
*
)
malloc
(
sizeof
(
TableStorageElem
)
+
inf_size
);
if
(
file
==
NULL
)
{
file
=
fopen
(
name
,
"w"
);
TableStorageElem
*
t
=
new
TableStorageElem
();
for
(
int
i
=
0
;
i
<
size
;
i
++
)
fwrite
(
t
,
sizeof
(
*
t
),
1
,
file
);
for
(
int
i
=
0
;
i
<
size
;
i
++
)
fwrite
(
t
,(
sizeof
(
TableStorageElem
)
+
inf_size
),
1
,
file
);
fclose
(
file
);
file
=
fopen
(
name
,
"r+"
);
seekpos
=
0
;
head
=-
1
;
}
else
{
seekpos
=
seek
;
fseek
(
file
,
seekpos
,
0
);
fread
(
t
,(
sizeof
(
TableStorageElem
)
+
inf_size
),
1
,
file
);
if
(
t
->
status
==
0
)
{
head
=-
1
;
}
else
if
((
t
->
status
==
1
)
||
(
t
->
status
==
6
))
{
head
=
0
;
}
else
if
((
t
->
status
==
2
)
||
(
t
->
status
==
3
))
{
while
((
t
->
status
!=
1
)
&&
(
t
->
status
!=
6
)
&&
(
r
-
l
>
1
))
{
mid
=
(
l
+
r
)
/
2
;
fseek
(
file
,
seekpos
+
mid
*
(
sizeof
(
TableStorageElem
)
+
inf_size
),
0
);
fread
(
t
,(
sizeof
(
TableStorageElem
)
+
inf_size
),
1
,
file
);
if
((
t
->
status
==
2
)
||
(
t
->
status
==
3
))
l
=
mid
;
else
if
((
t
->
status
==
4
)
||
(
t
->
status
==
5
))
r
=
mid
;
else
{
r
=
mid
;
break
;
}
}
if
(
r
<
size
)
head
=
r
;
else
head
=
size
-
1
;
}
else
{
while
((
t
->
status
!=
1
)
&&
(
t
->
status
!=
6
)
&&
(
r
-
l
>
1
))
{
mid
=
(
l
+
r
)
/
2
;
fseek
(
file
,
seekpos
+
mid
*
(
sizeof
(
TableStorageElem
)
+
inf_size
),
0
);
fread
(
t
,(
sizeof
(
TableStorageElem
)
+
inf_size
),
1
,
file
);
if
((
t
->
status
==
2
)
||
(
t
->
status
==
3
))
r
=
mid
;
else
if
((
t
->
status
==
4
)
||
(
t
->
status
==
5
))
l
=
mid
;
else
{
r
=
mid
;
break
;
}
}
if
(
r
<
size
)
head
=
r
;
else
head
=
size
-
1
;
}
}
else
seekpos
=
seek
;
}
TableStorage
::~
TableStorage
()
...
...
@@ -67,56 +112,118 @@ TableStorage::~TableStorage()
int
TableStorage
::
AddRow
(
char
*
key
,
char
*
value
)
{
TableStorageElem
*
tbl
=
new
TableStorageElem
(
);
int
i
;
TableStorageElem
*
tbl
=
(
TableStorageElem
*
)
malloc
(
sizeof
(
TableStorageElem
)
+
inf_size
);
int
i
,
k
,
j
,
st
;
if
(
file
!=
NULL
)
{
if
(
head
==-
1
)
{
fseek
(
file
,
seekpos
,
0
);
tbl
->
status
=
1
;
strcpy
(
tbl
->
key
,
key
);
for
(
k
=
0
;
k
<
inf_size
;
k
++
)
*
((
char
*
)(
tbl
)
+
sizeof
(
TableStorageElem
)
+
k
)
=*
(
value
+
k
);
fwrite
(
tbl
,(
sizeof
(
TableStorageElem
)
+
inf_size
),
1
,
file
);
head
=
0
;
return
0
;
}
fseek
(
file
,
seekpos
+
head
*
(
sizeof
(
TableStorageElem
)
+
inf_size
),
0
);
j
=
head
;
for
(
i
=
0
;
i
<
size
;
i
++
)
{
fread
(
tbl
,
sizeof
(
*
tbl
),
1
,
file
);
if
(
!
strcmp
(
tbl
->
key
,
key
))
fread
(
tbl
,(
sizeof
(
TableStorageElem
)
+
inf_size
),
1
,
file
);
if
(
tbl
->
status
==
0
)
break
;
if
(
!
strcmp
(
tbl
->
key
,
key
)
&&
((
tbl
->
status
==
2
)
||
(
tbl
->
status
==
4
)
||
(
tbl
->
status
==
1
)))
{
strcpy
(
tbl
->
value
,
value
);
fseek
(
file
,
seekpos
+
i
*
sizeof
(
*
tbl
),
0
);
fwrite
(
tbl
,
sizeof
(
*
tbl
),
1
,
file
);
for
(
k
=
0
;
k
<
inf_size
;
k
++
)
*
((
char
*
)(
tbl
)
+
sizeof
(
TableStorageElem
)
+
k
)
=*
(
value
+
k
);
fseek
(
file
,
seekpos
+
i
*
(
sizeof
(
TableStorageElem
)
+
inf_size
),
0
);
fwrite
(
tbl
,(
sizeof
(
TableStorageElem
)
+
inf_size
),
1
,
file
);
return
0
;
}
j
++
;
if
(
j
>=
size
)
{
j
=
0
;
fseek
(
file
,
seekpos
,
0
);
}
}
fseek
(
file
,
seekpos
+
j
*
(
sizeof
(
TableStorageElem
)
+
inf_size
),
0
);
if
(
j
==
head
)
{
if
((
tbl
->
status
==
2
)
||
(
tbl
->
status
==
3
))
st
=
2
;
else
st
=
4
;
if
(
j
==
0
)
if
(
st
==
2
)
st
=
4
;
else
st
=
2
;
tbl
->
status
=
st
;
strcpy
(
tbl
->
key
,
key
);
for
(
k
=
0
;
k
<
inf_size
;
k
++
)
*
((
char
*
)(
tbl
)
+
sizeof
(
TableStorageElem
)
+
k
)
=*
(
value
+
k
);
fwrite
(
tbl
,(
sizeof
(
TableStorageElem
)
+
inf_size
),
1
,
file
);
j
++
;
if
(
j
>=
size
)
{
j
=
0
;
fseek
(
file
,
seekpos
,
0
);
for
(
i
=
0
;
i
<
size
;
i
++
)
}
fread
(
tbl
,(
sizeof
(
TableStorageElem
)
+
inf_size
),
1
,
file
);
if
((
tbl
->
status
==
3
)
||
(
tbl
->
status
==
5
))
tbl
->
status
=
6
;
else
tbl
->
status
=
1
;
fseek
(
file
,
seekpos
+
j
*
(
sizeof
(
TableStorageElem
)
+
inf_size
),
0
);
fwrite
(
tbl
,(
sizeof
(
TableStorageElem
)
+
inf_size
),
1
,
file
);
head
++
;
if
(
head
>=
size
)
head
=
0
;
return
0
;
}
/*for(i=0;i<size;i++)
{
fread
(
tbl
,
sizeof
(
*
tbl
),
1
,
file
);
if
(
*
(
tbl
->
key
)
==
0
)
fread(tbl,
(sizeof(TableStorageElem)+inf_size
),1,file);
if(
tbl->key[0]
==0)
{
strcpy(tbl->key,key);
strcpy
(
tbl
->
value
,
value
);
fseek
(
file
,
seekpos
+
i
*
sizeof
(
*
tbl
),
0
);
fwrite
(
tbl
,
sizeof
(
*
tbl
),
1
,
file
);
for(k=0;k<inf_size;k++)
*((char*)(tbl)+sizeof(TableStorageElem)+k)=*(value+k);
fseek(file,seekpos+i*(sizeof(TableStorageElem)+inf_size),0);
fwrite(tbl,(sizeof(TableStorageElem)+inf_size),1,file);
return 0;
}
}
}
*/
}
return
1
;
}
int
TableStorage
::
DelRow
(
char
*
key
)
{
TableStorageElem
*
tbl
=
new
TableStorageElem
(
);
int
i
;
TableStorageElem
*
tbl
=
(
TableStorageElem
*
)
malloc
(
sizeof
(
TableStorageElem
)
+
inf_size
);
int
i
,
j
;
if
(
file
!=
NULL
)
{
fseek
(
file
,
seekpos
,
0
);
fseek
(
file
,
seekpos
+
head
*
(
sizeof
(
TableStorageElem
)
+
inf_size
),
0
);
j
=
head
;
for
(
i
=
0
;
i
<
size
;
i
++
)
{
fread
(
tbl
,(
key_size
+
val
_size
),
1
,
file
);
if
(
!
strcmp
(
tbl
->
key
,
key
))
fread
(
tbl
,(
sizeof
(
TableStorageElem
)
+
inf
_size
),
1
,
file
);
if
(
!
strcmp
(
tbl
->
key
,
key
)
&&
((
tbl
->
status
==
2
)
||
(
tbl
->
status
==
4
)
||
(
tbl
->
status
==
1
))
)
{
tbl
->
key
[
0
]
=
0
;
fseek
(
file
,
seekpos
+
i
*
(
key_size
+
val_size
),
0
);
fwrite
(
tbl
,(
key_size
+
val_size
),
1
,
file
);
//tbl->key[0]=0;
if
(
tbl
->
status
==
1
)
tbl
->
status
=
6
;
else
if
(
tbl
->
status
==
2
)
tbl
->
status
=
3
;
else
tbl
->
status
=
5
;
fseek
(
file
,
seekpos
+
j
*
(
sizeof
(
TableStorageElem
)
+
inf_size
),
0
);
fwrite
(
tbl
,(
sizeof
(
TableStorageElem
)
+
inf_size
),
1
,
file
);
return
0
;
}
j
++
;
if
(
j
>=
size
)
{
j
=
0
;
fseek
(
file
,
seekpos
,
0
);
}
}
}
return
1
;
...
...
@@ -124,17 +231,18 @@ int TableStorage::DelRow(char* key)
char
*
TableStorage
::
FindKeyValue
(
char
*
key
,
char
*
val
)
{
TableStorageElem
*
tbl
=
new
TableStorageElem
(
);
int
i
;
TableStorageElem
*
tbl
=
(
TableStorageElem
*
)
malloc
(
sizeof
(
TableStorageElem
)
+
inf_size
);
int
i
,
k
;
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
))
fread
(
tbl
,(
sizeof
(
TableStorageElem
)
+
inf
_size
),
1
,
file
);
if
(
!
strcmp
(
tbl
->
key
,
key
)
&&
((
tbl
->
status
==
2
)
||
(
tbl
->
status
==
4
)
||
(
tbl
->
status
==
1
))
)
{
strcpy
(
val
,
tbl
->
value
);
for
(
k
=
0
;
k
<
inf_size
;
k
++
)
*
(
val
+
k
)
=*
((
char
*
)(
tbl
)
+
sizeof
(
TableStorageElem
)
+
k
);
return
val
;
}
}
...
...
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