/[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

Annotation of /TokyoDystopia.xs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 22 - (hide annotations)
Mon Aug 18 18:53:39 2008 UTC (10 years, 10 months ago) by dpavlin
File size: 2884 byte(s)
tcidbsearch2
1 dpavlin 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     const char *
14 dpavlin 10 tcidberrmsg(ecode)
15 dpavlin 1 int ecode
16     CODE:
17 dpavlin 8 RETVAL = tcidberrmsg(ecode);
18 dpavlin 1 OUTPUT:
19     RETVAL
20 dpavlin 2
21    
22     void *
23 dpavlin 10 tcidbnew()
24 dpavlin 2 PREINIT:
25 dpavlin 10 TCIDB *idb;
26 dpavlin 2 CODE:
27 dpavlin 10 idb = tcidbnew();
28     RETVAL = idb;
29 dpavlin 2 OUTPUT:
30     RETVAL
31 dpavlin 3
32    
33     void
34 dpavlin 10 tcidbdel(idb)
35     void * idb
36 dpavlin 3 CODE:
37 dpavlin 10 tcidbdel(idb);
38 dpavlin 3
39    
40 dpavlin 4 int
41 dpavlin 10 tcidbecode(idb)
42     void * idb
43 dpavlin 4 CODE:
44 dpavlin 10 RETVAL = tcidbecode(idb);
45 dpavlin 4 OUTPUT:
46     RETVAL
47    
48 dpavlin 5
49     int
50 dpavlin 10 tcidbtune(idb, ernum, etnum, iusiz, opts)
51     void * idb
52 dpavlin 5 int ernum
53     int etnum
54     int iusiz
55     int opts
56     CODE:
57 dpavlin 10 RETVAL = tcidbtune(idb, ernum, etnum, iusiz, opts);
58 dpavlin 5 OUTPUT:
59     RETVAL
60    
61 dpavlin 7
62     int
63 dpavlin 10 tcidbsetcache(idb, icsiz, lcnum)
64     void * idb
65 dpavlin 7 int icsiz
66     int lcnum
67     CODE:
68 dpavlin 10 RETVAL = tcidbsetcache(idb, icsiz, lcnum);
69 dpavlin 7 OUTPUT:
70     RETVAL
71 dpavlin 9
72    
73     int
74 dpavlin 10 tcidbsetfwmmax(idb, fwmax)
75     void * idb
76 dpavlin 9 int fwmax
77     CODE:
78 dpavlin 10 RETVAL = tcidbsetfwmmax(idb, fwmax);
79 dpavlin 9 OUTPUT:
80     RETVAL
81    
82    
83 dpavlin 10 int
84     tcidbopen(idb, path, omode)
85     void * idb
86     char * path
87     int omode
88     CODE:
89     RETVAL = tcidbopen(idb, path, omode);
90     OUTPUT:
91     RETVAL
92    
93    
94 dpavlin 11 int
95     tcidbclose(idb)
96     void * idb
97     CODE:
98     RETVAL = tcidbclose(idb);
99     OUTPUT:
100     RETVAL
101    
102 dpavlin 14
103     int
104     tcidbput(idb, id, val)
105     void * idb
106     int id
107     SV * val
108     PREINIT:
109     STRLEN vsiz;
110     const char *vbuf;
111     CODE:
112     vbuf = SvPV(val, vsiz);
113     RETVAL = tcidbput(idb, id, vbuf);
114     OUTPUT:
115     RETVAL
116    
117 dpavlin 15
118     int
119     tcidbout(idb, id)
120     void * idb
121     int id
122     CODE:
123     RETVAL = tcidbout(idb, id);
124     OUTPUT:
125     RETVAL
126    
127 dpavlin 17
128     void
129     tcidbget(idb, id)
130     void * idb
131     int id
132     PREINIT:
133     char *vbuf;
134     PPCODE:
135     vbuf = tcidbget(idb, id);
136     if(vbuf){
137     XPUSHs(sv_2mortal(newSVpvn(vbuf, strlen(vbuf))));
138     tcfree(vbuf);
139     } else {
140     XPUSHs((SV *)&PL_sv_undef);
141     }
142     XSRETURN(1);
143    
144 dpavlin 18
145     void
146     tcidbsearch(idb, word, smode)
147     void * idb
148     SV * word
149     int smode
150     PREINIT:
151     AV *av;
152     STRLEN wsize;
153     uint64_t *results;
154     const char *wbuf;
155     int i, rnum;
156     PPCODE:
157     wbuf = SvPV(word, wsize);
158     results = tcidbsearch(idb, wbuf, smode, &rnum);
159     if ( rnum > 0 ) {
160     av = newAV();
161     for(i = 0; i < rnum; i++){
162     av_push(av, newSViv( (int)results[i] ));
163     }
164     XPUSHs(sv_2mortal(newRV_noinc((SV *)av)));
165     } else {
166     XPUSHs((SV *)&PL_sv_undef);
167     }
168     XSRETURN(1);
169    
170 dpavlin 19
171 dpavlin 22 void
172     tcidbsearch2(idb, expr)
173     void * idb
174     SV * expr
175     PREINIT:
176     AV *av;
177     STRLEN wsize;
178     uint64_t *results;
179     const char *wbuf;
180     int i, rnum;
181     PPCODE:
182     wbuf = SvPV(expr, wsize);
183     results = tcidbsearch2(idb, wbuf, &rnum);
184     if ( rnum > 0 ) {
185     av = newAV();
186     for(i = 0; i < rnum; i++){
187     av_push(av, newSViv( (int)results[i] ));
188     }
189     XPUSHs(sv_2mortal(newRV_noinc((SV *)av)));
190     } else {
191     XPUSHs((SV *)&PL_sv_undef);
192     }
193     XSRETURN(1);
194    
195    
196 dpavlin 19 int
197     tcidbiterinit(idb)
198     void * idb
199     CODE:
200     RETVAL = tcidbiterinit(idb);
201     OUTPUT:
202     RETVAL
203    
204 dpavlin 20
205     int
206     tcidbiternext(idb)
207     void * idb
208     CODE:
209     RETVAL = tcidbiternext(idb);
210     OUTPUT:
211     RETVAL
212    
213 dpavlin 21
214     int
215     tcidbsync(idb)
216     void * idb
217     CODE:
218     RETVAL = tcidbsync(idb);
219     OUTPUT:
220     RETVAL
221    

  ViewVC Help
Powered by ViewVC 1.1.26