29 off_t theadnode, tnodenumber = 0, tnewnode;
30 int iloop, ilenkeyuncomp = 0, ilenkeydesc, inodeused;
31 char ckeydesc[INTSIZE +
QUADSIZE + 1 + (NPARTS * ((INTSIZE * 2) + 1))];
36 pcdstptr = ckeydesc + INTSIZE;
65 tnodenumber = theadnode;
74 *pcdstptr = pskeydesc->k_flags / 2;
76 for (iloop = 0; iloop < pskeydesc->k_nparts; iloop++) {
77 ilenkeyuncomp += pskeydesc->k_part[iloop].kp_leng;
78 inl_stint (pskeydesc->k_part[iloop].kp_leng, pcdstptr);
79 if (iloop == 0 && pskeydesc->k_flags & ISDUPS) {
83 inl_stint (pskeydesc->k_part[iloop].kp_start, pcdstptr);
85 *pcdstptr = pskeydesc->k_part[iloop].kp_type;
89 ilenkeydesc = pcdstptr - ckeydesc;
91 if (psvbptr->
inodesize - (inodeused + 4) < ilenkeydesc) {
98 memcpy (cvbnodetmp2 + INTSIZE +
QUADSIZE, ckeydesc, (
size_t)ilenkeydesc);
110 inl_stint (inodeused + ilenkeydesc, cvbnodetmp);
111 pskeydesc->k_len = ilenkeyuncomp;
112 pskeydesc->k_rootnode = tnewnode;
113 memcpy (cvbnodetmp + inodeused, ckeydesc, (
size_t)ilenkeydesc);
144 pcsrcptr = cvbnodetmp + INTSIZE +
QUADSIZE;
146 while (pcsrcptr - cvbnodetmp < inodeused) {
147 if (iloop < ikeynumber) {
155 memcpy (pcsrcptr, pcsrcptr + n,
156 (
size_t)(psvbptr->
inodesize - (pcsrcptr - cvbnodetmp +
162 return psvbptr->
pskeydesc[ikeynumber]->k_rootnode;
164 theadnode =
inl_ldquad (cvbnodetmp + INTSIZE);
170 idelnodes (
const int ihandle,
const int ikeynumber, off_t trootnode)
174 struct keydesc *pskeydesc;
175 int iduplicate, ikeylength, icomplength = 0;
176 int inodeused, iresult = 0;
180 pskeydesc = psvbptr->
pskeydesc[ikeynumber];
181 iresult =
ivbblockread (ihandle, 1, trootnode, clclnode);
186 if (*(clclnode + psvbptr->
inodesize - 2)) {
189 pcsrcptr = clclnode + INTSIZE +
QUADSIZE;
191 pcsrcptr = clclnode + INTSIZE;
194 while (pcsrcptr - clclnode < inodeused) {
196 if (!(*(pcsrcptr + QUADSIZE) & 0x80)) {
204 pcsrcptr += (QUADSIZE * 2);
206 ikeylength = pskeydesc->k_len;
207 if (pskeydesc->k_flags & LCOMPRESS) {
211 ikeylength -= (icomplength - 2);
213 icomplength = *(pcsrcptr);
215 ikeylength -= (icomplength - 1);
218 if (pskeydesc->k_flags & TCOMPRESS) {
222 ikeylength -= (icomplength - 2);
224 icomplength = *pcsrcptr;
226 ikeylength -= (icomplength - 1);
229 pcsrcptr += ikeylength;
230 if (pskeydesc->k_flags & ISDUPS) {
232 if (*pcsrcptr & 0x80) {
253 int ideleted, iresult;
254 unsigned char ckeyvalue[VB_MAX_KEYLEN];
258 if (psvbptr->
pskeydesc[ikeynumber]->k_nparts == 0) {
281 iresult =
ivbkeysearch (ihandle, ISGREAT, ikeynumber, 0, ckeyvalue, (off_t)0);
283 if (iresult >= 0 && !
ivbkeyload (ihandle, ikeynumber, ISPREV, 0, &pskey)
284 && !memcmp (pskey->
ckey, ckeyvalue,
285 (
size_t)psvbptr->
pskeydesc[ikeynumber]->k_len)) {
287 if (psvbptr->
pskeydesc[ikeynumber]->k_flags & ISDUPS) {
310 isbuild (
const char *pcfilename,
const int imaxrowlength,
struct keydesc *pskey,
int imode)
320 if (imode & ISVARLEN) {
323 iminrowlength = imaxrowlength;
325 iflags = imode & 0x03;
331 if (strlen (pcfilename) >
sizeof(tmpfname) - 5) {
343 if (!strcmp (
psvbfile[ihandle]->cfilename, pcfilename)) {
350 for (ihandle = 0; ; ihandle++) {
365 if (psvbptr ==
NULL) {
369 psvbptr->
cfilename = strdup (pcfilename);
387 memcpy (psvbptr->
pskeydesc[0], pskey, sizeof (
struct keydesc));
388 if (
ivbcheckkey (ihandle, pskey, 0, iminrowlength, 1)) {
391 sprintf (tmpfname,
"%s.dat", pcfilename);
392 if (!stat (tmpfname, &sstat)) {
396 sprintf (tmpfname,
"%s.idx", pcfilename);
397 if (!stat (tmpfname, &sstat)) {
405 sprintf (tmpfname,
"%s.dat", pcfilename);
439 if (pskey->k_nparts) {
448 if (imode & ISVARLEN) {
478 inl_stint (INTSIZE +
QUADSIZE + 1 + (((INTSIZE * 2) + 1) * pskey->k_nparts), pctemp);
480 if (pskey->k_nparts) {
486 *pctemp = pskey->k_flags / 2;
488 for (iloop = 0; iloop < pskey->k_nparts; iloop++) {
489 inl_stint (pskey->k_part[iloop].kp_leng, pctemp);
490 if (iloop == 0 && pskey->k_flags & 1) {
494 inl_stint (pskey->k_part[iloop].kp_start, pctemp);
496 *pctemp = pskey->k_part[iloop].kp_type;
499 inl_stint (pctemp - cvbnodetmp, cvbnodetmp);
518 if (pskey->k_nparts) {
546 if (imode & ISEXCLLOCK) {
556 ivbtransbuild (pcfilename, iminrowlength, imaxrowlength, pskey, imode);
557 return isopen (pcfilename, imode);
561 free (
psvbfile[ihandle]->cfilename);
563 if (
psvbfile[ihandle]->ppcrowbuffer) {
564 free (
psvbfile[ihandle]->ppcrowbuffer);
566 if (
psvbfile[ihandle]->pskeydesc[0]) {
567 free (
psvbfile[ihandle]->pskeydesc[0]);
580 int iresult, ikeynumber;
589 if (!(psvbptr->
iopenmode & ISEXCLLOCK)) {
593 ikeynumber =
ivbcheckkey (ihandle, pskeydesc, 1, 0, 0);
594 if (ikeynumber == -1) {
602 ikeynumber =
ivbcheckkey (ihandle, pskeydesc, 1, 0, 0);
603 if (ikeynumber < 0) {
606 for (ikeynumber = 0; ikeynumber <
MAXSUBS && psvbptr->
pskeydesc[ikeynumber];
612 ikeynumber = psvbptr->
inkeys;
620 memcpy (psvbptr->
pskeydesc[ikeynumber], pskeydesc, sizeof (
struct keydesc));
648 int iresult = -1, ikeynumber, iloop;
655 if (!(psvbptr->
iopenmode & ISEXCLLOCK)) {
659 ikeynumber =
ivbcheckkey (ihandle, pskeydesc, 2, 0, 0);
660 if (ikeynumber == -1) {
672 if (
idelnodes (ihandle, ikeynumber, trootnode)) {
678 for (iloop = ikeynumber; iloop <
MAXSUBS; iloop++) {
int isdelindex(const int ihandle, struct keydesc *pskeydesc)
int ivbopen(const char *pcfilename, const int iflags, const mode_t tmode)
static int inl_ldint(void *pclocation)
int ivbkeysearch(const int ihandle, const int imode, const int ikeynumber, int ilength, unsigned char *pckeyvalue, off_t tdupnumber)
int ivbblockread(const int ihandle, const int iisindex, const off_t tblocknumber, char *cbuffer)
int ivbcheckkey(const int ihandle, struct keydesc *pskey, const int imode, int irowlength, const int iisbuild)
static int imakekeysfromdata(const int ihandle, const int ikeynumber)
int ivbtranscreateindex(const int ihandle, struct keydesc *pskeydesc)
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)
static int iaddkeydescriptor(const int ihandle, struct keydesc *pskeydesc)
void ivbclose3(const int ihandle)
static void inl_stint(int ivalue, void *pclocation)
int ivbtransdeleteindex(const int ihandle, struct keydesc *pskeydesc)
unsigned char iisdictlocked
int isopen(const char *pcfilename, int imode)
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
struct VBKEY * pskeyfree[32]
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)
void * pvvbmalloc(const size_t size)
int ivbfileopenlock(const int ihandle, const int imode)
static int idelnodes(const int ihandle, const int ikeynumber, off_t trootnode)
struct DICTINFO * psvbfile[128+1]
off_t tvbnodecountgetnext(const int ihandle)
int isaddindex(const int ihandle, struct keydesc *pskeydesc)
int ivbtransbuild(const char *pcfilename, const int iminrowlen, const int imaxrowlen, struct keydesc *pskeydesc, const int imode)
int ivbnodefree(const int ihandle, const off_t tnodenumber)
int ivbclose(const int ihandle)
int ivbkeyinsert(const int ihandle, struct VBTREE *pstree, const int ikeynumber, unsigned char *pckeyvalue, off_t trownode, off_t tdupnumber, struct VBTREE *pschild)
int ivbexit(const int ihandle)
int ivbblockwrite(const int ihandle, const int iisindex, const off_t tblocknumber, const char *cbuffer)
static off_t tdelkeydescriptor(const int ihandle, struct keydesc *pskeydesc, const int ikeynumber)
int isclose(const int ihandle)
void vvbtreeallfree(const int ihandle, const int ikeynumber, struct VBTREE *pstree)
int isbuild(const char *pcfilename, const int imaxrowlength, struct keydesc *pskey, int imode)
#define MAX_RESERVED_LENGTH
static void inl_stquad(off_t tvalue, void *pclocation)
struct VBTREE * pstree[32]
struct keydesc * pskeydesc[32]
static off_t inl_ldquad(void *pclocation)
void vvbkeyunmalloc(const int ihandle, const int ikeynumber)