cdb-full 0.5a

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. data/COPYING +6 -0
  2. data/FILES +88 -0
  3. data/README +163 -0
  4. data/VERSION +1 -0
  5. data/cdb-0.75/CHANGES +16 -0
  6. data/cdb-0.75/FILES +78 -0
  7. data/cdb-0.75/Makefile +320 -0
  8. data/cdb-0.75/README +7 -0
  9. data/cdb-0.75/SYSDEPS +3 -0
  10. data/cdb-0.75/TARGETS +66 -0
  11. data/cdb-0.75/TODO +1 -0
  12. data/cdb-0.75/VERSION +1 -0
  13. data/cdb-0.75/alloc.c +32 -0
  14. data/cdb-0.75/alloc.h +8 -0
  15. data/cdb-0.75/auto-str.c +44 -0
  16. data/cdb-0.75/auto_home.h +6 -0
  17. data/cdb-0.75/buffer.c +10 -0
  18. data/cdb-0.75/buffer.h +56 -0
  19. data/cdb-0.75/buffer_0.c +12 -0
  20. data/cdb-0.75/buffer_1.c +6 -0
  21. data/cdb-0.75/buffer_1s.c +6 -0
  22. data/cdb-0.75/buffer_2.c +6 -0
  23. data/cdb-0.75/buffer_copy.c +16 -0
  24. data/cdb-0.75/buffer_get.c +67 -0
  25. data/cdb-0.75/buffer_put.c +88 -0
  26. data/cdb-0.75/byte.h +13 -0
  27. data/cdb-0.75/byte_copy.c +14 -0
  28. data/cdb-0.75/byte_cr.c +16 -0
  29. data/cdb-0.75/byte_diff.c +16 -0
  30. data/cdb-0.75/cdb.c +136 -0
  31. data/cdb-0.75/cdb.h +37 -0
  32. data/cdb-0.75/cdb_hash.c +21 -0
  33. data/cdb-0.75/cdb_make.c +153 -0
  34. data/cdb-0.75/cdb_make.h +39 -0
  35. data/cdb-0.75/cdbdump.c +83 -0
  36. data/cdb-0.75/cdbget.c +67 -0
  37. data/cdb-0.75/cdbmake-12.sh +8 -0
  38. data/cdb-0.75/cdbmake-sv.sh +22 -0
  39. data/cdb-0.75/cdbmake.c +110 -0
  40. data/cdb-0.75/cdbstats.c +125 -0
  41. data/cdb-0.75/cdbtest.c +119 -0
  42. data/cdb-0.75/choose.sh +18 -0
  43. data/cdb-0.75/conf-cc +3 -0
  44. data/cdb-0.75/conf-home +3 -0
  45. data/cdb-0.75/conf-ld +3 -0
  46. data/cdb-0.75/error.c +109 -0
  47. data/cdb-0.75/error.h +25 -0
  48. data/cdb-0.75/error_str.c +271 -0
  49. data/cdb-0.75/exit.h +6 -0
  50. data/cdb-0.75/find-systype.sh +159 -0
  51. data/cdb-0.75/fmt.h +25 -0
  52. data/cdb-0.75/fmt_ulong.c +13 -0
  53. data/cdb-0.75/hier.c +15 -0
  54. data/cdb-0.75/install.c +149 -0
  55. data/cdb-0.75/instcheck.c +108 -0
  56. data/cdb-0.75/open.h +10 -0
  57. data/cdb-0.75/open_read.c +6 -0
  58. data/cdb-0.75/open_trunc.c +6 -0
  59. data/cdb-0.75/random.cdb +0 -0
  60. data/cdb-0.75/readwrite.h +7 -0
  61. data/cdb-0.75/rts.exp +251 -0
  62. data/cdb-0.75/rts.sh +1 -0
  63. data/cdb-0.75/rts.tests +210 -0
  64. data/cdb-0.75/scan.h +28 -0
  65. data/cdb-0.75/scan_ulong.c +11 -0
  66. data/cdb-0.75/seek.h +15 -0
  67. data/cdb-0.75/seek_cur.c +7 -0
  68. data/cdb-0.75/seek_set.c +7 -0
  69. data/cdb-0.75/str.h +14 -0
  70. data/cdb-0.75/str_len.c +14 -0
  71. data/cdb-0.75/strerr.h +78 -0
  72. data/cdb-0.75/strerr_die.c +31 -0
  73. data/cdb-0.75/strerr_sys.c +12 -0
  74. data/cdb-0.75/testzero.c +35 -0
  75. data/cdb-0.75/trycpp.c +7 -0
  76. data/cdb-0.75/tryulong32.c +11 -0
  77. data/cdb-0.75/uint32.h1 +11 -0
  78. data/cdb-0.75/uint32.h2 +11 -0
  79. data/cdb-0.75/uint32_pack.c +21 -0
  80. data/cdb-0.75/uint32_unpack.c +31 -0
  81. data/cdb-0.75/warn-auto.sh +2 -0
  82. data/cdb-0.75/x86cpuid.c +38 -0
  83. data/cdb.c +372 -0
  84. data/depend +1 -0
  85. data/extconf.rb +11 -0
  86. data/lib/cdb.rb +90 -0
  87. data/sample/sample.rb +35 -0
  88. metadata +152 -0
@@ -0,0 +1,7 @@
1
+ cdb 0.75, beta.
2
+ 20000219
3
+ Copyright 2000
4
+ D. J. Bernstein
5
+
6
+ cdb home page: http://cr.yp.to/cdb.html
7
+ Installation instructions: http://cr.yp.to/cdb/install.html
@@ -0,0 +1,3 @@
1
+ VERSION
2
+ systype
3
+ uint32.h
@@ -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
@@ -0,0 +1 @@
1
+ more rts
@@ -0,0 +1 @@
1
+ cdb 0.75
@@ -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
+ }
@@ -0,0 +1,8 @@
1
+ #ifndef ALLOC_H
2
+ #define ALLOC_H
3
+
4
+ extern /*@null@*//*@out@*/char *alloc();
5
+ extern void alloc_free();
6
+ extern int alloc_re();
7
+
8
+ #endif
@@ -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
+ }
@@ -0,0 +1,6 @@
1
+ #ifndef AUTO_HOME_H
2
+ #define AUTO_HOME_H
3
+
4
+ extern char auto_home[];
5
+
6
+ #endif
@@ -0,0 +1,10 @@
1
+ #include "buffer.h"
2
+
3
+ void buffer_init(buffer *s,int (*op)(),int fd,char *buf,unsigned int len)
4
+ {
5
+ s->x = buf;
6
+ s->fd = fd;
7
+ s->op = op;
8
+ s->p = 0;
9
+ s->n = len;
10
+ }
@@ -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
@@ -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 = &it;
@@ -0,0 +1,6 @@
1
+ #include "readwrite.h"
2
+ #include "buffer.h"
3
+
4
+ char buffer_1_space[BUFFER_OUTSIZE];
5
+ static buffer it = BUFFER_INIT(write,1,buffer_1_space,sizeof buffer_1_space);
6
+ buffer *buffer_1 = &it;
@@ -0,0 +1,6 @@
1
+ #include "readwrite.h"
2
+ #include "buffer.h"
3
+
4
+ char buffer_1small_space[256];
5
+ static buffer it = BUFFER_INIT(write,1,buffer_1small_space,sizeof buffer_1small_space);
6
+ buffer *buffer_1small = &it;
@@ -0,0 +1,6 @@
1
+ #include "readwrite.h"
2
+ #include "buffer.h"
3
+
4
+ char buffer_2_space[256];
5
+ static buffer it = BUFFER_INIT(write,2,buffer_2_space,sizeof buffer_2_space);
6
+ buffer *buffer_2 = &it;
@@ -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
+ }