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/README
ADDED
data/cdb-0.75/SYSDEPS
ADDED
data/cdb-0.75/TARGETS
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
load
|
2
|
+
compile
|
3
|
+
uint32.h
|
4
|
+
cdbget.o
|
5
|
+
systype
|
6
|
+
makelib
|
7
|
+
cdb.o
|
8
|
+
cdb_hash.o
|
9
|
+
cdb_make.o
|
10
|
+
cdb.a
|
11
|
+
strerr_sys.o
|
12
|
+
buffer.o
|
13
|
+
buffer_put.o
|
14
|
+
buffer_2.o
|
15
|
+
strerr_die.o
|
16
|
+
buffer_get.o
|
17
|
+
buffer_copy.o
|
18
|
+
buffer_1.o
|
19
|
+
buffer_0.o
|
20
|
+
buffer_1s.o
|
21
|
+
buffer.a
|
22
|
+
error.o
|
23
|
+
open_read.o
|
24
|
+
open_trunc.o
|
25
|
+
error_str.o
|
26
|
+
seek_set.o
|
27
|
+
seek_cur.o
|
28
|
+
unix.a
|
29
|
+
byte_copy.o
|
30
|
+
byte_cr.o
|
31
|
+
str_len.o
|
32
|
+
fmt_ulong.o
|
33
|
+
uint32_unpack.o
|
34
|
+
byte_diff.o
|
35
|
+
uint32_pack.o
|
36
|
+
scan_ulong.o
|
37
|
+
byte.a
|
38
|
+
cdbget
|
39
|
+
cdbmake.o
|
40
|
+
alloc.o
|
41
|
+
alloc.a
|
42
|
+
cdbmake
|
43
|
+
cdbdump.o
|
44
|
+
cdbdump
|
45
|
+
cdbstats.o
|
46
|
+
cdbstats
|
47
|
+
cdbtest.o
|
48
|
+
cdbtest
|
49
|
+
cdbmake-12
|
50
|
+
cdbmake-sv
|
51
|
+
rts
|
52
|
+
testzero.o
|
53
|
+
testzero
|
54
|
+
prog
|
55
|
+
install.o
|
56
|
+
hier.o
|
57
|
+
auto-str.o
|
58
|
+
auto-str
|
59
|
+
auto_home.c
|
60
|
+
auto_home.o
|
61
|
+
install
|
62
|
+
instcheck.o
|
63
|
+
instcheck
|
64
|
+
it
|
65
|
+
setup
|
66
|
+
check
|
data/cdb-0.75/TODO
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
more rts
|
data/cdb-0.75/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
cdb 0.75
|
data/cdb-0.75/alloc.c
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
#include "alloc.h"
|
2
|
+
#include "error.h"
|
3
|
+
extern char *malloc();
|
4
|
+
extern void free();
|
5
|
+
|
6
|
+
#define ALIGNMENT 16 /* XXX: assuming that this alignment is enough */
|
7
|
+
#define SPACE 4096 /* must be multiple of ALIGNMENT */
|
8
|
+
|
9
|
+
typedef union { char irrelevant[ALIGNMENT]; double d; } aligned;
|
10
|
+
static aligned realspace[SPACE / ALIGNMENT];
|
11
|
+
#define space ((char *) realspace)
|
12
|
+
static unsigned int avail = SPACE; /* multiple of ALIGNMENT; 0<=avail<=SPACE */
|
13
|
+
|
14
|
+
/*@null@*//*@out@*/char *alloc(n)
|
15
|
+
unsigned int n;
|
16
|
+
{
|
17
|
+
char *x;
|
18
|
+
n = ALIGNMENT + n - (n & (ALIGNMENT - 1)); /* XXX: could overflow */
|
19
|
+
if (n <= avail) { avail -= n; return space + avail; }
|
20
|
+
x = malloc(n);
|
21
|
+
if (!x) errno = error_nomem;
|
22
|
+
return x;
|
23
|
+
}
|
24
|
+
|
25
|
+
void alloc_free(x)
|
26
|
+
char *x;
|
27
|
+
{
|
28
|
+
if (x >= space)
|
29
|
+
if (x < space + SPACE)
|
30
|
+
return; /* XXX: assuming that pointers are flat */
|
31
|
+
free(x);
|
32
|
+
}
|
data/cdb-0.75/alloc.h
ADDED
data/cdb-0.75/auto-str.c
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
#include "buffer.h"
|
2
|
+
#include "readwrite.h"
|
3
|
+
#include "exit.h"
|
4
|
+
|
5
|
+
char buf1[256];
|
6
|
+
buffer ss1 = BUFFER_INIT(write,1,buf1,sizeof(buf1));
|
7
|
+
|
8
|
+
void puts(s)
|
9
|
+
char *s;
|
10
|
+
{
|
11
|
+
if (buffer_puts(&ss1,s) == -1) _exit(111);
|
12
|
+
}
|
13
|
+
|
14
|
+
main(argc,argv)
|
15
|
+
int argc;
|
16
|
+
char **argv;
|
17
|
+
{
|
18
|
+
char *name;
|
19
|
+
char *value;
|
20
|
+
unsigned char ch;
|
21
|
+
char octal[4];
|
22
|
+
|
23
|
+
name = argv[1];
|
24
|
+
if (!name) _exit(100);
|
25
|
+
value = argv[2];
|
26
|
+
if (!value) _exit(100);
|
27
|
+
|
28
|
+
puts("char ");
|
29
|
+
puts(name);
|
30
|
+
puts("[] = \"\\\n");
|
31
|
+
|
32
|
+
while (ch = *value++) {
|
33
|
+
puts("\\");
|
34
|
+
octal[3] = 0;
|
35
|
+
octal[2] = '0' + (ch & 7); ch >>= 3;
|
36
|
+
octal[1] = '0' + (ch & 7); ch >>= 3;
|
37
|
+
octal[0] = '0' + (ch & 7);
|
38
|
+
puts(octal);
|
39
|
+
}
|
40
|
+
|
41
|
+
puts("\\\n\";\n");
|
42
|
+
if (buffer_flush(&ss1) == -1) _exit(111);
|
43
|
+
_exit(0);
|
44
|
+
}
|
data/cdb-0.75/buffer.c
ADDED
data/cdb-0.75/buffer.h
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
#ifndef BUFFER_H
|
2
|
+
#define BUFFER_H
|
3
|
+
|
4
|
+
typedef struct buffer {
|
5
|
+
char *x;
|
6
|
+
unsigned int p;
|
7
|
+
unsigned int n;
|
8
|
+
int fd;
|
9
|
+
int (*op)();
|
10
|
+
} buffer;
|
11
|
+
|
12
|
+
#define BUFFER_INIT(op,fd,buf,len) { (buf), 0, (len), (fd), (op) }
|
13
|
+
#define BUFFER_INSIZE 8192
|
14
|
+
#define BUFFER_OUTSIZE 8192
|
15
|
+
|
16
|
+
extern void buffer_init(buffer *,int (*)(),int,char *,unsigned int);
|
17
|
+
|
18
|
+
extern int buffer_flush(buffer *);
|
19
|
+
extern int buffer_put(buffer *,char *,unsigned int);
|
20
|
+
extern int buffer_putalign(buffer *,char *,unsigned int);
|
21
|
+
extern int buffer_putflush(buffer *,char *,unsigned int);
|
22
|
+
extern int buffer_puts(buffer *,char *);
|
23
|
+
extern int buffer_putsalign(buffer *,char *);
|
24
|
+
extern int buffer_putsflush(buffer *,char *);
|
25
|
+
|
26
|
+
#define buffer_PUTC(s,c) \
|
27
|
+
( ((s)->n != (s)->p) \
|
28
|
+
? ( (s)->x[(s)->p++] = (c), 0 ) \
|
29
|
+
: buffer_put((s),&(c),1) \
|
30
|
+
)
|
31
|
+
|
32
|
+
extern int buffer_get(buffer *,char *,unsigned int);
|
33
|
+
extern int buffer_bget(buffer *,char *,unsigned int);
|
34
|
+
extern int buffer_feed(buffer *);
|
35
|
+
|
36
|
+
extern char *buffer_peek(buffer *);
|
37
|
+
extern void buffer_seek(buffer *,unsigned int);
|
38
|
+
|
39
|
+
#define buffer_PEEK(s) ( (s)->x + (s)->n )
|
40
|
+
#define buffer_SEEK(s,len) ( ( (s)->p -= (len) ) , ( (s)->n += (len) ) )
|
41
|
+
|
42
|
+
#define buffer_GETC(s,c) \
|
43
|
+
( ((s)->p > 0) \
|
44
|
+
? ( *(c) = (s)->x[(s)->n], buffer_SEEK((s),1), 1 ) \
|
45
|
+
: buffer_get((s),(c),1) \
|
46
|
+
)
|
47
|
+
|
48
|
+
extern int buffer_copy(buffer *,buffer *);
|
49
|
+
|
50
|
+
extern buffer *buffer_0;
|
51
|
+
extern buffer *buffer_0small;
|
52
|
+
extern buffer *buffer_1;
|
53
|
+
extern buffer *buffer_1small;
|
54
|
+
extern buffer *buffer_2;
|
55
|
+
|
56
|
+
#endif
|
data/cdb-0.75/buffer_0.c
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
#include "readwrite.h"
|
2
|
+
#include "buffer.h"
|
3
|
+
|
4
|
+
int buffer_0_read(fd,buf,len) int fd; char *buf; int len;
|
5
|
+
{
|
6
|
+
if (buffer_flush(buffer_1) == -1) return -1;
|
7
|
+
return read(fd,buf,len);
|
8
|
+
}
|
9
|
+
|
10
|
+
char buffer_0_space[BUFFER_INSIZE];
|
11
|
+
static buffer it = BUFFER_INIT(buffer_0_read,0,buffer_0_space,sizeof buffer_0_space);
|
12
|
+
buffer *buffer_0 = ⁢
|
data/cdb-0.75/buffer_1.c
ADDED
data/cdb-0.75/buffer_2.c
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#include "buffer.h"
|
2
|
+
|
3
|
+
int buffer_copy(buffer *bout,buffer *bin)
|
4
|
+
{
|
5
|
+
int n;
|
6
|
+
char *x;
|
7
|
+
|
8
|
+
for (;;) {
|
9
|
+
n = buffer_feed(bin);
|
10
|
+
if (n < 0) return -2;
|
11
|
+
if (!n) return 0;
|
12
|
+
x = buffer_PEEK(bin);
|
13
|
+
if (buffer_put(bout,x,n) == -1) return -3;
|
14
|
+
buffer_SEEK(bin,n);
|
15
|
+
}
|
16
|
+
}
|
@@ -0,0 +1,67 @@
|
|
1
|
+
#include "buffer.h"
|
2
|
+
#include "byte.h"
|
3
|
+
#include "error.h"
|
4
|
+
|
5
|
+
static int oneread(int (*op)(),int fd,char *buf,unsigned int len)
|
6
|
+
{
|
7
|
+
int r;
|
8
|
+
|
9
|
+
for (;;) {
|
10
|
+
r = op(fd,buf,len);
|
11
|
+
if (r == -1) if (errno == error_intr) continue;
|
12
|
+
return r;
|
13
|
+
}
|
14
|
+
}
|
15
|
+
|
16
|
+
static int getthis(buffer *s,char *buf,unsigned int len)
|
17
|
+
{
|
18
|
+
if (len > s->p) len = s->p;
|
19
|
+
s->p -= len;
|
20
|
+
byte_copy(buf,len,s->x + s->n);
|
21
|
+
s->n += len;
|
22
|
+
return len;
|
23
|
+
}
|
24
|
+
|
25
|
+
int buffer_feed(buffer *s)
|
26
|
+
{
|
27
|
+
int r;
|
28
|
+
|
29
|
+
if (s->p) return s->p;
|
30
|
+
r = oneread(s->op,s->fd,s->x,s->n);
|
31
|
+
if (r <= 0) return r;
|
32
|
+
s->p = r;
|
33
|
+
s->n -= r;
|
34
|
+
if (s->n > 0) byte_copyr(s->x + s->n,r,s->x);
|
35
|
+
return r;
|
36
|
+
}
|
37
|
+
|
38
|
+
int buffer_bget(buffer *s,char *buf,unsigned int len)
|
39
|
+
{
|
40
|
+
int r;
|
41
|
+
|
42
|
+
if (s->p > 0) return getthis(s,buf,len);
|
43
|
+
if (s->n <= len) return oneread(s->op,s->fd,buf,s->n);
|
44
|
+
r = buffer_feed(s); if (r <= 0) return r;
|
45
|
+
return getthis(s,buf,len);
|
46
|
+
}
|
47
|
+
|
48
|
+
int buffer_get(buffer *s,char *buf,unsigned int len)
|
49
|
+
{
|
50
|
+
int r;
|
51
|
+
|
52
|
+
if (s->p > 0) return getthis(s,buf,len);
|
53
|
+
if (s->n <= len) return oneread(s->op,s->fd,buf,len);
|
54
|
+
r = buffer_feed(s); if (r <= 0) return r;
|
55
|
+
return getthis(s,buf,len);
|
56
|
+
}
|
57
|
+
|
58
|
+
char *buffer_peek(buffer *s)
|
59
|
+
{
|
60
|
+
return s->x + s->n;
|
61
|
+
}
|
62
|
+
|
63
|
+
void buffer_seek(buffer *s,unsigned int len)
|
64
|
+
{
|
65
|
+
s->n += len;
|
66
|
+
s->p -= len;
|
67
|
+
}
|
@@ -0,0 +1,88 @@
|
|
1
|
+
#include "buffer.h"
|
2
|
+
#include "str.h"
|
3
|
+
#include "byte.h"
|
4
|
+
#include "error.h"
|
5
|
+
|
6
|
+
static int allwrite(int (*op)(),int fd,char *buf,unsigned int len)
|
7
|
+
{
|
8
|
+
int w;
|
9
|
+
|
10
|
+
while (len) {
|
11
|
+
w = op(fd,buf,len);
|
12
|
+
if (w == -1) {
|
13
|
+
if (errno == error_intr) continue;
|
14
|
+
return -1; /* note that some data may have been written */
|
15
|
+
}
|
16
|
+
if (w == 0) ; /* luser's fault */
|
17
|
+
buf += w;
|
18
|
+
len -= w;
|
19
|
+
}
|
20
|
+
return 0;
|
21
|
+
}
|
22
|
+
|
23
|
+
int buffer_flush(buffer *s)
|
24
|
+
{
|
25
|
+
int p;
|
26
|
+
|
27
|
+
p = s->p;
|
28
|
+
if (!p) return 0;
|
29
|
+
s->p = 0;
|
30
|
+
return allwrite(s->op,s->fd,s->x,p);
|
31
|
+
}
|
32
|
+
|
33
|
+
int buffer_putalign(buffer *s,char *buf,unsigned int len)
|
34
|
+
{
|
35
|
+
unsigned int n;
|
36
|
+
|
37
|
+
while (len > (n = s->n - s->p)) {
|
38
|
+
byte_copy(s->x + s->p,n,buf); s->p += n; buf += n; len -= n;
|
39
|
+
if (buffer_flush(s) == -1) return -1;
|
40
|
+
}
|
41
|
+
/* now len <= s->n - s->p */
|
42
|
+
byte_copy(s->x + s->p,len,buf);
|
43
|
+
s->p += len;
|
44
|
+
return 0;
|
45
|
+
}
|
46
|
+
|
47
|
+
int buffer_put(buffer *s,char *buf,unsigned int len)
|
48
|
+
{
|
49
|
+
unsigned int n;
|
50
|
+
|
51
|
+
n = s->n;
|
52
|
+
if (len > n - s->p) {
|
53
|
+
if (buffer_flush(s) == -1) return -1;
|
54
|
+
/* now s->p == 0 */
|
55
|
+
if (n < BUFFER_OUTSIZE) n = BUFFER_OUTSIZE;
|
56
|
+
while (len > s->n) {
|
57
|
+
if (n > len) n = len;
|
58
|
+
if (allwrite(s->op,s->fd,buf,n) == -1) return -1;
|
59
|
+
buf += n;
|
60
|
+
len -= n;
|
61
|
+
}
|
62
|
+
}
|
63
|
+
/* now len <= s->n - s->p */
|
64
|
+
byte_copy(s->x + s->p,len,buf);
|
65
|
+
s->p += len;
|
66
|
+
return 0;
|
67
|
+
}
|
68
|
+
|
69
|
+
int buffer_putflush(buffer *s,char *buf,unsigned int len)
|
70
|
+
{
|
71
|
+
if (buffer_flush(s) == -1) return -1;
|
72
|
+
return allwrite(s->op,s->fd,buf,len);
|
73
|
+
}
|
74
|
+
|
75
|
+
int buffer_putsalign(buffer *s,char *buf)
|
76
|
+
{
|
77
|
+
return buffer_putalign(s,buf,str_len(buf));
|
78
|
+
}
|
79
|
+
|
80
|
+
int buffer_puts(buffer *s,char *buf)
|
81
|
+
{
|
82
|
+
return buffer_put(s,buf,str_len(buf));
|
83
|
+
}
|
84
|
+
|
85
|
+
int buffer_putsflush(buffer *s,char *buf)
|
86
|
+
{
|
87
|
+
return buffer_putflush(s,buf,str_len(buf));
|
88
|
+
}
|