X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=index%2Fkcompare.c;h=936929f8f3c9c4ccdbff75fc332790984b2a3ba4;hb=47ea1fc957c7b97bb30a26698f072109cae275e4;hp=647349a2ddf1bfd287e9ae121d23a409b52447e9;hpb=e150e51a7e20a902e9fd2f11f00811f94f67d529;p=idzebra-moved-to-github.git diff --git a/index/kcompare.c b/index/kcompare.c index 647349a..936929f 100644 --- a/index/kcompare.c +++ b/index/kcompare.c @@ -42,6 +42,13 @@ int key_compare_it (const void *p1, const void *p2) return 0; } +char *key_print_it (const void *p, char *buf) +{ + const struct it_key *i = p; + sprintf (buf, "%d:%d", i->sysno, i->seqno); + return buf; +} + int key_compare (const void *p1, const void *p2) { struct it_key i1, i2; @@ -216,8 +223,6 @@ ISAMS_M key_isams_m (Res res, ISAMS_M me) return me; } -#if ZMBOL - ISAMC_M key_isamc_m (Res res, ISAMC_M me) { isc_getmethod (me); @@ -251,26 +256,60 @@ ISAMD_M key_isamd_m (Res res,ISAMD_M me) return me; } -#endif - -int key_SU_code (int ch, char *out) +int key_SU_encode (int ch, char *out) { int i; for (i = 0; ch; i++) { - if (ch > 63) - out[i] = 128 + (ch & 63); + if (ch >= 64) + out[i] = 65 + (ch & 63); else out[i] = 1 + ch; ch = ch >> 6; } return i; + /* in out + 0 1 + 1 2 + 63 64 + 64 65, 2 + 65 66, 2 + 127 128, 2 + 128 65, 3 + 191 128, 3 + 192 65, 4 + */ } +int key_SU_decode (int *ch, const unsigned char *out) +{ + int len = 1; + int fact = 1; + *ch = 0; + for (len = 1; *out >= 65; len++, out++) + { + *ch += (*out - 65) * fact; + fact <<= 6; + } + *ch += (*out - 1) * fact; + return len; +} /* * $Log: kcompare.c,v $ - * Revision 1.35 1999-11-30 13:48:03 adam + * Revision 1.39 2002-04-12 14:55:22 adam + * key_print_it + * + * Revision 1.38 2002/04/05 08:46:26 adam + * Zebra with full functionality + * + * Revision 1.37 2001/11/19 23:08:30 adam + * Added const qualifier for name parameter of key_SU_decode. + * + * Revision 1.36 2001/10/15 19:53:43 adam + * POSIX thread updates. First work on term sets. + * + * Revision 1.35 1999/11/30 13:48:03 adam * Improved installation. Updated for inclusion of YAZ header files. * * Revision 1.34 1999/07/14 13:21:34 heikki