home *** CD-ROM | disk | FTP | other *** search
- /*
- * update support routines (used in ctaddk & ctdelk)
- *
- * This program is the CONFIDENTIAL and PROPRIETARY property
- * of FairCom(R) Corporation. Any unauthorized use, reproduction or
- * transfer of this program is strictly prohibited.
- *
- * Copyright (c) 1984, 1985, 1986, 1987, 1988, 1989 FairCom Corporation
- * (Subject to limited distribution and
- * restricted disclosure only.)
- * *** ALL RIGHTS RESERVED ***
- *
- * 4006 West Broadway
- * Columbia, MO 65203
- *
- *
- * c-tree(R) Version 4.3
- * Release C
- * February 7, 1989 17:30
- *
- */
-
- #include "ctstdr.h" /* standard i/o header */
- #include "ctoptn.h" /* c-tree configuration options */
- #include "cterrc.h" /* c-tree error codes */
- #include "ctstrc.h" /* c-tree data structures */
- #include "ctgvar.h" /* c-tree global variables */
-
- /*
- * To disable the index entry count as described in Section 6.2,
- * add the following #define to the CTOPTN.H module:
- *
- * #define NO_IDXENT
- *
- */
-
-
- #ifdef FPUTFGET
- COUNT LOCK(),UNLOCK();
- #endif
-
- /* --------------------------------------------------------------------
- hdrupd updates index header information, either on disk or in memory
- */
-
- COUNT hdrupd(knum,chgnum)
-
- KEYFILE *knum;
- POINTER chgnum;
-
- {
- #ifndef NO_IDXENT
- COUNT redhdr(),wrthdr();
-
- #ifdef FPUTFGET
- if (LOCK(NODEZERO,knum) || redhdr(knum - knum->kmem))
- return(uerr_cod);
- #endif
-
- knum->nument += chgnum;
-
- #ifdef NOTFORCE
- /* no action */
- #else
- if (wrthdr(knum))
- return(uerr_cod);
- #endif
-
- #ifdef FPUTFGET
- if (UNLOCK(NODEZERO,knum))
- return(uerr_cod);
- #endif
- #endif
- return(NO_ERROR);
- }
-
-
- /* --------------------------------------------------------------------
- routine to update node size and note that node has been updated
- */
-
- COUNT putnod(buf,nodsiz)
-
- PFAST TREEBUFF *buf;
- PFAST COUNT nodsiz;
-
- {
- VOID inracs();
- COUNT wrtnod();
-
- if (nodsiz < 0)
- terr(216);
- inracs(buf);
- buf->update = 'y';
- buf->nkv = nodsiz;
-
- #ifdef NOTFORCE
- /* no action */
- #else
- if (wrtnod(buf))
- return(uerr_cod);
- #endif
-
- return(NO_ERROR);
- }
-
-
- /* ---------------------------------------------------------------------
- setup duplicate ct_key entry for ADDKEY & DELKEY
- */
-
- VOID prpdup(ip,knum,pntrp)
-
- TEXT *ip;
- KEYFILE *knum;
- POINTER *pntrp;
-
- {
- FAST COUNT kl;
- FAST TEXT *suffix,*tp;
-
- suffix = ip + knum->length - sizeof(POINTER);
- tp = (TEXT *) pntrp;
-
- #ifdef LOW_HIGH
- tp += sizeof(POINTER);
- for (kl = 0; kl < sizeof(POINTER); kl++)
- *suffix++ = *--tp;
- #else
- for (kl = 0; kl < sizeof(POINTER); kl++)
- *suffix++ = *tp++;
- #endif
-
- }
-
- /* --------------------------------------------------------------------
- move right with left-to-right locking
- */
-
- TREEBUFF *movrgt(idxval,knum,buffer)
-
- TEXT *idxval; /* pointer to target key value */
- PFAST KEYFILE *knum; /* key number pointer */
- PFAST TREEBUFF *buffer; /* pointer to buffer containing leaf node */
-
- {
- LOCAL LONG node;
-
- COUNT nodser();
- TREEBUFF *getnod();
- /* NOTE: nodser sets ct_elm */
- while (buffer != NULL && nodser(buffer,idxval,'L') == -1) {
- if (LOCK((node = buffer->sucesr),knum))
- return(NULL);
- if (UNLOCK(buffer->nodeid,knum))
- return(NULL);
- buffer = getnod(node,knum);
- }
- return(buffer);
- }
-
- /* shift right */
-
- VOID shfrgt(n,bp,strbyt)
- PFAST COUNT n;
- TREEBUFF *bp;
- UCOUNT strbyt;
- {
- FAST TEXT *dp,*sp;
-
- sp = bp->ct_kyval + bp->nkb - 1;
- dp = sp + n;
- for (n = bp->nkb - strbyt; n-- > 0; ) /* strbyt org at 0, nkb org 1 */
- *dp-- = *sp--;
- }
-
- /* shift left */
-
- VOID shflft(n,bp,strbyt)
- PFAST COUNT n;
- TREEBUFF *bp;
- UCOUNT strbyt;
- {
- FAST TEXT *sp;
-
- sp = bp->ct_kyval + strbyt;
- cpybuf(sp - n,sp,bp->nkb - strbyt);
- }
-
- /* end of ctupdt.c */
-