59 ttailnode (
const int ihandle,
char *pcbuffer,
const int ilength,
int *pislotnumber)
65 off_t tnodenumber = 0, tnodenext, tnodeprev;
66 int ifreethis, ifreeoffset, igroup, islotnumber;
73 pshdr = (
struct SVARLEN *)clclnode;
74 psnphdr = (
struct SVARLEN *)cnextprev;
77 for (igroup = 0;
igroupsize[igroup] < ilength + INTSIZE + INTSIZE; igroup++) {
83 while (!tnodenumber) {
106 if (tnodenumber == -1) {
115 clclnode[inodesize - 3] = 0x7c;
124 pcnodeptr = clclnode + inodesize - (3 + INTSIZE + INTSIZE);
130 for (islotnumber = 0; islotnumber < n; islotnumber++) {
132 pcnodeptr -= (INTSIZE * 2);
135 *pislotnumber = islotnumber;
139 if (*pislotnumber == -1) {
153 pcnodeptr = clclnode + inodesize - (3 + INTSIZE + INTSIZE +
154 (*pislotnumber * INTSIZE * 2));
156 inl_stint (ifreeoffset, pcnodeptr + INTSIZE);
157 memcpy (clclnode + ifreeoffset, pcbuffer, (
size_t)ilength);
158 ifreethis -= ilength;
160 ifreeoffset += ilength;
163 for (igroup = 0;
igroupsize[igroup] < ifreethis; igroup++) {
169 if (igroup != pshdr->
cgroup) {
206 (pshdr->
cgroup * QUADSIZE));
220 ivbvarlenread (
const int ihandle,
char *pcbuffer, off_t tnodenumber,
int islotnumber,
int ilength)
223 int iresult, islotlength, islotoffset;
236 pcnodeptr =
cnode + inodesize - 3;
237 if (*pcnodeptr != 0x7c) {
241 pcnodeptr -= ((islotnumber + 1) * INTSIZE * 2);
243 islotoffset =
inl_ldint (pcnodeptr + INTSIZE);
244 if (islotlength <= ilength) {
249 memcpy (pcbuffer,
cnode + islotoffset, (
size_t)ilength);
252 ilength -= islotlength;
256 *(psvarlenheader->
cfreecont + 1) &= (
unsigned char)0x3f;
258 islotnumber = *(psvarlenheader->
cfreecont);
273 off_t tnewnode, tnodenumber = 0;
283 while (ilength > 0) {
285 (inodesize - (
int)(3 + INTSIZE + INTSIZE +
sizeof (
struct SVARLEN)))) {
287 if (tnewnode == -1) {
304 inl_stint (inodesize - (3 + INTSIZE + INTSIZE),
306 psvarlenheader->
cflag = 0x01;
312 psvarlenheader->
cgroup = 0x00;
313 memcpy (&(psvarlenheader->
cgroup) + 1, pcbuffer,
314 inodesize - (3 + INTSIZE + INTSIZE +
317 inodesize - (3 + INTSIZE + INTSIZE +
320 inodesize - (3 + INTSIZE + INTSIZE +
324 (3 + INTSIZE + INTSIZE +
sizeof (
struct SVARLEN)),
325 cnode + inodesize - (3 + INTSIZE + INTSIZE));
328 cnode + inodesize - (3 + INTSIZE));
329 *(
cnode + inodesize - 3) = 0x7c;
330 *(
cnode + inodesize - 2) = 0x0;
331 *(
cnode + inodesize - 1) = 0x0;
332 tnodenumber = tnewnode;
340 if (tnodenumber && !ilength) {
344 tnewnode =
ttailnode (ihandle, pcbuffer, ilength, &islotnumber);
345 if (tnewnode == -1) {
354 *psvarlenheader->
cfreecont = islotnumber;
379 off_t tnodenext, tnodeprev;
380 int ifreethis, ifreeoffset, igroup,
381 iisanyused, iloop, imovelength,
382 ioffset, ithislength, ithisoffset, iusedcount;
387 while (ilength > 0) {
392 (3 + INTSIZE + INTSIZE + (islotnumber * 2 * INTSIZE)));
393 ilength -= ithislength;
395 (3 + INTSIZE + INTSIZE + (islotnumber * 2 * INTSIZE)));
397 (3 + INTSIZE + (islotnumber * 2 * INTSIZE)));
399 (3 + INTSIZE + (islotnumber * 2 * INTSIZE)));
406 for (iloop = 0; iloop < iusedcount; iloop++) {
408 (3 + INTSIZE + INTSIZE + (iloop * 2 * INTSIZE)))) {
416 igroup = psvarlenheader->
cgroup;
421 (igroup * QUADSIZE));
447 if (islotnumber == iusedcount) {
454 ifreethis += (INTSIZE * 2);
456 imovelength = inodesize - (ithisoffset + ithislength);
457 imovelength -= (3 + (iusedcount * INTSIZE * 2));
458 memmove (
cnode + ithisoffset,
cnode + ithisoffset + ithislength, (
size_t)imovelength);
459 ifreeoffset -= ithislength;
460 ifreethis += ithislength;
463 memset (
cnode + ifreeoffset, 0, (
size_t)ifreethis);
464 for (iloop = 0; iloop < iusedcount; iloop++) {
467 (3 + INTSIZE + (iloop * 2 * INTSIZE)));
468 if (ioffset > ithisoffset) {
471 (3 + INTSIZE + (iloop * 2 * INTSIZE)));
496 off_t tblocknumber, toffset, tsofar;
510 if (trownumber < 1) {
521 toffset = irowlength * (trownumber - 1);
525 memset (pcreadbuffer, 0, irowlength);
529 memcpy (pcbuffer, pcreadbuffer, (
size_t)psvbptr->
iminrowlength);
538 toffset = irowlength * (trownumber - 1);
539 tblocknumber = (toffset / psvbptr->
inodesize);
540 toffset -= (tblocknumber * psvbptr->
inodesize);
541 if (
ivbblockread (ihandle, 0, tblocknumber + 1, cvbnodetmp)) {
548 memcpy (pcbuffer + tsofar, cvbnodetmp + toffset,
554 memcpy (pcbuffer + tsofar, cvbnodetmp + toffset, (
size_t)(psvbptr->
inodesize - toffset));
558 if (
ivbblockread (ihandle, 0, tblocknumber + 1, cvbnodetmp)) {
564 while (tsofar < irowlength) {
565 if ((irowlength - tsofar) <= (psvbptr->
inodesize - toffset)) {
566 memcpy (cfooter + tsofar - psvbptr->
iminrowlength, cvbnodetmp + toffset,
567 (
size_t)(irowlength - tsofar));
570 memcpy (cfooter + tsofar - psvbptr->
iminrowlength, cvbnodetmp + toffset,
575 if (
ivbblockread (ihandle, 0, tblocknumber + 1, cvbnodetmp)) {
581 if (cfooter[0] == 0x00) {
591 *(cfooter + 1 + INTSIZE + 1) &= (
unsigned char)0x3f;
595 *(cfooter + 1 + INTSIZE) = 0;
615 off_t tblocknumber, toffset, tsofar;
628 if (trownumber < 1) {
634 toffset = irowlength + 1;
639 toffset *= (trownumber - 1);
643 memcpy (pcwritebuffer, pcbuffer, (
size_t)irowlength);
644 *(pcwritebuffer + irowlength) = ideletedrow ? 0x00 : 0x0a;
646 if (
tvbwrite (psvbptr->
idatahandle, pcwritebuffer, (
size_t)irowlength) != (ssize_t)irowlength) {
651 toffset *= (trownumber - 1);
670 memcpy (pcwritebuffer, pcbuffer, (
size_t)irowlength);
671 *(pcwritebuffer + irowlength) = ideletedrow ? 0x00 : 0x0a;
675 pctemp = pcwritebuffer + irowlength + INTSIZE;
686 tblocknumber = (toffset / psvbptr->
inodesize);
687 toffset -= (tblocknumber * psvbptr->
inodesize);
689 while (tsofar < irowlength) {
691 ivbblockread (ihandle, 0, tblocknumber + 1, cvbnodetmp);
692 if ((irowlength - tsofar) <= (psvbptr->
inodesize - toffset)) {
693 memcpy (cvbnodetmp + toffset, pcwritebuffer + tsofar,
694 (
size_t)(irowlength - tsofar));
695 if (
ivbblockwrite (ihandle, 0, tblocknumber + 1, cvbnodetmp)) {
700 memcpy (cvbnodetmp + toffset, pcbuffer + tsofar, (
size_t)(psvbptr->
inodesize - toffset));
701 if (
ivbblockwrite (ihandle, 0, tblocknumber + 1, cvbnodetmp)) {
ssize_t tvbwrite(const int ihandle, const void *pvbuffer, const size_t tcount)
static struct SVARLEN * psvarlenheader
static int inl_ldint(void *pclocation)
int ivbdataread(const int ihandle, char *pcbuffer, int *pideletedrow, const off_t trownumber)
int ivbblockread(const int ihandle, const int iisindex, const off_t tblocknumber, char *cbuffer)
static off_t ttailnode(const int ihandle, char *pcbuffer, const int ilength, int *pislotnumber)
static int ivbvarlenread(const int ihandle, char *pcbuffer, off_t tnodenumber, int islotnumber, int ilength)
static void inl_stint(int ivalue, void *pclocation)
unsigned char iisdictlocked
struct DICTNODE sdictnode
static int ivbvarlenwrite(const int ihandle, char *pcbuffer, int ilength)
static const int igroupsize[]
struct DICTINFO * psvbfile[128+1]
off_t tvbnodecountgetnext(const int ihandle)
int ivbnodefree(const int ihandle, const off_t tnodenumber)
int ivbblockwrite(const int ihandle, const int iisindex, const off_t tblocknumber, const char *cbuffer)
#define MAX_RESERVED_LENGTH
static void inl_stquad(off_t tvalue, void *pclocation)
ssize_t tvbread(const int ihandle, void *pvbuffer, const size_t tcount)
static int ivbvarlendelete(const int ihandle, off_t tnodenumber, int islotnumber, int ilength)
int ivbdatawrite(const int ihandle, char *pcbuffer, int ideletedrow, const off_t trownumber)
static off_t inl_ldquad(void *pclocation)
static char * pcwritebuffer
off_t tvblseek(const int ihandle, off_t toffset, const int iwhence)