/[Search-TokyoDystopia]/TokyoDystopia.xs
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 /TokyoDystopia.xs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 39 - (show annotations)
Sat Feb 14 17:34:01 2009 UTC (10 years, 9 months ago) by dpavlin
File size: 9531 byte(s)
tcjdbsearch2 , tcjdbsearch doesn't work
1 #include "EXTERN.h"
2 #include "perl.h"
3 #include "XSUB.h"
4 #include <dystopia.h>
5 #include <stdlib.h>
6 #include <stdbool.h>
7 #include <stdint.h>
8
9
10 MODULE = Search::TokyoDystopia PACKAGE = Search::TokyoDystopia
11 PROTOTYPES: DISABLE
12
13
14 const char *
15 tdversion()
16 CODE:
17 RETVAL = tdversion;
18 OUTPUT:
19 RETVAL
20
21
22 const char *
23 tcidberrmsg(ecode)
24 int ecode
25 CODE:
26 RETVAL = tcidberrmsg(ecode);
27 OUTPUT:
28 RETVAL
29
30
31 void *
32 tcidbnew()
33 PREINIT:
34 TCIDB *idb;
35 CODE:
36 idb = tcidbnew();
37 RETVAL = idb;
38 OUTPUT:
39 RETVAL
40
41
42 void
43 tcidbdel(idb)
44 void * idb
45 CODE:
46 tcidbdel(idb);
47
48
49 int
50 tcidbecode(idb)
51 void * idb
52 CODE:
53 RETVAL = tcidbecode(idb);
54 OUTPUT:
55 RETVAL
56
57
58 int
59 tcidbtune(idb, ernum, etnum, iusiz, opts)
60 void * idb
61 int ernum
62 int etnum
63 int iusiz
64 int opts
65 CODE:
66 RETVAL = tcidbtune(idb, ernum, etnum, iusiz, opts);
67 OUTPUT:
68 RETVAL
69
70
71 int
72 tcidbsetcache(idb, icsiz, lcnum)
73 void * idb
74 int icsiz
75 int lcnum
76 CODE:
77 RETVAL = tcidbsetcache(idb, icsiz, lcnum);
78 OUTPUT:
79 RETVAL
80
81
82 int
83 tcidbsetfwmmax(idb, fwmax)
84 void * idb
85 int fwmax
86 CODE:
87 RETVAL = tcidbsetfwmmax(idb, fwmax);
88 OUTPUT:
89 RETVAL
90
91
92 int
93 tcidbopen(idb, path, omode)
94 void * idb
95 char * path
96 int omode
97 CODE:
98 RETVAL = tcidbopen(idb, path, omode);
99 OUTPUT:
100 RETVAL
101
102
103 int
104 tcidbclose(idb)
105 void * idb
106 CODE:
107 RETVAL = tcidbclose(idb);
108 OUTPUT:
109 RETVAL
110
111
112 int
113 tcidbput(idb, id, val)
114 void * idb
115 int id
116 SV * val
117 PREINIT:
118 STRLEN vsiz;
119 const char *vbuf;
120 CODE:
121 vbuf = SvPV(val, vsiz);
122 RETVAL = tcidbput(idb, id, vbuf);
123 OUTPUT:
124 RETVAL
125
126
127 int
128 tcidbout(idb, id)
129 void * idb
130 int id
131 CODE:
132 RETVAL = tcidbout(idb, id);
133 OUTPUT:
134 RETVAL
135
136
137 void
138 tcidbget(idb, id)
139 void * idb
140 int id
141 PREINIT:
142 char *vbuf;
143 PPCODE:
144 vbuf = tcidbget(idb, id);
145 if(vbuf){
146 XPUSHs(sv_2mortal(newSVpvn(vbuf, strlen(vbuf))));
147 tcfree(vbuf);
148 } else {
149 XPUSHs((SV *)&PL_sv_undef);
150 }
151 XSRETURN(1);
152
153
154 void
155 tcidbsearch(idb, word, smode)
156 void * idb
157 SV * word
158 int smode
159 PREINIT:
160 AV *av;
161 STRLEN wsize;
162 uint64_t *results;
163 const char *wbuf;
164 int i, rnum;
165 PPCODE:
166 wbuf = SvPV(word, wsize);
167 results = tcidbsearch(idb, wbuf, smode, &rnum);
168 if ( rnum > 0 ) {
169 av = newAV();
170 for(i = 0; i < rnum; i++){
171 av_push(av, newSViv( (int)results[i] ));
172 }
173 XPUSHs(sv_2mortal(newRV_noinc((SV *)av)));
174 } else {
175 XPUSHs((SV *)&PL_sv_undef);
176 }
177 XSRETURN(1);
178
179
180 void
181 tcidbsearch2(idb, expr)
182 void * idb
183 SV * expr
184 PREINIT:
185 AV *av;
186 STRLEN wsize;
187 uint64_t *results;
188 const char *wbuf;
189 int i, rnum;
190 PPCODE:
191 wbuf = SvPV(expr, wsize);
192 results = tcidbsearch2(idb, wbuf, &rnum);
193 if ( rnum > 0 ) {
194 av = newAV();
195 for(i = 0; i < rnum; i++){
196 av_push(av, newSViv( (int)results[i] )); // FIXME convert to double?
197 }
198 XPUSHs(sv_2mortal(newRV_noinc((SV *)av)));
199 } else {
200 XPUSHs((SV *)&PL_sv_undef);
201 }
202 XSRETURN(1);
203
204
205 int
206 tcidbiterinit(idb)
207 void * idb
208 CODE:
209 RETVAL = tcidbiterinit(idb);
210 OUTPUT:
211 RETVAL
212
213
214 double
215 tcidbiternext(idb)
216 void * idb
217 CODE:
218 RETVAL = tcidbiternext(idb);
219 OUTPUT:
220 RETVAL
221
222
223 int
224 tcidbsync(idb)
225 void * idb
226 CODE:
227 RETVAL = tcidbsync(idb);
228 OUTPUT:
229 RETVAL
230
231
232 int
233 tcidboptimize(idb)
234 void * idb
235 CODE:
236 RETVAL = tcidboptimize(idb);
237 OUTPUT:
238 RETVAL
239
240
241 int
242 tcidbvanish(idb)
243 void * idb
244 CODE:
245 RETVAL = tcidbvanish(idb);
246 OUTPUT:
247 RETVAL
248
249
250 int
251 tcidbcopy(idb, path)
252 void * idb
253 char * path
254 CODE:
255 RETVAL = tcidbcopy(idb, path);
256 OUTPUT:
257 RETVAL
258
259
260 void
261 tcidbpath(idb)
262 void * idb
263 PREINIT:
264 const char *path;
265 PPCODE:
266 path = tcidbpath(idb);
267 if(path){
268 XPUSHs(sv_2mortal(newSVpv(path, 0)));
269 } else {
270 XPUSHs((SV *)&PL_sv_undef);
271 }
272 XSRETURN(1);
273
274
275 double
276 tcidbrnum(idb)
277 void * idb
278 CODE:
279 RETVAL = tcidbrnum(idb);
280 OUTPUT:
281 RETVAL
282
283
284 double
285 tcidbfsiz(idb)
286 void * idb
287 CODE:
288 RETVAL = tcidbfsiz(idb);
289 OUTPUT:
290 RETVAL
291
292
293 #include <tcqdb.h>
294
295 const char *
296 tcqdberrmsg(ecode)
297 int ecode
298 CODE:
299 RETVAL = tcqdberrmsg(ecode);
300 OUTPUT:
301 RETVAL
302
303
304 void *
305 tcqdbnew()
306 PREINIT:
307 TCQDB *qdb;
308 CODE:
309 qdb = tcqdbnew();
310 RETVAL = qdb;
311 OUTPUT:
312 RETVAL
313
314
315 void
316 tcqdbdel(qdb)
317 void * qdb
318 CODE:
319 tcqdbdel(qdb);
320
321
322 int
323 tcqdbecode(qdb)
324 void * qdb
325 CODE:
326 RETVAL = tcqdbecode(qdb);
327 OUTPUT:
328 RETVAL
329
330
331 int
332 tcqdbtune(qdb, etnum, opts)
333 void * qdb
334 int etnum
335 int opts
336 CODE:
337 RETVAL = tcqdbtune(qdb, etnum, opts);
338 OUTPUT:
339 RETVAL
340
341
342 int
343 tcqdbsetcache(qdb, icsiz, lcnum)
344 void * qdb
345 int icsiz
346 int lcnum
347 CODE:
348 RETVAL = tcqdbsetcache(qdb, icsiz, lcnum);
349 OUTPUT:
350 RETVAL
351
352
353 int
354 tcqdbsetfwmmax(qdb, fwmax)
355 void * qdb
356 int fwmax
357 CODE:
358 RETVAL = tcqdbsetfwmmax(qdb, fwmax);
359 OUTPUT:
360 RETVAL
361
362
363 int
364 tcqdbopen(qdb, path, omode)
365 void * qdb
366 char * path
367 int omode
368 CODE:
369 RETVAL = tcqdbopen(qdb, path, omode);
370 OUTPUT:
371 RETVAL
372
373
374 int
375 tcqdbclose(qdb)
376 void * qdb
377 CODE:
378 RETVAL = tcqdbclose(qdb);
379 OUTPUT:
380 RETVAL
381
382
383 int
384 tcqdbput(qdb, id, val)
385 void * qdb
386 int id
387 SV * val
388 PREINIT:
389 STRLEN vsiz;
390 const char *vbuf;
391 CODE:
392 vbuf = SvPV(val, vsiz);
393 RETVAL = tcqdbput(qdb, id, vbuf);
394 OUTPUT:
395 RETVAL
396
397
398 int
399 tcqdbout(qdb, id, text)
400 void * qdb
401 int id
402 SV * text
403 PREINIT:
404 STRLEN tsize;
405 const char *tbuf;
406 CODE:
407 tbuf = SvPV(text, tsize);
408 RETVAL = tcqdbout(qdb, id, tbuf);
409 OUTPUT:
410 RETVAL
411
412
413 void
414 tcqdbsearch(qdb, word, smode)
415 void * qdb
416 SV * word
417 int smode
418 PREINIT:
419 AV *av;
420 STRLEN wsize;
421 uint64_t *results;
422 const char *wbuf;
423 int i, rnum;
424 PPCODE:
425 wbuf = SvPV(word, wsize);
426 results = tcqdbsearch(qdb, wbuf, smode, &rnum);
427 if ( rnum > 0 ) {
428 av = newAV();
429 for(i = 0; i < rnum; i++){
430 av_push(av, newSViv( (int)results[i] ));
431 }
432 XPUSHs(sv_2mortal(newRV_noinc((SV *)av)));
433 } else {
434 XPUSHs((SV *)&PL_sv_undef);
435 }
436 XSRETURN(1);
437
438
439 int
440 tcqdbsync(qdb)
441 void * qdb
442 CODE:
443 RETVAL = tcqdbsync(qdb);
444 OUTPUT:
445 RETVAL
446
447
448 int
449 tcqdboptimize(qdb)
450 void * qdb
451 CODE:
452 RETVAL = tcqdboptimize(qdb);
453 OUTPUT:
454 RETVAL
455
456
457 int
458 tcqdbvanish(qdb)
459 void * qdb
460 CODE:
461 RETVAL = tcqdbvanish(qdb);
462 OUTPUT:
463 RETVAL
464
465
466 int
467 tcqdbcopy(qdb, path)
468 void * qdb
469 char * path
470 CODE:
471 RETVAL = tcqdbcopy(qdb, path);
472 OUTPUT:
473 RETVAL
474
475
476 void
477 tcqdbpath(qdb)
478 void * qdb
479 PREINIT:
480 const char *path;
481 PPCODE:
482 path = tcqdbpath(qdb);
483 if(path){
484 XPUSHs(sv_2mortal(newSVpv(path, 0)));
485 } else {
486 XPUSHs((SV *)&PL_sv_undef);
487 }
488 XSRETURN(1);
489
490
491 double
492 tcqdbtnum(qdb)
493 void * qdb
494 CODE:
495 RETVAL = tcqdbtnum(qdb);
496 OUTPUT:
497 RETVAL
498
499
500 double
501 tcqdbfsiz(qdb)
502 void * qdb
503 CODE:
504 RETVAL = tcqdbfsiz(qdb);
505 OUTPUT:
506 RETVAL
507
508
509 #include <laputa.h>
510
511 const char *
512 tcjdberrmsg(ecode)
513 int ecode
514 CODE:
515 RETVAL = tcjdberrmsg(ecode);
516 OUTPUT:
517 RETVAL
518
519
520 void *
521 tcjdbnew()
522 PREINIT:
523 TCJDB *jdb;
524 CODE:
525 jdb = tcjdbnew();
526 RETVAL = jdb;
527 OUTPUT:
528 RETVAL
529
530
531 void
532 tcjdbdel(jdb)
533 void * jdb
534 CODE:
535 tcjdbdel(jdb);
536
537
538 int
539 tcjdbecode(jdb)
540 void * jdb
541 CODE:
542 RETVAL = tcjdbecode(jdb);
543 OUTPUT:
544 RETVAL
545
546
547 int
548 tcjdbtune(jdb, ernum, etnum, iusiz, opts)
549 void * jdb
550 int ernum
551 int etnum
552 int iusiz
553 int opts
554 CODE:
555 RETVAL = tcjdbtune(jdb, ernum, etnum, iusiz, opts);
556 OUTPUT:
557 RETVAL
558
559
560 int
561 tcjdbsetcache(jdb, icsiz, lcnum)
562 void * jdb
563 int icsiz
564 int lcnum
565 CODE:
566 RETVAL = tcjdbsetcache(jdb, icsiz, lcnum);
567 OUTPUT:
568 RETVAL
569
570
571 int
572 tcjdbsetfwmmax(jdb, fwmax)
573 void * jdb
574 int fwmax
575 CODE:
576 RETVAL = tcjdbsetfwmmax(jdb, fwmax);
577 OUTPUT:
578 RETVAL
579
580
581 int
582 tcjdbopen(jdb, path, omode)
583 void * jdb
584 char * path
585 int omode
586 CODE:
587 RETVAL = tcjdbopen(jdb, path, omode);
588 OUTPUT:
589 RETVAL
590
591
592 int
593 tcjdbclose(jdb)
594 void * jdb
595 CODE:
596 RETVAL = tcjdbclose(jdb);
597 OUTPUT:
598 RETVAL
599
600
601 int
602 tcjdbput(jdb, id, vals)
603 void * jdb
604 int id
605 AV * vals
606 PREINIT:
607 TCLIST *tvals;
608 SV *val;
609 STRLEN vsiz;
610 const char *vbuf;
611 int i, num;
612 CODE:
613 tvals = tclistnew();
614 num = av_len(vals) + 1;
615 for(i = 0; i < num; i++) {
616 val = *av_fetch(vals, i, 0);
617 vbuf = SvPV(val, vsiz);
618 tclistpush(tvals, vbuf, (int)vsiz);
619 }
620 RETVAL = tcjdbput(jdb, id, tvals);
621 tclistdel(tvals);
622 OUTPUT:
623 RETVAL
624
625
626 int
627 tcjdbput2(jdb, id, text, delims)
628 void * jdb
629 int id
630 SV * text
631 SV * delims
632 PREINIT:
633 STRLEN tsiz, dsiz;
634 const char *tbuf, *dbuf;
635 CODE:
636 tbuf = SvPV(text, tsiz);
637 dbuf = SvPV(delims, dsiz);
638 RETVAL = tcjdbput2(jdb, id, tbuf, dbuf);
639 OUTPUT:
640 RETVAL
641
642 int
643 tcjdbout(jdb, id)
644 void * jdb
645 int id
646 CODE:
647 RETVAL = tcjdbout(jdb, id);
648 OUTPUT:
649 RETVAL
650
651
652 void
653 tcjdbsearch(jdb, word, smode)
654 void * jdb
655 SV * word
656 int smode
657 PREINIT:
658 AV *av;
659 STRLEN wsize;
660 uint64_t *results;
661 const char *wbuf;
662 int i, rnum;
663 PPCODE:
664 wbuf = SvPV(word, wsize);
665 results = tcjdbsearch(jdb, wbuf, smode, &rnum);
666 if ( rnum > 0 ) {
667 av = newAV();
668 for(i = 0; i < rnum; i++){
669 av_push(av, newSViv( (int)results[i] ));
670 }
671 XPUSHs(sv_2mortal(newRV_noinc((SV *)av)));
672 } else {
673 XPUSHs((SV *)&PL_sv_undef);
674 }
675 XSRETURN(1);
676
677
678 void
679 tcjdbsearch2(jdb, word)
680 void * jdb
681 SV * word
682 PREINIT:
683 AV *av;
684 STRLEN wsize;
685 uint64_t *results;
686 const char *wbuf;
687 int i, rnum;
688 PPCODE:
689 wbuf = SvPV(word, wsize);
690 results = tcjdbsearch2(jdb, wbuf, &rnum);
691 if ( rnum > 0 ) {
692 av = newAV();
693 for(i = 0; i < rnum; i++){
694 av_push(av, newSViv( (int)results[i] ));
695 }
696 XPUSHs(sv_2mortal(newRV_noinc((SV *)av)));
697 } else {
698 XPUSHs((SV *)&PL_sv_undef);
699 }
700 XSRETURN(1);
701
702
703 int
704 tcjdbsync(jdb)
705 void * jdb
706 CODE:
707 RETVAL = tcjdbsync(jdb);
708 OUTPUT:
709 RETVAL
710
711
712 int
713 tcjdboptimize(jdb)
714 void * jdb
715 CODE:
716 RETVAL = tcjdboptimize(jdb);
717 OUTPUT:
718 RETVAL
719
720
721 int
722 tcjdbvanish(jdb)
723 void * jdb
724 CODE:
725 RETVAL = tcjdbvanish(jdb);
726 OUTPUT:
727 RETVAL
728
729
730 int
731 tcjdbcopy(jdb, path)
732 void * jdb
733 char * path
734 CODE:
735 RETVAL = tcjdbcopy(jdb, path);
736 OUTPUT:
737 RETVAL
738
739
740 void
741 tcjdbpath(jdb)
742 void * jdb
743 PREINIT:
744 const char *path;
745 PPCODE:
746 path = tcjdbpath(jdb);
747 if(path){
748 XPUSHs(sv_2mortal(newSVpv(path, 0)));
749 } else {
750 XPUSHs((SV *)&PL_sv_undef);
751 }
752 XSRETURN(1);
753
754
755 double
756 tcjdbrnum(jdb)
757 void * jdb
758 CODE:
759 RETVAL = tcjdbrnum(jdb);
760 OUTPUT:
761 RETVAL
762
763
764 double
765 tcjdbfsiz(jdb)
766 void * jdb
767 CODE:
768 RETVAL = tcjdbfsiz(jdb);
769 OUTPUT:
770 RETVAL
771

  ViewVC Help
Powered by ViewVC 1.1.26