home *** CD-ROM | disk | FTP | other *** search
- /* (C) Copyright 1984,85,86,87 Walter L. Peacock All Rights Reserved */
- /* u p d i l v l . c 9/19/87 */
- /* THIS PROGRAM BELONGS TO WALTER L. PEACOCK. IT IS CONSIDERED A TRADE */
- /* SECRET AND IS NOT TO BE DIVULGED OR USED BY PARTIES WHO HAVE NOT */
- /* RECEIVED WRITTEN AUTHORIZATION FROM THE OWNER. */
- /*----------------------------------------------------------------------------
- * updilvl() will update the upper level index node when the END KEY
- * of a lower level node is deleted. The new end key is copied into the
- * upper level index node and repeated as needed for each upper level.
- *---------------------------------------------------------------------------*/
-
- #include "cbtree.h"
-
- int updilvl(fdidx, node, keystr, btparmst)
- int fdidx;
- long node; /* original node */
- char *keystr; /* that node's end key */
- struct btcommo *btparmst;
- {
- extern long poptop();
- extern char *calloc();
- extern int strcmp();
- extern void free();
- extern int sp;
- static BTIDXBLK *lvlblk;
- long int lvlnode;
- int savsp;
- register int i;
-
- /* allocate space for the parent node */
- i = sizeof(BTIDXBLK) + btparmst->btcells * sizeof(BTIDX);
- if( !(lvlblk = (BTIDXBLK *) calloc(i, SZCHAR) ))
- ckerror(- CK_NOMEM, "99");
-
- savsp = sp; /* save the stack pointer */
-
- while( (lvlnode = poptop() ) != 0L){
- getidxr(fdidx, lvlnode, lvlblk, btparmst->btidxlen, btparmst->btkeylen);
- i = 0;
-
- while (lvlblk->btpage[i++].btptr != node){ /* loc lower node ptr */
- if(i >= lvlblk->cellicnt)
- ckerror(- CK_INDX, "100");
- }
- i--;
-
- strcpy(lvlblk->btpage[i].skeynme, keystr);
- putidxr(fdidx, lvlnode, lvlblk, btparmst);
-
- if (i < lvlblk->cellicnt -1) /* then not an end point */
- break;
-
- node = lvlnode; /* continue back up the tree */
- }
-
- freekeys(lvlblk);
- FREE(lvlblk);
-
- sp = savsp; /* restore the stack */
-
- return(BTCALLOK);
- }
-
-