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,10 @@
1
+ #ifndef OPEN_H
2
+ #define OPEN_H
3
+
4
+ extern int open_read(char *);
5
+ extern int open_excl(char *);
6
+ extern int open_append(char *);
7
+ extern int open_trunc(char *);
8
+ extern int open_write(char *);
9
+
10
+ #endif
@@ -0,0 +1,6 @@
1
+ #include <sys/types.h>
2
+ #include <fcntl.h>
3
+ #include "open.h"
4
+
5
+ int open_read(char *fn)
6
+ { return open(fn,O_RDONLY | O_NDELAY); }
@@ -0,0 +1,6 @@
1
+ #include <sys/types.h>
2
+ #include <fcntl.h>
3
+ #include "open.h"
4
+
5
+ int open_trunc(char *fn)
6
+ { return open(fn,O_WRONLY | O_NDELAY | O_TRUNC | O_CREAT,0644); }
Binary file
@@ -0,0 +1,7 @@
1
+ #ifndef READWRITE_H
2
+ #define READWRITE_H
3
+
4
+ extern int read();
5
+ extern int write();
6
+
7
+ #endif
@@ -0,0 +1,251 @@
1
+ --- cdbmake handles simple example
2
+ 0
3
+ --- cdbmake-12 handles simple example
4
+ 0
5
+ --- cdbmake-sv handles simple example
6
+ 0
7
+ --- cdbdump handles simple examples
8
+ +3,5:one->Hello
9
+ +3,7:two->Goodbye
10
+
11
+ 0
12
+ +3,5:one->Hello
13
+ +3,7:two->Goodbye
14
+
15
+ 0
16
+ +6,4:@7/tcp->echo
17
+ +8,1:echo/tcp->7
18
+ +6,4:@7/udp->echo
19
+ +8,1:echo/udp->7
20
+ +6,7:@9/tcp->discard
21
+ +11,1:discard/tcp->9
22
+ +8,1:sink/tcp->9
23
+ +8,1:null/tcp->9
24
+ +6,7:@9/udp->discard
25
+ +11,1:discard/udp->9
26
+ +8,1:sink/udp->9
27
+ +8,1:null/udp->9
28
+ +7,6:@11/tcp->systat
29
+ +10,2:systat/tcp->11
30
+ +9,2:users/tcp->11
31
+ +7,6:@11/udp->systat
32
+ +10,2:systat/udp->11
33
+ +9,2:users/udp->11
34
+
35
+ 0
36
+ --- cdbtest handles simple examples
37
+ found: 2
38
+ different record: 0
39
+ bad length: 0
40
+ not found: 0
41
+ untested: 0
42
+ 0
43
+ found: 2
44
+ different record: 0
45
+ bad length: 0
46
+ not found: 0
47
+ untested: 0
48
+ 0
49
+ found: 18
50
+ different record: 0
51
+ bad length: 0
52
+ not found: 0
53
+ untested: 0
54
+ 0
55
+ --- cdbstats handles simple examples
56
+ records 2
57
+ d0 2
58
+ d1 0
59
+ d2 0
60
+ d3 0
61
+ d4 0
62
+ d5 0
63
+ d6 0
64
+ d7 0
65
+ d8 0
66
+ d9 0
67
+ >9 0
68
+ 0
69
+ records 2
70
+ d0 2
71
+ d1 0
72
+ d2 0
73
+ d3 0
74
+ d4 0
75
+ d5 0
76
+ d6 0
77
+ d7 0
78
+ d8 0
79
+ d9 0
80
+ >9 0
81
+ 0
82
+ records 18
83
+ d0 18
84
+ d1 0
85
+ d2 0
86
+ d3 0
87
+ d4 0
88
+ d5 0
89
+ d6 0
90
+ d7 0
91
+ d8 0
92
+ d9 0
93
+ >9 0
94
+ 0
95
+ --- cdbget retrieves data successfully
96
+ Hello
97
+ 0
98
+ Goodbye
99
+ 0
100
+ echo
101
+ 0
102
+ echo
103
+ 0
104
+ 7
105
+ 0
106
+ 7
107
+ 0
108
+ discard
109
+ 0
110
+ discard
111
+ 0
112
+ 9
113
+ 0
114
+ 9
115
+ 0
116
+ 9
117
+ 0
118
+ 9
119
+ 0
120
+ 9
121
+ 0
122
+ 9
123
+ 0
124
+ systat
125
+ 0
126
+ systat
127
+ 0
128
+ 11
129
+ 0
130
+ 11
131
+ 0
132
+ 11
133
+ 0
134
+ 11
135
+ 0
136
+ --- cdbget exits 100 on nonexistent data
137
+ 100
138
+ 100
139
+ --- cdbmake handles repeated keys
140
+ 0
141
+ +3,5:one->Hello
142
+ +3,7:one->Goodbye
143
+ +3,7:one->Another
144
+
145
+ 0
146
+ --- cdbget handles repeated keys
147
+ Hello
148
+ 0
149
+ Hello
150
+ 0
151
+ Goodbye
152
+ 0
153
+ Another
154
+ 0
155
+
156
+ 100
157
+
158
+ 100
159
+ --- cdbmake handles long keys and data
160
+ 0
161
+ --- cdbdump handles long keys and data
162
+ +320,320:ba483b3442e75cace82def4b5df25bfca887b41687537c21dc4b82cb4c36315e2f6a0661d1af2e05e686c4c595c16561d8c1b3fbee8a6b99c54b3d10d61948445298e97e971f85a600c88164d6b0b09
163
+ b5169a54910232db0a56938de61256721667bddc1c0a2b14f5d063ab586a87a957e87f704acb7246c5e8c25becef713a365efef79bb1f406fecee88f3261f68e239c5903e3145961eb0fbc538ff506a
164
+ ->152e113d5deec3638ead782b93e1b9666d265feb5aebc840e79aa69e2cfc1a2ce4b3254b79fa73c338d22a75e67cfed4cd17b92c405e204a48f21c31cdcf7da46312dc80debfbdaf6dc39d74694a711
165
+ 6d170c5fde1a81806847cf71732c7f3217a38c6234235951af7b7c1d32e62d480d7c82a63a9d94291d92767ed97dd6a6809d1eb856ce23eda20268cb53fda31c016a19fc20e80aec3bd594a3eb82a5a
166
+
167
+
168
+ 0
169
+ --- cdbtest handles long keys and data
170
+ found: 1
171
+ different record: 0
172
+ bad length: 0
173
+ not found: 0
174
+ untested: 0
175
+ 0
176
+ --- cdbstats handles long keys and data
177
+ records 1
178
+ d0 1
179
+ d1 0
180
+ d2 0
181
+ d3 0
182
+ d4 0
183
+ d5 0
184
+ d6 0
185
+ d7 0
186
+ d8 0
187
+ d9 0
188
+ >9 0
189
+ 0
190
+ --- cdbget handles long keys and data
191
+ 152e113d5deec3638ead782b93e1b9666d265feb5aebc840e79aa69e2cfc1a2ce4b3254b79fa73c338d22a75e67cfed4cd17b92c405e204a48f21c31cdcf7da46312dc80debfbdaf6dc39d74694a711
192
+ 6d170c5fde1a81806847cf71732c7f3217a38c6234235951af7b7c1d32e62d480d7c82a63a9d94291d92767ed97dd6a6809d1eb856ce23eda20268cb53fda31c016a19fc20e80aec3bd594a3eb82a5a
193
+
194
+ 0
195
+ --- cdbmake handles unwritable tmp
196
+ cdbmake: fatal: unable to create loop: symbolic link loop
197
+ 111
198
+ --- cdbmake handles unmovable cdb
199
+ cdbmake: fatal: unable to rename test.tmp to loop/test.cdb: symbolic link loop
200
+ 111
201
+ --- cdbmake handles nomem
202
+ cdbmake: fatal: unable to create test.tmp: out of memory
203
+ 111
204
+ --- cdbmake handles full disk
205
+ cdbmake: fatal: unable to create test.tmp: file too big
206
+ 111
207
+ --- cdbmake handles absurd klen
208
+ cdbmake: fatal: unable to create test.tmp: out of memory
209
+ 111
210
+ --- cdbget handles empty file
211
+ cdbget: fatal: unable to read input: protocol error
212
+ 111
213
+ --- cdbdump and cdbmake handle random.cdb
214
+ 0
215
+ --- cdbtest handles random.cdb
216
+ found: 100
217
+ different record: 0
218
+ bad length: 0
219
+ not found: 0
220
+ untested: 0
221
+ 0
222
+ --- cdbstats handles random.cdb
223
+ records 100
224
+ d0 96
225
+ d1 4
226
+ d2 0
227
+ d3 0
228
+ d4 0
229
+ d5 0
230
+ d6 0
231
+ d7 0
232
+ d8 0
233
+ d9 0
234
+ >9 0
235
+ 0
236
+ --- testzero works
237
+ 0
238
+ found: 5
239
+ different record: 0
240
+ bad length: 0
241
+ not found: 0
242
+ untested: 0
243
+ 0
244
+ --- testzero can build a database very close to 4GB
245
+ 0
246
+ --- testzero complains if hash table passes 4GB
247
+ testzero: fatal: unable to write: out of memory
248
+ 111
249
+ --- testzero complains if records pass 4GB
250
+ testzero: fatal: unable to write: out of memory
251
+ 111
@@ -0,0 +1 @@
1
+ env - PATH="`pwd`:$PATH" sh rts.tests 2>&1 | cat -v
@@ -0,0 +1,210 @@
1
+ # Requirements:
2
+ # You have softlimit in your path.
3
+ # XFSZ is signal 25.
4
+ #
5
+ # Some features not tested here:
6
+ # cdbmake traps 4GB overflows.
7
+
8
+
9
+ umask 022
10
+
11
+ rm -rf rts-tmp
12
+ mkdir rts-tmp
13
+ cd rts-tmp
14
+
15
+
16
+ echo '--- cdbmake handles simple example'
17
+ echo '+3,5:one->Hello
18
+ +3,7:two->Goodbye
19
+ ' | cdbmake test.cdb test.tmp
20
+ echo $?
21
+
22
+ echo '--- cdbmake-12 handles simple example'
23
+ echo '
24
+ one Hello
25
+ # comment line
26
+ two Goodbye
27
+ ' | cdbmake-12 12.cdb 12.tmp
28
+ echo $?
29
+
30
+ echo '--- cdbmake-sv handles simple example'
31
+ echo '
32
+ # Network services, Internet style
33
+ echo 7/tcp
34
+ echo 7/udp
35
+ discard 9/tcp sink null
36
+ discard 9/udp sink null
37
+ systat 11/tcp users #Active Users
38
+ systat 11/udp users #Active Users
39
+ ' | cdbmake-sv sv.cdb sv.tmp
40
+ echo $?
41
+
42
+ echo '--- cdbdump handles simple examples'
43
+ cdbdump < test.cdb
44
+ echo $?
45
+ cdbdump < 12.cdb
46
+ echo $?
47
+ cdbdump < sv.cdb
48
+ echo $?
49
+
50
+ echo '--- cdbtest handles simple examples'
51
+ cdbtest < test.cdb
52
+ echo $?
53
+ cdbtest < 12.cdb
54
+ echo $?
55
+ cdbtest < sv.cdb
56
+ echo $?
57
+
58
+ echo '--- cdbstats handles simple examples'
59
+ cdbstats < test.cdb
60
+ echo $?
61
+ cdbstats < 12.cdb
62
+ echo $?
63
+ cdbstats < sv.cdb
64
+ echo $?
65
+
66
+ echo '--- cdbget retrieves data successfully'
67
+ cdbget one < test.cdb
68
+ echo '
69
+ '$?
70
+ cdbget two < test.cdb
71
+ echo '
72
+ '$?
73
+ for i in @7 echo @9 discard sink null @11 systat users
74
+ do
75
+ cdbget $i/tcp < sv.cdb
76
+ echo '
77
+ '$?
78
+ cdbget $i/udp < sv.cdb
79
+ echo '
80
+ '$?
81
+ done
82
+
83
+ echo '--- cdbget exits 100 on nonexistent data'
84
+ cdbget three < test.cdb
85
+ echo $?
86
+ cdbget '#Active' < sv.cdb
87
+ echo $?
88
+
89
+
90
+ echo '--- cdbmake handles repeated keys'
91
+ echo '+3,5:one->Hello
92
+ +3,7:one->Goodbye
93
+ +3,7:one->Another
94
+ ' | cdbmake rep.cdb rep.tmp
95
+ echo $?
96
+ cdbdump < rep.cdb
97
+ echo $?
98
+
99
+ echo '--- cdbget handles repeated keys'
100
+ cdbget one < rep.cdb
101
+ echo '
102
+ '$?
103
+ cdbget one 0 < rep.cdb
104
+ echo '
105
+ '$?
106
+ cdbget one 1 < rep.cdb
107
+ echo '
108
+ '$?
109
+ cdbget one 2 < rep.cdb
110
+ echo '
111
+ '$?
112
+ cdbget one 3 < rep.cdb
113
+ echo '
114
+ '$?
115
+ cdbget one 4 < rep.cdb
116
+ echo '
117
+ '$?
118
+
119
+ echo '--- cdbmake handles long keys and data'
120
+ echo '+320,320:ba483b3442e75cace82def4b5df25bfca887b41687537c21dc4b82cb4c36315e2f6a0661d1af2e05e686c4c595c16561d8c1b3fbee8a6b99c54b3d10d61948445298e97e971f85a600c88164d6b0b09
121
+ b5169a54910232db0a56938de61256721667bddc1c0a2b14f5d063ab586a87a957e87f704acb7246c5e8c25becef713a365efef79bb1f406fecee88f3261f68e239c5903e3145961eb0fbc538ff506a
122
+ ->152e113d5deec3638ead782b93e1b9666d265feb5aebc840e79aa69e2cfc1a2ce4b3254b79fa73c338d22a75e67cfed4cd17b92c405e204a48f21c31cdcf7da46312dc80debfbdaf6dc39d74694a711
123
+ 6d170c5fde1a81806847cf71732c7f3217a38c6234235951af7b7c1d32e62d480d7c82a63a9d94291d92767ed97dd6a6809d1eb856ce23eda20268cb53fda31c016a19fc20e80aec3bd594a3eb82a5a
124
+
125
+ ' | cdbmake test.cdb test.tmp
126
+ echo $?
127
+
128
+ echo '--- cdbdump handles long keys and data'
129
+ cdbdump < test.cdb
130
+ echo $?
131
+
132
+ echo '--- cdbtest handles long keys and data'
133
+ cdbtest < test.cdb
134
+ echo $?
135
+
136
+ echo '--- cdbstats handles long keys and data'
137
+ cdbstats < test.cdb
138
+ echo $?
139
+
140
+ echo '--- cdbget handles long keys and data'
141
+ cdbget 'ba483b3442e75cace82def4b5df25bfca887b41687537c21dc4b82cb4c36315e2f6a0661d1af2e05e686c4c595c16561d8c1b3fbee8a6b99c54b3d10d61948445298e97e971f85a600c88164d6b0b09
142
+ b5169a54910232db0a56938de61256721667bddc1c0a2b14f5d063ab586a87a957e87f704acb7246c5e8c25becef713a365efef79bb1f406fecee88f3261f68e239c5903e3145961eb0fbc538ff506a
143
+ ' < test.cdb
144
+ echo '
145
+ '$?
146
+
147
+ echo '--- cdbmake handles unwritable tmp'
148
+ ln -s loop loop
149
+ echo '' | cdbmake test.cdb loop
150
+ echo $?
151
+
152
+ echo '--- cdbmake handles unmovable cdb'
153
+ echo '' | cdbmake loop/test.cdb test.tmp
154
+ echo $?
155
+
156
+ echo '--- cdbmake handles nomem'
157
+ csh -cf 'repeat 5000 echo "+3,5:one->Hello"' \
158
+ | softlimit -d 50000 cdbmake test.cdb test.tmp
159
+ echo $?
160
+
161
+ echo '--- cdbmake handles full disk'
162
+ (
163
+ trap '' 25
164
+ echo '' | softlimit -f 2047 cdbmake test.cdb test.tmp
165
+ echo $?
166
+ )
167
+
168
+ echo '--- cdbmake handles absurd klen'
169
+ echo '+4294967210' | cdbmake test.cdb test.tmp
170
+ echo $?
171
+
172
+ echo '--- cdbget handles empty file'
173
+ cdbget foo </dev/null
174
+ echo $?
175
+
176
+
177
+ echo '--- cdbdump and cdbmake handle random.cdb'
178
+ cdbdump < ../random.cdb | cdbmake test.cdb test.tmp
179
+ echo $?
180
+ cmp ../random.cdb test.cdb
181
+
182
+ echo '--- cdbtest handles random.cdb'
183
+ cdbtest < ../random.cdb
184
+ echo $?
185
+
186
+ echo '--- cdbstats handles random.cdb'
187
+ cdbstats < ../random.cdb
188
+ echo $?
189
+
190
+
191
+ echo '--- testzero works'
192
+ testzero 5 > test.cdb
193
+ echo $?
194
+ cdbtest < test.cdb
195
+ echo $?
196
+
197
+ echo '--- testzero can build a database very close to 4GB'
198
+ testzero 65507 > /dev/null
199
+ echo $?
200
+
201
+ echo '--- testzero complains if hash table passes 4GB'
202
+ testzero 65508 > /dev/null
203
+ echo $?
204
+
205
+ echo '--- testzero complains if records pass 4GB'
206
+ testzero 66000 > /dev/null
207
+ echo $?
208
+
209
+
210
+ exit 0