--- TokyoDystopia.xs 2008/08/17 22:35:45 5 +++ TokyoDystopia.xs 2008/08/18 18:28:05 18 @@ -14,7 +14,7 @@ tcidberrmsg(ecode) int ecode CODE: - RETVAL = tchdberrmsg(ecode); + RETVAL = tcidberrmsg(ecode); OUTPUT: RETVAL @@ -22,39 +22,148 @@ void * tcidbnew() PREINIT: - TCIDB *db; + TCIDB *idb; CODE: - db = tcidbnew(); - RETVAL = db; + idb = tcidbnew(); + RETVAL = idb; OUTPUT: RETVAL void -tcidbdel(db) - void * db +tcidbdel(idb) + void * idb CODE: - tcidbdel(db); + tcidbdel(idb); int -tcidbecode(db) - void * db +tcidbecode(idb) + void * idb CODE: - RETVAL = tcidbecode(db); + RETVAL = tcidbecode(idb); OUTPUT: RETVAL int -tcidbtune(db, ernum, etnum, iusiz, opts) - void * db +tcidbtune(idb, ernum, etnum, iusiz, opts) + void * idb int ernum int etnum int iusiz int opts CODE: - RETVAL = tcidbtune(db, ernum, etnum, iusiz, opts); + RETVAL = tcidbtune(idb, ernum, etnum, iusiz, opts); OUTPUT: RETVAL + +int +tcidbsetcache(idb, icsiz, lcnum) + void * idb + int icsiz + int lcnum +CODE: + RETVAL = tcidbsetcache(idb, icsiz, lcnum); +OUTPUT: + RETVAL + + +int +tcidbsetfwmmax(idb, fwmax) + void * idb + int fwmax +CODE: + RETVAL = tcidbsetfwmmax(idb, fwmax); +OUTPUT: + RETVAL + + +int +tcidbopen(idb, path, omode) + void * idb + char * path + int omode +CODE: + RETVAL = tcidbopen(idb, path, omode); +OUTPUT: + RETVAL + + +int +tcidbclose(idb) + void * idb +CODE: + RETVAL = tcidbclose(idb); +OUTPUT: + RETVAL + + +int +tcidbput(idb, id, val) + void * idb + int id + SV * val +PREINIT: + STRLEN vsiz; + const char *vbuf; +CODE: + vbuf = SvPV(val, vsiz); + RETVAL = tcidbput(idb, id, vbuf); +OUTPUT: + RETVAL + + +int +tcidbout(idb, id) + void * idb + int id +CODE: + RETVAL = tcidbout(idb, id); +OUTPUT: + RETVAL + + +void +tcidbget(idb, id) + void * idb + int id +PREINIT: + char *vbuf; +PPCODE: + vbuf = tcidbget(idb, id); + if(vbuf){ + XPUSHs(sv_2mortal(newSVpvn(vbuf, strlen(vbuf)))); + tcfree(vbuf); + } else { + XPUSHs((SV *)&PL_sv_undef); + } + XSRETURN(1); + + +void +tcidbsearch(idb, word, smode) + void * idb + SV * word + int smode +PREINIT: + AV *av; + STRLEN wsize; + uint64_t *results; + const char *wbuf; + int i, rnum; +PPCODE: + wbuf = SvPV(word, wsize); + results = tcidbsearch(idb, wbuf, smode, &rnum); + if ( rnum > 0 ) { + av = newAV(); + for(i = 0; i < rnum; i++){ + av_push(av, newSViv( (int)results[i] )); + } + XPUSHs(sv_2mortal(newRV_noinc((SV *)av))); + } else { + XPUSHs((SV *)&PL_sv_undef); + } + XSRETURN(1); +