28 int ibias = 1, ideleted = 1, ilockresult = 0, iresult = 0;
85 if (psvbptr->
iopenmode & ISAUTOLOCK || imode & ISLOCK) {
87 ilockresult = ELOCKED;
124 ivbcheckkey (
const int ihandle,
struct keydesc *pskey,
const int imode,
125 int irowlength,
const int iisbuild)
128 struct keydesc *pslocalkey;
129 struct keypart *pskptr;
130 struct keypart *psklptr;
131 int iloop, ipart, itype, ilocalkeylength;
140 if (pskey->k_flags < 0 || pskey->k_flags > COMPRESS + ISDUPS) {
141 goto vbcheckkey_exit;
143 if (pskey->k_nparts >= NPARTS || pskey->k_nparts < 0) {
144 goto vbcheckkey_exit;
146 if (pskey->k_nparts == 0 && !iisbuild) {
147 goto vbcheckkey_exit;
149 for (ipart = 0; ipart < pskey->k_nparts; ipart++) {
152 pskptr = &pskey->k_part[ipart];
153 pskey->k_len += pskptr->kp_leng;
154 if (pskey->k_len > VB_MAX_KEYLEN) {
155 goto vbcheckkey_exit;
157 itype = pskptr->kp_type & ~ISDESC;
163 if (pskptr->kp_leng % INTSIZE) {
164 goto vbcheckkey_exit;
169 if (pskptr->kp_leng % LONGSIZE) {
170 goto vbcheckkey_exit;
176 goto vbcheckkey_exit;
181 if (pskptr->kp_leng % FLOATSIZE) {
182 goto vbcheckkey_exit;
187 if (pskptr->kp_leng % DOUBLESIZE) {
188 goto vbcheckkey_exit;
193 goto vbcheckkey_exit;
195 if (pskptr->kp_start + pskptr->kp_leng > irowlength) {
196 goto vbcheckkey_exit;
198 if (pskptr->kp_start < 0) {
199 goto vbcheckkey_exit;
208 for (iloop = 0; iloop < psvbptr->
inkeys; iloop++) {
210 if (pslocalkey->k_nparts != pskey->k_nparts) {
214 for (ipart = 0; ipart < pslocalkey->k_nparts; ipart++) {
215 pskptr = &pskey->k_part[ipart];
216 psklptr = &pslocalkey->k_part[ipart];
217 if (psklptr->kp_start != pskptr->kp_start) {
220 if (psklptr->kp_leng != pskptr->kp_leng) {
223 if (psklptr->kp_type != pskptr->kp_type) {
226 ilocalkeylength += pskptr->kp_leng;
228 if (ipart == pslocalkey->k_nparts) {
229 pskey->k_len = ilocalkeylength;
233 if (iloop == psvbptr->
inkeys) {
235 goto vbcheckkey_exit;
240 goto vbcheckkey_exit;
250 isread (
const int ihandle,
char *pcrow,
int imode)
254 int ideleted = 0, ikeynumber, ilockresult = 0;
255 int ireadmode, iresult = -1;
256 unsigned char ckeyvalue[VB_MAX_KEYLEN];
270 ireadmode = imode & BYTEMASK;
272 if (ikeynumber == -1 || !psvbptr->
pskeydesc[ikeynumber]->k_nparts) {
290 iresult =
ivbkeysearch (ihandle, ISFIRST, ikeynumber, 0, ckeyvalue, (off_t)0);
307 iresult =
ivbkeysearch (ihandle, ISLAST, ikeynumber, 0, ckeyvalue, (off_t)0);
324 iresult =
ivbkeysearch (ihandle, ISGTEQ, ikeynumber, 0, ckeyvalue, (off_t)0);
332 iresult =
ivbkeyload (ihandle, ikeynumber, ISNEXT, 1, &pskey);
333 if (iresult == EENDFILE) {
341 (
size_t)psvbptr->
pskeydesc[ikeynumber]->k_len)) {
353 iresult =
ivbkeysearch (ihandle, ireadmode, ikeynumber, 0, ckeyvalue, (off_t)0);
443 if (imode & ISLOCK || psvbptr->
iopenmode & ISAUTOLOCK) {
448 iserrno = ilockresult = ELOCKED;
455 if (!iresult && (!ilockresult || (imode & ISSKIPLOCK &&
iserrno == ELOCKED))) {
469 isstart (
const int ihandle,
struct keydesc *
pskeydesc,
int ilength,
char *pcrow,
int imode)
473 int ikeynumber, iresult;
474 unsigned char ckeyvalue[VB_MAX_KEYLEN];
475 unsigned char ckeyvalue2[VB_MAX_KEYLEN];
482 ikeynumber =
ivbcheckkey (ihandle, pskeydesc, 2, 0, 0);
484 if (ikeynumber == -1 && pskeydesc->k_nparts) {
487 if (ilength < 1 || ilength > psvbptr->
pskeydesc[ikeynumber]->k_len) {
488 ilength = pskeydesc->k_len;
491 if (!(imode & ISKEEPLOCK)) {
495 if (!pskeydesc->k_nparts) {
497 if (iresult &&
iserrno == ENOREC && imode <= ISLAST) {
507 iresult =
ivbkeysearch (ihandle, ISFIRST, ikeynumber, 0, ckeyvalue, (off_t)0);
516 iresult =
ivbkeysearch (ihandle, ISLAST, ikeynumber, 0, ckeyvalue, (off_t)0);
517 if (iresult < 0 || iresult > 2) {
530 memset (ckeyvalue, 0,
sizeof (ckeyvalue));
531 memcpy (ckeyvalue, ckeyvalue2, (
size_t)ilength);
532 if (ilength < pskeydesc->k_len) {
533 iresult =
ivbkeysearch (ihandle, ISGTEQ, ikeynumber, 0, ckeyvalue, (off_t)0);
535 iresult =
ivbkeysearch (ihandle, ISEQUAL, ikeynumber, ilength, ckeyvalue, (off_t)0);
544 }
else if (iresult == 0
545 && memcmp (ckeyvalue,
557 if (ilength < pskeydesc->k_len && imode == ISGREAT) {
558 memset (ckeyvalue, 255,
sizeof (ckeyvalue));
560 memset (ckeyvalue, 0,
sizeof (ckeyvalue));
562 memcpy (ckeyvalue, ckeyvalue2, (
size_t)ilength);
563 iresult =
ivbkeysearch (ihandle, imode, ikeynumber, 0, ckeyvalue, (off_t)0);
static int istartrownumber(const int ihandle, const int imode, const int iisread)
int ivbkeysearch(const int ihandle, const int imode, const int ikeynumber, int ilength, unsigned char *pckeyvalue, off_t tdupnumber)
int ivbkeylocaterow(const int ihandle, const int ikeynumber, off_t trownumber)
int ivbcheckkey(const int ihandle, struct keydesc *pskey, const int imode, int irowlength, const int iisbuild)
int ivbenter(const int ihandle, const unsigned int imodifying, const unsigned int ispecial)
int ivbkeyload(const int ihandle, const int ikeynumber, const int imode, const int isetcurr, struct VBKEY **ppskey)
int isstart(const int ihandle, struct keydesc *pskeydesc, int ilength, char *pcrow, int imode)
unsigned char iisdictlocked
int ivbdatalock(const int ihandle, const int imode, const off_t trownumber)
struct VBKEY * pskeycurr[32]
struct DICTNODE sdictnode
void vvbmakekey(const struct keydesc *pskeydesc, char *pcrow_buffer, unsigned char *pckeyvalue)
int ivbdataread(const int ihandle, char *pcbuffer, int *pideletedrow, const off_t trownumber)
struct DICTINFO * psvbfile[128+1]
int ivbexit(const int ihandle)
int isread(const int ihandle, char *pcrow, int imode)
unsigned char iisdisjoint
struct keydesc * pskeydesc[32]
static off_t inl_ldquad(void *pclocation)
int isrelease(const int ihandle)