23 #define VB_MAX_OFF_T (off_t)9223372036854775807LL
25 #define VB_MAX_OFF_T (off_t)2147483647
31 itreeload (
const int ihandle,
const int ikeynumber,
const int ilength,
37 struct keydesc *pskptr;
38 unsigned int idelta, iindex;
42 pstree = psvbptr->
pstree[ikeynumber];
46 psvbptr->
pstree[ikeynumber] = pstree;
55 pskptr->k_rootnode, -1);
64 pskptr->k_rootnode, -1);
108 if (tdupnumber < pstree->pskeycurr->tdupnumber) {
133 iresult =
ivbkeycompare (ihandle, ikeynumber, ilength, pckeyvalue,
135 if (iresult == 0 && tdupnumber < pstree->pskeycurr->tdupnumber) {
203 return (iresult + 1);
212 vvbmakekey (
const struct keydesc *pskeydesc,
char *pcrow_buffer,
213 unsigned char *pckeyvalue)
215 const struct keypart *pskptr;
221 for (ipart = 0; ipart < pskeydesc->k_nparts; ipart++) {
222 pskptr = &pskeydesc->k_part[ipart];
223 pcsource = pcrow_buffer + pskptr->kp_start;
224 memcpy (pckeyvalue, pcsource, (
size_t)pskptr->kp_leng);
225 pckeyvalue += pskptr->kp_leng;
231 unsigned char *pckey1,
unsigned char *pckey2)
233 struct keydesc *pskeydesc;
234 struct keypart *pskptr;
235 off_t tvalue1, tvalue2;
236 int idescbias, ipart, ilengthtocompare;
237 int ivalue1, ivalue2;
239 int lvalue1, lvalue2;
240 float fvalue1, fvalue2;
241 double dvalue1, dvalue2;
245 ilength = pskeydesc->k_len;
247 for (ipart = 0; ilength > 0 && ipart < pskeydesc->k_nparts; ipart++) {
248 pskptr = &pskeydesc->k_part[ipart];
249 if (ilength >= pskptr->kp_leng) {
250 ilengthtocompare = pskptr->kp_leng;
252 ilengthtocompare = ilength;
254 ilength -= ilengthtocompare;
255 if (pskptr->kp_type & ISDESC) {
260 switch (pskptr->kp_type & ~ISDESC) {
263 n = memcmp (pckey1, pckey2, (
size_t)ilengthtocompare);
270 pckey1 += ilengthtocompare;
271 pckey2 += ilengthtocompare;
285 while (ilengthtocompare >= INTSIZE) {
288 if (ivalue1 < ivalue2) {
291 if (ivalue1 > ivalue2) {
296 ilengthtocompare -= INTSIZE;
301 while (ilengthtocompare >= LONGSIZE) {
304 if (lvalue1 < lvalue2) {
307 if (lvalue1 > lvalue2) {
312 ilengthtocompare -= LONGSIZE;
317 while (ilengthtocompare >=
QUADSIZE) {
320 if (tvalue1 < tvalue2) {
323 if (tvalue1 > tvalue2) {
333 while (ilengthtocompare >= FLOATSIZE) {
336 if (fvalue1 < fvalue2) {
339 if (fvalue1 > fvalue2) {
344 ilengthtocompare -= FLOATSIZE;
349 while (ilengthtocompare >= DOUBLESIZE) {
350 dvalue1 =
lddbl (pckey1);
351 dvalue2 =
lddbl (pckey2);
352 if (dvalue1 < dvalue2) {
355 if (dvalue1 > dvalue2) {
358 pckey1 += DOUBLESIZE;
359 pckey2 += DOUBLESIZE;
360 ilengthtocompare -= DOUBLESIZE;
372 ivbkeysearch (
const int ihandle,
const int imode,
const int ikeynumber,
373 int ilength,
unsigned char *pckeyvalue, off_t tdupnumber)
376 struct keydesc *pskeydesc;
378 unsigned char ckeyvalue[VB_MAX_KEYLEN];
382 ilength = pskeydesc->k_len;
388 return itreeload (ihandle, ikeynumber, ilength, ckeyvalue, tdupnumber);
393 return itreeload (ihandle, ikeynumber, ilength, ckeyvalue, tdupnumber);
396 iresult =
ivbkeyload (ihandle, ikeynumber, ISNEXT, 1, &pskey);
398 if (iresult == EENDFILE) {
407 iresult =
ivbkeyload (ihandle, ikeynumber, ISPREV, 1, &pskey);
409 if (iresult == EENDFILE) {
418 return itreeload (ihandle, ikeynumber, ilength, pckeyvalue, tdupnumber);
423 return itreeload (ihandle, ikeynumber, ilength, pckeyvalue, tdupnumber);
427 return itreeload (ihandle, ikeynumber, ilength, pckeyvalue, tdupnumber);
441 unsigned char ckeyvalue[VB_MAX_KEYLEN];
453 if (pskey && pskey->
trownode == trownumber) {
480 iresult =
ivbkeysearch (ihandle, ISGTEQ, ikeynumber, 0, ckeyvalue, (off_t)0);
481 if (iresult < 0 || iresult > 1) {
503 ivbkeyload (
const int ihandle,
const int ikeynumber,
const int imode,
504 const int isetcurr,
struct VBKEY **ppskey)
507 struct VBKEY *pskey, *pskeyhold;
543 while (pstree->
ilevel && pskey) {
659 vvbkeyvalueset (
const int ihigh,
struct keydesc *pskeydesc,
unsigned char *pckeyvalue)
661 struct keypart *pskptr;
662 int ipart, iremainder;
665 for (ipart = 0; ipart < pskeydesc->k_nparts; ipart++) {
666 pskptr = &pskeydesc->k_part[ipart];
667 switch (pskptr->kp_type & ~ISDESC) {
669 memset (pckeyvalue, ihigh ? 0xff : 0, (
size_t)pskptr->kp_leng);
670 pckeyvalue += pskptr->kp_leng;
674 iremainder = pskptr->kp_leng;
675 while (iremainder > 0) {
676 inl_stint (ihigh ? SHRT_MAX : SHRT_MIN, pckeyvalue);
677 pckeyvalue += INTSIZE;
678 iremainder -= INTSIZE;
683 iremainder = pskptr->kp_leng;
684 while (iremainder > 0) {
685 inl_stlong (ihigh ? LONG_MAX : LONG_MIN, pckeyvalue);
686 pckeyvalue += LONGSIZE;
687 iremainder -= LONGSIZE;
692 memset (cbuffer, ihigh ? 0xff : 0,
QUADSIZE);
693 cbuffer[0] = ihigh ? 0x7f : 0x80;
694 iremainder = pskptr->kp_leng;
695 while (iremainder > 0) {
696 memcpy (pckeyvalue, cbuffer,
QUADSIZE);
703 iremainder = pskptr->kp_leng;
704 while (iremainder > 0) {
705 stfloat (ihigh ? FLT_MAX : FLT_MIN, pckeyvalue);
706 pckeyvalue += FLOATSIZE;
707 iremainder -= FLOATSIZE;
712 iremainder = pskptr->kp_leng;
713 while (iremainder > 0) {
714 stdbl (ihigh ? DBL_MAX : DBL_MIN, pckeyvalue);
715 pckeyvalue += DOUBLESIZE;
716 iremainder -= DOUBLESIZE;
728 unsigned char *pckeyvalue, off_t trownode, off_t tdupnumber,
732 struct VBKEY *pskey, *pstempkey;
733 int iposn = 0, iresult;
751 memcpy (pskey->
ckey, pckeyvalue, (
size_t)psvbptr->
pskeydesc[ikeynumber]->k_len);
763 for (pstempkey = pstree->
pskeyfirst; pstempkey; pstempkey = pstempkey->
psnext) {
764 if (pstempkey == pskey) {
780 struct VBKEY *pskey, *pskeytemp;
781 struct VBTREE *pstree, *pstreeroot;
782 int iforcerewrite = 0, iposn, iresult;
833 pskeytemp = pskeytemp->
psnext) {
834 if (pskey == pskeytemp) {
863 return ivbnodesave (ihandle, ikeynumber, pstreeroot,
876 psvbptr->
pskeydesc[ikeynumber]->k_rootnode;
881 if (pstree != pstreeroot) {
884 psvbptr->
pstree[ikeynumber] = pstreeroot;
885 return ivbnodesave (ihandle, ikeynumber, pstreeroot,
int ivbkeyinsert(const int ihandle, struct VBTREE *pstree, const int ikeynumber, unsigned char *pckeyvalue, off_t trownode, off_t tdupnumber, struct VBTREE *pschild)
void vvbmakekey(const struct keydesc *pskeydesc, char *pcrow_buffer, unsigned char *pckeyvalue)
int ivbkeyload(const int ihandle, const int ikeynumber, const int imode, const int isetcurr, struct VBKEY **ppskey)
static int inl_ldint(void *pclocation)
int ivbkeycompare(const int ihandle, const int ikeynumber, int ilength, unsigned char *pckey1, unsigned char *pckey2)
int ivbkeylocaterow(const int ihandle, const int ikeynumber, off_t trownumber)
struct VBTREE * psvbtreeallocate(const int ihandle)
unsigned char iindexchanged
void stdbl(double dsource, void *pcdestination)
int ivbkeysearch(const int ihandle, const int imode, const int ikeynumber, int ilength, unsigned char *pckeyvalue, off_t tdupnumber)
struct VBKEY * psvbkeyallocate(const int ihandle, const int ikeynumber)
static void inl_stlong(int lvalue, void *pclocation)
int ivbnodeload(const int ihandle, const int ikeynumber, struct VBTREE *pstree, const off_t tnodenumber, const int iprevlvl)
static void inl_stint(int ivalue, void *pclocation)
static int itreeload(const int ihandle, const int ikeynumber, const int ilength, unsigned char *pckeyvalue, off_t tdupnumber)
void stfloat(double dsource, void *pcdestination)
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
double lddbl(void *pclocation)
struct VBKEY * pskeycurr[32]
void vvbkeyvalueset(const int ihigh, struct keydesc *pskeydesc, unsigned char *pckeyvalue)
int ivbnodesave(const int ihandle, const int ikeynumber, struct VBTREE *pstree, const off_t tnodenumber, const int imode, const int iposn)
double ldfloat(void *pclocation)
int ivbkeydelete(const int ihandle, const int ikeynumber)
void vvbkeyfree(const int ihandle, const int ikeynumber, struct VBKEY *pskey)
struct DICTINFO * psvbfile[128+1]
int ivbnodefree(const int ihandle, const off_t tnodenumber)
static int inl_ldlong(void *pclocation)
void vvbtreeallfree(const int ihandle, const int ikeynumber, struct VBTREE *pstree)
struct VBKEY * pskeylist[512]
struct VBTREE * pstree[32]
struct VBKEY * pskeyfirst
struct keydesc * pskeydesc[32]
static off_t inl_ldquad(void *pclocation)