/[Search-TokyoDystopia]/lib/Search/TokyoDystopia.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /lib/Search/TokyoDystopia.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 38 - (show annotations)
Sun Sep 21 21:27:40 2008 UTC (15 years, 6 months ago) by dpavlin
File size: 7663 byte(s)
- skip close/open of empty database because of segfault
- tcjdbrnum
1 package Search::TokyoDystopia;
2
3 use strict;
4 use warnings;
5
6 require Exporter;
7 require XSLoader;
8 use base qw(Exporter);
9 our $VERSION = '0.01';
10 our $debug = 0;
11 XSLoader::load('Search::TokyoDystopia', $VERSION);
12
13 our @EXPORT = qw(
14 tcidberrmsg
15 tcidbnew
16 tcidbdel
17 tcidbnew
18 tcidbecode
19 tcidbtune
20 IDBTLARGE
21 IDBTDEFLATE
22 IDBTTCBS
23 tcidbsetcache
24 tcidbsetfwmmax
25 tcidbopen
26 IDBOREADER
27 IDBOWRITER
28 IDBOCREAT
29 IDBOTRUNC
30 IDBONOLCK
31 IDBOLCKNB
32 tcidbclose
33 tcidbput
34 tcidbout
35 tcidbget
36 tcidbsearch
37 tcidbsearch2
38 IDBSSUBSTR
39 IDBSPREFIX
40 IDBSSUFFIX
41 IDBSFULL
42 IDBSTOKEN
43 IDBSTOKPRE
44 IDBSTOKSUF
45 tcidbiterinit
46 tcidbiternext
47 tcidbsync
48 tcidboptimize
49 tcidbvanish
50 tcidbcopy
51 tcidbpath
52 tcidbrnum
53 tcidbfsiz
54
55 tdversion
56 tcqdberrmsg
57 tcqdbnew
58 tcqdbdel
59 tcqdbnew
60 tcqdbecode
61 tcqdbtune
62 QDBTLARGE
63 QDBTDEFLATE
64 QDBTTCBS
65 tcqdbsetcache
66 tcqdbsetfwmmax
67 tcqdbopen
68 QDBOREADER
69 QDBOWRITER
70 QDBOCREAT
71 QDBOTRUNC
72 QDBONOLCK
73 QDBOLCKNB
74 tcqdbclose
75 tcqdbput
76 tcqdbout
77 tcqdbget
78 tcqdbsearch
79 tcqdbsearch2
80 QDBSSUBSTR
81 QDBSPREFIX
82 QDBSSUFFIX
83 QDBSFULL
84 QDBSTOKEN
85 QDBSTOKPRE
86 QDBSTOKSUF
87 tcqdbiterinit
88 tcqdbiternext
89 tcqdbsync
90 tcqdboptimize
91 tcqdbvanish
92 tcqdbcopy
93 tcqdbpath
94 tcqdbtnum
95 tcqdbfsiz
96
97 tcjdberrmsg
98 tcjdbnew
99 tcjdbdel
100 tcjdbnew
101 tcjdbecode
102 tcjdbtune
103 JDBTLARGE
104 JDBTDEFLATE
105 JDBTTCBS
106 tcjdbsetcache
107 tcjdbsetfwmmax
108 tcjdbopen
109 JDBOREADER
110 JDBOWRITER
111 JDBOCREAT
112 JDBOTRUNC
113 JDBONOLCK
114 JDBOLCKNB
115 tcjdbclose
116 tcjdbput
117 tcjdbput2
118 tcjdbout
119 tcjdbget
120 tcjdbget2
121 tcjdbsearch
122 tcjdbsearch2
123 JDBSSUBSTR
124 JDBSPREFIX
125 JDBSSUFFIX
126 JDBSFULL
127 JDBSTOKEN
128 JDBSTOKPRE
129 JDBSTOKSUF
130 tcjdbiterinit
131 tcjdbiternext
132 tcjdbsync
133 tcjdboptimize
134 tcjdbvanish
135 tcjdbcopy
136 tcjdbpath
137 tcjdbrnum
138 tcjdbfsiz
139 );
140
141 =head1 NAME
142
143 Search::TokyoDystopia - XS bindings for Tokyo Dystopia
144
145 =head1 Core API
146
147 If you don't prevent it, it will export all kind of stuff into your namespace to cut down on typing.
148 void
149 tcqdbget(qdb, id)
150 void * qdb
151 int id
152 PREINIT:
153 char *vbuf;
154 PPCODE:
155 vbuf = tcqdbget(qdb, id);
156 if(vbuf){
157 XPUSHs(sv_2mortal(newSVpvn(vbuf, strlen(vbuf))));
158 tcfree(vbuf);
159 } else {
160 XPUSHs((SV *)&PL_sv_undef);
161 }
162 XSRETURN(1);
163
164
165
166 =head2 tcidberrmsg
167
168 my $message = tcidberrmsg( $ecode );
169
170 =head2 tcidbnew
171
172 my $idb = tcidbnew;
173
174 =head2 tcidbdel
175
176 tcidbdel( $idb );
177
178 =head2 tcidbecode
179
180 my $ecode = tcidbecode( $idb );
181
182 =head2 tcidbtune
183
184 my $success = tcidbtune( $idb, $ernum, $etnum, $iusiz, IDBTLARGE | IDBTDEFLATE );
185
186 =cut
187
188 use constant {
189 IDBTLARGE => 1 << 0,
190 IDBTDEFLATE => 1 << 1,
191 IDBTTCBS => 1 << 2,
192 };
193
194 =head2 tcidbsetcache
195
196 my $success = tcidbsetcache( $idb, $icsiz, $lcnum );
197
198 =head2 tcidbsetfwmmax
199
200 my $success = tcidbsetfwmmax( $idb, $fwmax );
201
202 =head2 tcidbopen
203
204 my $success = tcidbopen( $idb, 'casket', IDBOWRITER | IDBOCREAT );
205
206 =cut
207
208 use constant {
209 IDBOREADER => 1 << 0,
210 IDBOWRITER => 1 << 1,
211 IDBOCREAT => 1 << 2,
212 IDBOTRUNC => 1 << 3,
213 IDBONOLCK => 1 << 4,
214 IDBOLCKNB => 1 << 5,
215 };
216
217 =head2 tcidbclose
218
219 my $success = tcidbclose( $idb );
220
221 =head2 tcidbput
222
223 my $success = tcidbput( $idb, $id, $text );
224
225 =head2 tcidbout
226
227 my $success = tcidbout( $idb, $id );
228
229 =head2 tcidbget
230
231 my $text = tcidbget( $idb, $id );
232
233 =head2 tcidbsearch
234
235 my $ids = tcidbsearch( $idb, $word, IDBSSUBSTR );
236
237 =cut
238
239 use constant {
240 IDBSSUBSTR => 0, # substring matching
241 IDBSPREFIX => 1, # prefix matching
242 IDBSSUFFIX => 2, # suffix matching
243 IDBSFULL => 3, # full matching
244 IDBSTOKEN => 4, # token matching
245 IDBSTOKPRE => 5, # token prefix matching
246 IDBSTOKSUF => 6, # token suffix matching
247 };
248
249 =head2 tcidbsearch2
250
251 my $ids = tcidbsearch2( $idb, $expr );
252
253 =head2 tcidbiterinit
254
255 my $success = tcidbiterinit( $idb );
256
257 =head2 tcidbiternext
258
259 my $id = tcidbiternext( $idb );
260
261 =head2 tcidbsync
262
263 my $success = tcidbsync( $idb );
264
265 =head2 tcidboptimize
266
267 my $success = tcidboptimize( $idb );
268
269 =head2 tcidbvanish
270
271 my $success = tcidbvanish( $idb );
272
273 =head2 tcidbcopy
274
275 my $success = tcidbcopy( $idb, '/path/of/copy' );
276
277 =head2 tcidbpath
278
279 my $path = tcidbpath( $idb );
280
281 =head2 tcidbrnum
282
283 my $number_of_records = tcidbrnum( $idb );
284
285 =head2 tcidbfsiz
286
287 my $file_size = tcidbfsiz( $idb );
288
289 =cut
290
291
292 =head1 Q-gram API
293
294 =head2 tcqdberrmsg
295
296 my $message = tcqdberrmsg( $ecode );
297
298 =head2 tcqdbnew
299
300 my $qdb = tcqdbnew;
301
302 =head2 tcqdbdel
303
304 tcqdbdel( $qdb );
305
306 =head2 tcqdbecode
307
308 my $ecode = tcqdbecode( $qdb );
309
310 =head2 tcqdbtune
311
312 my $success = tcqdbtune( $qdb, $etnum, QDBTLARGE | QDBTDEFLATE );
313
314 =cut
315
316 use constant {
317 QDBTLARGE => 1 << 0,
318 QDBTDEFLATE => 1 << 1,
319 QDBTTCBS => 1 << 2,
320 };
321
322 =head2 tcqdbsetcache
323
324 my $success = tcqdbsetcache( $qdb, $icsiz, $lcnum );
325
326 =head2 tcqdbsetfwmmax
327
328 my $success = tcqdbsetfwmmax( $qdb, $fwmax );
329
330 =head2 tcqdbopen
331
332 my $success = tcqdbopen( $qdb, 'casket', QDBOWRITER | QDBOCREAT );
333
334 =cut
335
336 use constant {
337 QDBOREADER => 1 << 0,
338 QDBOWRITER => 1 << 1,
339 QDBOCREAT => 1 << 2,
340 QDBOTRUNC => 1 << 3,
341 QDBONOLCK => 1 << 4,
342 QDBOLCKNB => 1 << 5,
343 };
344
345 =head2 tcqdbclose
346
347 my $success = tcqdbclose( $qdb );
348
349 =head2 tcqdbput
350
351 my $success = tcqdbput( $qdb, $id, $text );
352
353 =head2 tcqdbout
354
355 my $success = tcqdbout( $qdb, $id );
356
357 =head2 tcqdbsearch
358
359 my $ids = tcqdbsearch( $qdb, $word, QDBSSUBSTR );
360
361 =cut
362
363 use constant {
364 QDBSSUBSTR => 0, # substring matching
365 QDBSPREFIX => 1, # prefix matching
366 QDBSUFFIX => 2, # suffix matching
367 QDBFULL => 3, # full matching
368 QDBTOKEN => 4, # token matching
369 QDBTOKPRE => 5, # token prefix matching
370 QDBTOKSUF => 6, # token suffix matching
371 };
372
373 =head2 tcqdbsync
374
375 my $success = tcqdbsync( $qdb );
376
377 =head2 tcqdboptimize
378
379 my $success = tcqdboptimize( $qdb );
380
381 =head2 tcqdbvanish
382
383 my $success = tcqdbvanish( $qdb );
384
385 =head2 tcqdbcopy
386
387 my $success = tcqdbcopy( $qdb, '/path/of/copy' );
388
389 =head2 tcqdbpath
390
391 my $path = tcqdbpath( $qdb );
392
393 =head2 tcqdbtnum
394
395 my $number_of_records = tcqdbtnum( $qdb );
396
397 =head2 tcqdbfsiz
398
399 my $file_size = tcqdbtsiz( $qdb );
400
401
402 =head1 Simple API
403
404 =head2 tcjdberrmsg
405
406 my $message = tcjdberrmsg( $ecode );
407
408 =head2 tcjdbnew
409
410 my $jdb = tcjdbnew;
411
412 =head2 tcjdbdel
413
414 tcjdbdel( $jdb );
415
416 =head2 tcjdbecode
417
418 my $ecode = tcjdbecode( $jdb );
419
420 =head2 tcjdbtune
421
422 my $success = tcjdbtune( $jdb, $ernum, $etnum, $iusiz, JDBTLARGE | JDBTDEFLATE );
423
424 =cut
425
426 use constant {
427 JDBTLARGE => 1 << 0,
428 JDBTDEFLATE => 1 << 1,
429 JDBTTCBS => 1 << 2,
430 };
431
432 =head2 tcjdbsetcache
433
434 my $success = tcjdbsetcache( $jdb, $icsiz, $lcnum );
435
436 =head2 tcjdbsetfwmmax
437
438 my $success = tcjdbsetfwmmax( $jdb, $fwmax );
439
440 =head2 tcjdbopen
441
442 my $success = tcjdbopen( $jdb, 'casket', JDBOWRITER | JDBOCREAT );
443
444 =cut
445
446 use constant {
447 JDBOREADER => 1 << 0,
448 JDBOWRITER => 1 << 1,
449 JDBOCREAT => 1 << 2,
450 JDBOTRUNC => 1 << 3,
451 JDBONOLCK => 1 << 4,
452 JDBOLCKNB => 1 << 5,
453 };
454
455 =head2 tcjdbclose
456
457 my $success = tcjdbclose( $jdb );
458
459 =head2 tcjdbput
460
461 my $success = tcjdbput( $jdb, $id, $text );
462
463 =head2 tcjdbput2
464
465 my $success = tcjdbput2( $jdb, $id, $text );
466
467 =head2 tcjdbout
468
469 my $success = tcjdbout( $jdb, $id );
470
471 =head2 tcjdbsearch
472
473 my $ids = tcjdbsearch( $jdb, $word, JDBSSUBSTR );
474
475 =cut
476
477 use constant {
478 JDBSSUBSTR => 0, # substring matching
479 JDBSPREFIX => 1, # prefix matching
480 JDBSUFFIX => 2, # suffix matching
481 JDBFULL => 3, # full matching
482 JDBTOKEN => 4, # token matching
483 JDBTOKPRE => 5, # token prefix matching
484 JDBTOKSUF => 6, # token suffix matching
485 };
486
487 =head2 tcjdbsync
488
489 my $success = tcjdbsync( $jdb );
490
491 =head2 tcjdboptimize
492
493 my $success = tcjdboptimize( $jdb );
494
495 =head2 tcjdbvanish
496
497 my $success = tcjdbvanish( $jdb );
498
499 =head2 tcjdbcopy
500
501 my $success = tcjdbcopy( $jdb, '/path/of/copy' );
502
503 =head2 tcjdbpath
504
505 my $path = tcjdbpath( $jdb );
506
507 =head2 tcjdbrnum
508
509 my $number_of_records = tcjdbrnum( $jdb );
510
511 =head2 tcjdbfsiz
512
513 my $file_size = tcjdbtsiz( $jdb );
514
515 =cut
516
517 =head1 KNOWN BUGS
518
519 Low-level functions often just die when called on invalid (or deleted) database
520
521 =cut
522
523 1;

  ViewVC Help
Powered by ViewVC 1.1.26