cdb-full 0.5a
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +6 -0
- data/FILES +88 -0
- data/README +163 -0
- data/VERSION +1 -0
- data/cdb-0.75/CHANGES +16 -0
- data/cdb-0.75/FILES +78 -0
- data/cdb-0.75/Makefile +320 -0
- data/cdb-0.75/README +7 -0
- data/cdb-0.75/SYSDEPS +3 -0
- data/cdb-0.75/TARGETS +66 -0
- data/cdb-0.75/TODO +1 -0
- data/cdb-0.75/VERSION +1 -0
- data/cdb-0.75/alloc.c +32 -0
- data/cdb-0.75/alloc.h +8 -0
- data/cdb-0.75/auto-str.c +44 -0
- data/cdb-0.75/auto_home.h +6 -0
- data/cdb-0.75/buffer.c +10 -0
- data/cdb-0.75/buffer.h +56 -0
- data/cdb-0.75/buffer_0.c +12 -0
- data/cdb-0.75/buffer_1.c +6 -0
- data/cdb-0.75/buffer_1s.c +6 -0
- data/cdb-0.75/buffer_2.c +6 -0
- data/cdb-0.75/buffer_copy.c +16 -0
- data/cdb-0.75/buffer_get.c +67 -0
- data/cdb-0.75/buffer_put.c +88 -0
- data/cdb-0.75/byte.h +13 -0
- data/cdb-0.75/byte_copy.c +14 -0
- data/cdb-0.75/byte_cr.c +16 -0
- data/cdb-0.75/byte_diff.c +16 -0
- data/cdb-0.75/cdb.c +136 -0
- data/cdb-0.75/cdb.h +37 -0
- data/cdb-0.75/cdb_hash.c +21 -0
- data/cdb-0.75/cdb_make.c +153 -0
- data/cdb-0.75/cdb_make.h +39 -0
- data/cdb-0.75/cdbdump.c +83 -0
- data/cdb-0.75/cdbget.c +67 -0
- data/cdb-0.75/cdbmake-12.sh +8 -0
- data/cdb-0.75/cdbmake-sv.sh +22 -0
- data/cdb-0.75/cdbmake.c +110 -0
- data/cdb-0.75/cdbstats.c +125 -0
- data/cdb-0.75/cdbtest.c +119 -0
- data/cdb-0.75/choose.sh +18 -0
- data/cdb-0.75/conf-cc +3 -0
- data/cdb-0.75/conf-home +3 -0
- data/cdb-0.75/conf-ld +3 -0
- data/cdb-0.75/error.c +109 -0
- data/cdb-0.75/error.h +25 -0
- data/cdb-0.75/error_str.c +271 -0
- data/cdb-0.75/exit.h +6 -0
- data/cdb-0.75/find-systype.sh +159 -0
- data/cdb-0.75/fmt.h +25 -0
- data/cdb-0.75/fmt_ulong.c +13 -0
- data/cdb-0.75/hier.c +15 -0
- data/cdb-0.75/install.c +149 -0
- data/cdb-0.75/instcheck.c +108 -0
- data/cdb-0.75/open.h +10 -0
- data/cdb-0.75/open_read.c +6 -0
- data/cdb-0.75/open_trunc.c +6 -0
- data/cdb-0.75/random.cdb +0 -0
- data/cdb-0.75/readwrite.h +7 -0
- data/cdb-0.75/rts.exp +251 -0
- data/cdb-0.75/rts.sh +1 -0
- data/cdb-0.75/rts.tests +210 -0
- data/cdb-0.75/scan.h +28 -0
- data/cdb-0.75/scan_ulong.c +11 -0
- data/cdb-0.75/seek.h +15 -0
- data/cdb-0.75/seek_cur.c +7 -0
- data/cdb-0.75/seek_set.c +7 -0
- data/cdb-0.75/str.h +14 -0
- data/cdb-0.75/str_len.c +14 -0
- data/cdb-0.75/strerr.h +78 -0
- data/cdb-0.75/strerr_die.c +31 -0
- data/cdb-0.75/strerr_sys.c +12 -0
- data/cdb-0.75/testzero.c +35 -0
- data/cdb-0.75/trycpp.c +7 -0
- data/cdb-0.75/tryulong32.c +11 -0
- data/cdb-0.75/uint32.h1 +11 -0
- data/cdb-0.75/uint32.h2 +11 -0
- data/cdb-0.75/uint32_pack.c +21 -0
- data/cdb-0.75/uint32_unpack.c +31 -0
- data/cdb-0.75/warn-auto.sh +2 -0
- data/cdb-0.75/x86cpuid.c +38 -0
- data/cdb.c +372 -0
- data/depend +1 -0
- data/extconf.rb +11 -0
- data/lib/cdb.rb +90 -0
- data/sample/sample.rb +35 -0
- metadata +152 -0
data/cdb-0.75/cdbdump.c
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
#include "uint32.h"
|
2
|
+
#include "fmt.h"
|
3
|
+
#include "buffer.h"
|
4
|
+
#include "strerr.h"
|
5
|
+
|
6
|
+
#define FATAL "cdbdump: fatal: "
|
7
|
+
|
8
|
+
void die_write(void)
|
9
|
+
{
|
10
|
+
strerr_die2sys(111,FATAL,"unable to write output: ");
|
11
|
+
}
|
12
|
+
void put(char *buf,unsigned int len)
|
13
|
+
{
|
14
|
+
if (buffer_put(buffer_1,buf,len) == -1) die_write();
|
15
|
+
}
|
16
|
+
void putflush(void)
|
17
|
+
{
|
18
|
+
if (buffer_flush(buffer_1) == -1) die_write();
|
19
|
+
}
|
20
|
+
|
21
|
+
uint32 pos = 0;
|
22
|
+
|
23
|
+
void get(char *buf,unsigned int len)
|
24
|
+
{
|
25
|
+
int r;
|
26
|
+
while (len > 0) {
|
27
|
+
r = buffer_get(buffer_0,buf,len);
|
28
|
+
if (r == -1)
|
29
|
+
strerr_die2sys(111,FATAL,"unable to read input: ");
|
30
|
+
if (r == 0)
|
31
|
+
strerr_die2x(111,FATAL,"unable to read input: truncated file");
|
32
|
+
pos += r;
|
33
|
+
buf += r;
|
34
|
+
len -= r;
|
35
|
+
}
|
36
|
+
}
|
37
|
+
|
38
|
+
char buf[512];
|
39
|
+
|
40
|
+
void copy(uint32 len)
|
41
|
+
{
|
42
|
+
unsigned int x;
|
43
|
+
|
44
|
+
while (len) {
|
45
|
+
x = sizeof buf;
|
46
|
+
if (len < x) x = len;
|
47
|
+
get(buf,x);
|
48
|
+
put(buf,x);
|
49
|
+
len -= x;
|
50
|
+
}
|
51
|
+
}
|
52
|
+
|
53
|
+
void getnum(uint32 *num)
|
54
|
+
{
|
55
|
+
get(buf,4);
|
56
|
+
uint32_unpack(buf,num);
|
57
|
+
}
|
58
|
+
|
59
|
+
char strnum[FMT_ULONG];
|
60
|
+
|
61
|
+
main()
|
62
|
+
{
|
63
|
+
uint32 eod;
|
64
|
+
uint32 klen;
|
65
|
+
uint32 dlen;
|
66
|
+
|
67
|
+
getnum(&eod);
|
68
|
+
while (pos < 2048) getnum(&dlen);
|
69
|
+
|
70
|
+
while (pos < eod) {
|
71
|
+
getnum(&klen);
|
72
|
+
getnum(&dlen);
|
73
|
+
put("+",1); put(strnum,fmt_ulong(strnum,klen));
|
74
|
+
put(",",1); put(strnum,fmt_ulong(strnum,dlen));
|
75
|
+
put(":",1); copy(klen);
|
76
|
+
put("->",2); copy(dlen);
|
77
|
+
put("\n",1);
|
78
|
+
}
|
79
|
+
|
80
|
+
put("\n",1);
|
81
|
+
putflush();
|
82
|
+
_exit(0);
|
83
|
+
}
|
data/cdb-0.75/cdbget.c
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
#include "exit.h"
|
2
|
+
#include "scan.h"
|
3
|
+
#include "str.h"
|
4
|
+
#include "buffer.h"
|
5
|
+
#include "strerr.h"
|
6
|
+
#include "cdb.h"
|
7
|
+
|
8
|
+
#define FATAL "cdbget: fatal: "
|
9
|
+
|
10
|
+
void die_read(void)
|
11
|
+
{
|
12
|
+
strerr_die2sys(111,FATAL,"unable to read input: ");
|
13
|
+
}
|
14
|
+
void die_write(void)
|
15
|
+
{
|
16
|
+
strerr_die2sys(111,FATAL,"unable to write output: ");
|
17
|
+
}
|
18
|
+
void die_usage(void)
|
19
|
+
{
|
20
|
+
strerr_die1x(111,"cdbget: usage: cdbget key [skip]");
|
21
|
+
}
|
22
|
+
|
23
|
+
static struct cdb c;
|
24
|
+
char buf[1024];
|
25
|
+
|
26
|
+
main(int argc,char **argv)
|
27
|
+
{
|
28
|
+
char *key;
|
29
|
+
int r;
|
30
|
+
uint32 pos;
|
31
|
+
uint32 len;
|
32
|
+
unsigned long u = 0;
|
33
|
+
|
34
|
+
if (!*argv) die_usage();
|
35
|
+
|
36
|
+
if (!*++argv) die_usage();
|
37
|
+
key = *argv;
|
38
|
+
|
39
|
+
if (*++argv) {
|
40
|
+
scan_ulong(*argv,&u);
|
41
|
+
}
|
42
|
+
|
43
|
+
cdb_init(&c,0);
|
44
|
+
cdb_findstart(&c);
|
45
|
+
|
46
|
+
for (;;) {
|
47
|
+
r = cdb_findnext(&c,key,str_len(key));
|
48
|
+
if (r == -1) die_read();
|
49
|
+
if (!r) _exit(100);
|
50
|
+
if (!u) break;
|
51
|
+
--u;
|
52
|
+
}
|
53
|
+
|
54
|
+
pos = cdb_datapos(&c);
|
55
|
+
len = cdb_datalen(&c);
|
56
|
+
|
57
|
+
while (len > 0) {
|
58
|
+
r = sizeof buf;
|
59
|
+
if (r > len) r = len;
|
60
|
+
if (cdb_read(&c,buf,r,pos) == -1) die_read();
|
61
|
+
if (buffer_put(buffer_1small,buf,r) == -1) die_write();
|
62
|
+
pos += r;
|
63
|
+
len -= r;
|
64
|
+
}
|
65
|
+
if (buffer_flush(buffer_1small) == -1) die_write();
|
66
|
+
_exit(0);
|
67
|
+
}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
awk '
|
2
|
+
{
|
3
|
+
if (split($0,x,"#")) {
|
4
|
+
f = split(x[1],y)
|
5
|
+
if (f >= 2) {
|
6
|
+
if (split(y[2],z,"/") >= 2) {
|
7
|
+
a = "@" z[1] "/" z[2]
|
8
|
+
print "+" length(a) "," length(y[1]) ":" a "->" y[1]
|
9
|
+
for (i = 1;i <= f;i += 1) {
|
10
|
+
if (i != 2) {
|
11
|
+
a = y[i] "/" z[2]
|
12
|
+
print "+" length(a) "," length(z[1]) ":" a "->" z[1]
|
13
|
+
}
|
14
|
+
}
|
15
|
+
}
|
16
|
+
}
|
17
|
+
}
|
18
|
+
}
|
19
|
+
END {
|
20
|
+
print ""
|
21
|
+
}
|
22
|
+
' | HOME/bin/cdbmake "$@"
|
data/cdb-0.75/cdbmake.c
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
#include "error.h"
|
2
|
+
#include "open.h"
|
3
|
+
#include "strerr.h"
|
4
|
+
#include "cdb_make.h"
|
5
|
+
#include "cdb.h"
|
6
|
+
|
7
|
+
#define FATAL "cdbmake: fatal: "
|
8
|
+
|
9
|
+
char *fn;
|
10
|
+
char *fntmp;
|
11
|
+
|
12
|
+
void die_usage(void)
|
13
|
+
{
|
14
|
+
strerr_die1x(100,"cdbmake: usage: cdbmake f ftmp");
|
15
|
+
}
|
16
|
+
void die_write(void)
|
17
|
+
{
|
18
|
+
strerr_die4sys(111,FATAL,"unable to create ",fntmp,": ");
|
19
|
+
}
|
20
|
+
void die_read(void)
|
21
|
+
{
|
22
|
+
strerr_die2sys(111,FATAL,"unable to read input: ");
|
23
|
+
}
|
24
|
+
void die_readformat(void)
|
25
|
+
{
|
26
|
+
strerr_die2x(111,FATAL,"unable to read input: bad format");
|
27
|
+
}
|
28
|
+
|
29
|
+
inline void get(char *ch)
|
30
|
+
{
|
31
|
+
switch(buffer_GETC(buffer_0,ch)) {
|
32
|
+
case 0: die_readformat();
|
33
|
+
case -1: die_read();
|
34
|
+
}
|
35
|
+
}
|
36
|
+
|
37
|
+
static struct cdb_make c;
|
38
|
+
|
39
|
+
main(int argc,char **argv)
|
40
|
+
{
|
41
|
+
unsigned int klen;
|
42
|
+
unsigned int dlen;
|
43
|
+
unsigned int i;
|
44
|
+
uint32 h;
|
45
|
+
int fd;
|
46
|
+
char ch;
|
47
|
+
|
48
|
+
if (!*argv) die_usage();
|
49
|
+
|
50
|
+
if (!*++argv) die_usage();
|
51
|
+
fn = *argv;
|
52
|
+
|
53
|
+
if (!*++argv) die_usage();
|
54
|
+
fntmp = *argv;
|
55
|
+
|
56
|
+
fd = open_trunc(fntmp);
|
57
|
+
if (fd == -1) die_write();
|
58
|
+
|
59
|
+
if (cdb_make_start(&c,fd) == -1) die_write();
|
60
|
+
|
61
|
+
for (;;) {
|
62
|
+
get(&ch);
|
63
|
+
if (ch == '\n') break;
|
64
|
+
if (ch != '+') die_readformat();
|
65
|
+
klen = 0;
|
66
|
+
for (;;) {
|
67
|
+
get(&ch);
|
68
|
+
if (ch == ',') break;
|
69
|
+
if ((ch < '0') || (ch > '9')) die_readformat();
|
70
|
+
if (klen > 429496720) { errno = error_nomem; die_write(); }
|
71
|
+
klen = klen * 10 + (ch - '0');
|
72
|
+
}
|
73
|
+
dlen = 0;
|
74
|
+
for (;;) {
|
75
|
+
get(&ch);
|
76
|
+
if (ch == ':') break;
|
77
|
+
if ((ch < '0') || (ch > '9')) die_readformat();
|
78
|
+
if (dlen > 429496720) { errno = error_nomem; die_write(); }
|
79
|
+
dlen = dlen * 10 + (ch - '0');
|
80
|
+
}
|
81
|
+
|
82
|
+
if (cdb_make_addbegin(&c,klen,dlen) == -1) die_write();
|
83
|
+
h = CDB_HASHSTART;
|
84
|
+
for (i = 0;i < klen;++i) {
|
85
|
+
get(&ch);
|
86
|
+
if (buffer_PUTC(&c.b,ch) == -1) die_write();
|
87
|
+
h = cdb_hashadd(h,ch);
|
88
|
+
}
|
89
|
+
get(&ch);
|
90
|
+
if (ch != '-') die_readformat();
|
91
|
+
get(&ch);
|
92
|
+
if (ch != '>') die_readformat();
|
93
|
+
for (i = 0;i < dlen;++i) {
|
94
|
+
get(&ch);
|
95
|
+
if (buffer_PUTC(&c.b,ch) == -1) die_write();
|
96
|
+
}
|
97
|
+
if (cdb_make_addend(&c,klen,dlen,h) == -1) die_write();
|
98
|
+
|
99
|
+
get(&ch);
|
100
|
+
if (ch != '\n') die_readformat();
|
101
|
+
}
|
102
|
+
|
103
|
+
if (cdb_make_finish(&c) == -1) die_write();
|
104
|
+
if (fsync(fd) == -1) die_write();
|
105
|
+
if (close(fd) == -1) die_write(); /* NFS silliness */
|
106
|
+
if (rename(fntmp,fn) == -1)
|
107
|
+
strerr_die6sys(111,FATAL,"unable to rename ",fntmp," to ",fn,": ");
|
108
|
+
|
109
|
+
_exit(0);
|
110
|
+
}
|
data/cdb-0.75/cdbstats.c
ADDED
@@ -0,0 +1,125 @@
|
|
1
|
+
#include "uint32.h"
|
2
|
+
#include "fmt.h"
|
3
|
+
#include "buffer.h"
|
4
|
+
#include "strerr.h"
|
5
|
+
#include "seek.h"
|
6
|
+
#include "cdb.h"
|
7
|
+
|
8
|
+
#define FATAL "cdbstats: fatal: "
|
9
|
+
|
10
|
+
void die_read(void)
|
11
|
+
{
|
12
|
+
strerr_die2sys(111,FATAL,"unable to read input: ");
|
13
|
+
}
|
14
|
+
void die_readformat(void)
|
15
|
+
{
|
16
|
+
strerr_die2x(111,FATAL,"unable to read input: truncated file");
|
17
|
+
}
|
18
|
+
void die_write(void)
|
19
|
+
{
|
20
|
+
strerr_die2sys(111,FATAL,"unable to write output: ");
|
21
|
+
}
|
22
|
+
void put(char *buf,unsigned int len)
|
23
|
+
{
|
24
|
+
if (buffer_put(buffer_1small,buf,len) == -1) die_write();
|
25
|
+
}
|
26
|
+
void putflush(void)
|
27
|
+
{
|
28
|
+
if (buffer_flush(buffer_1small) == -1) die_write();
|
29
|
+
}
|
30
|
+
|
31
|
+
uint32 pos = 0;
|
32
|
+
|
33
|
+
void get(char *buf,unsigned int len)
|
34
|
+
{
|
35
|
+
int r;
|
36
|
+
while (len > 0) {
|
37
|
+
r = buffer_get(buffer_0,buf,len);
|
38
|
+
if (r == -1) die_read();
|
39
|
+
if (r == 0) die_readformat();
|
40
|
+
pos += r;
|
41
|
+
buf += r;
|
42
|
+
len -= r;
|
43
|
+
}
|
44
|
+
}
|
45
|
+
|
46
|
+
void getnum(uint32 *num)
|
47
|
+
{
|
48
|
+
char buf[4];
|
49
|
+
get(buf,4);
|
50
|
+
uint32_unpack(buf,num);
|
51
|
+
}
|
52
|
+
|
53
|
+
char strnum[FMT_ULONG];
|
54
|
+
|
55
|
+
void putnum(char *label,unsigned long count)
|
56
|
+
{
|
57
|
+
unsigned int i;
|
58
|
+
put(label,str_len(label));
|
59
|
+
for (i = fmt_ulong(0,count);i < 10;++i) put(" ",1);
|
60
|
+
put(strnum,fmt_ulong(strnum,count));
|
61
|
+
put("\n",1);
|
62
|
+
}
|
63
|
+
|
64
|
+
char key[1024];
|
65
|
+
|
66
|
+
static struct cdb c;
|
67
|
+
|
68
|
+
static unsigned long numrecords;
|
69
|
+
static unsigned long numd[11];
|
70
|
+
|
71
|
+
main()
|
72
|
+
{
|
73
|
+
uint32 eod;
|
74
|
+
uint32 klen;
|
75
|
+
uint32 dlen;
|
76
|
+
seek_pos rest;
|
77
|
+
int r;
|
78
|
+
|
79
|
+
cdb_init(&c,0);
|
80
|
+
|
81
|
+
getnum(&eod);
|
82
|
+
while (pos < 2048) getnum(&dlen);
|
83
|
+
|
84
|
+
while (pos < eod) {
|
85
|
+
getnum(&klen);
|
86
|
+
getnum(&dlen);
|
87
|
+
if (klen > sizeof key) {
|
88
|
+
while (klen) { get(key,1); --klen; }
|
89
|
+
}
|
90
|
+
else {
|
91
|
+
get(key,klen);
|
92
|
+
rest = seek_cur(0);
|
93
|
+
cdb_findstart(&c);
|
94
|
+
do {
|
95
|
+
switch(cdb_findnext(&c,key,klen)) {
|
96
|
+
case -1: die_read();
|
97
|
+
case 0: die_readformat();
|
98
|
+
}
|
99
|
+
} while (cdb_datapos(&c) != pos);
|
100
|
+
if (!c.loop) die_readformat();
|
101
|
+
++numrecords;
|
102
|
+
if (c.loop > 10)
|
103
|
+
++numd[10];
|
104
|
+
else
|
105
|
+
++numd[c.loop - 1];
|
106
|
+
if (seek_set(0,rest) == -1) die_read();
|
107
|
+
}
|
108
|
+
while (dlen) { get(key,1); --dlen; }
|
109
|
+
}
|
110
|
+
|
111
|
+
putnum("records ",numrecords);
|
112
|
+
putnum("d0 ",numd[0]);
|
113
|
+
putnum("d1 ",numd[1]);
|
114
|
+
putnum("d2 ",numd[2]);
|
115
|
+
putnum("d3 ",numd[3]);
|
116
|
+
putnum("d4 ",numd[4]);
|
117
|
+
putnum("d5 ",numd[5]);
|
118
|
+
putnum("d6 ",numd[6]);
|
119
|
+
putnum("d7 ",numd[7]);
|
120
|
+
putnum("d8 ",numd[8]);
|
121
|
+
putnum("d9 ",numd[9]);
|
122
|
+
putnum(">9 ",numd[10]);
|
123
|
+
putflush();
|
124
|
+
_exit(0);
|
125
|
+
}
|
data/cdb-0.75/cdbtest.c
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
#include "uint32.h"
|
2
|
+
#include "fmt.h"
|
3
|
+
#include "buffer.h"
|
4
|
+
#include "strerr.h"
|
5
|
+
#include "seek.h"
|
6
|
+
#include "cdb.h"
|
7
|
+
|
8
|
+
#define FATAL "cdbtest: fatal: "
|
9
|
+
|
10
|
+
void die_read(void)
|
11
|
+
{
|
12
|
+
strerr_die2sys(111,FATAL,"unable to read input: ");
|
13
|
+
}
|
14
|
+
void die_write(void)
|
15
|
+
{
|
16
|
+
strerr_die2sys(111,FATAL,"unable to write output: ");
|
17
|
+
}
|
18
|
+
void put(char *buf,unsigned int len)
|
19
|
+
{
|
20
|
+
if (buffer_put(buffer_1small,buf,len) == -1) die_write();
|
21
|
+
}
|
22
|
+
void putflush(void)
|
23
|
+
{
|
24
|
+
if (buffer_flush(buffer_1small) == -1) die_write();
|
25
|
+
}
|
26
|
+
|
27
|
+
uint32 pos = 0;
|
28
|
+
|
29
|
+
void get(char *buf,unsigned int len)
|
30
|
+
{
|
31
|
+
int r;
|
32
|
+
while (len > 0) {
|
33
|
+
r = buffer_get(buffer_0,buf,len);
|
34
|
+
if (r == -1) die_read();
|
35
|
+
if (r == 0)
|
36
|
+
strerr_die2x(111,FATAL,"unable to read input: truncated file");
|
37
|
+
pos += r;
|
38
|
+
buf += r;
|
39
|
+
len -= r;
|
40
|
+
}
|
41
|
+
}
|
42
|
+
|
43
|
+
void getnum(uint32 *num)
|
44
|
+
{
|
45
|
+
char buf[4];
|
46
|
+
get(buf,4);
|
47
|
+
uint32_unpack(buf,num);
|
48
|
+
}
|
49
|
+
|
50
|
+
char strnum[FMT_ULONG];
|
51
|
+
|
52
|
+
void putnum(char *label,unsigned long count)
|
53
|
+
{
|
54
|
+
put(label,str_len(label));
|
55
|
+
put(strnum,fmt_ulong(strnum,count));
|
56
|
+
put("\n",1);
|
57
|
+
}
|
58
|
+
|
59
|
+
char key[1024];
|
60
|
+
|
61
|
+
unsigned long numuntested = 0;
|
62
|
+
unsigned long numnotfound = 0;
|
63
|
+
unsigned long numotherpos = 0;
|
64
|
+
unsigned long numbadlen = 0;
|
65
|
+
unsigned long numfound = 0;
|
66
|
+
|
67
|
+
static struct cdb c;
|
68
|
+
|
69
|
+
main()
|
70
|
+
{
|
71
|
+
uint32 eod;
|
72
|
+
uint32 klen;
|
73
|
+
uint32 dlen;
|
74
|
+
seek_pos rest;
|
75
|
+
int r;
|
76
|
+
|
77
|
+
cdb_init(&c,0);
|
78
|
+
|
79
|
+
getnum(&eod);
|
80
|
+
while (pos < 2048) getnum(&dlen);
|
81
|
+
|
82
|
+
while (pos < eod) {
|
83
|
+
getnum(&klen);
|
84
|
+
getnum(&dlen);
|
85
|
+
if (klen > sizeof key) {
|
86
|
+
++numuntested;
|
87
|
+
while (klen) { get(key,1); --klen; }
|
88
|
+
}
|
89
|
+
else {
|
90
|
+
get(key,klen);
|
91
|
+
rest = seek_cur(0);
|
92
|
+
switch(cdb_find(&c,key,klen)) {
|
93
|
+
case -1:
|
94
|
+
die_read();
|
95
|
+
case 0:
|
96
|
+
++numnotfound;
|
97
|
+
break;
|
98
|
+
default:
|
99
|
+
if (cdb_datapos(&c) != pos)
|
100
|
+
++numotherpos;
|
101
|
+
else
|
102
|
+
if (cdb_datalen(&c) != dlen)
|
103
|
+
++numbadlen;
|
104
|
+
else
|
105
|
+
++numfound;
|
106
|
+
}
|
107
|
+
if (seek_set(0,rest) == -1) die_read();
|
108
|
+
}
|
109
|
+
while (dlen) { get(key,1); --dlen; }
|
110
|
+
}
|
111
|
+
|
112
|
+
putnum("found: ",numfound);
|
113
|
+
putnum("different record: ",numotherpos);
|
114
|
+
putnum("bad length: ",numbadlen);
|
115
|
+
putnum("not found: ",numnotfound);
|
116
|
+
putnum("untested: ",numuntested);
|
117
|
+
putflush();
|
118
|
+
_exit(0);
|
119
|
+
}
|